Merge pull request #68 from FunkeCoder23/66-remove-sync-alter

Remove alter param from database sync
This commit is contained in:
Gabisonfire
2024-02-05 08:14:29 -05:00
committed by GitHub
3 changed files with 12 additions and 10 deletions

View File

@@ -27,6 +27,7 @@ MAX_SINGLE_TORRENT_CONNECTIONS=10
TORRENT_TIMEOUT=30000 TORRENT_TIMEOUT=30000
UDP_TRACKERS_ENABLED=true UDP_TRACKERS_ENABLED=true
CONSUMER_REPLICAS=3 CONSUMER_REPLICAS=3
AUTO_CREATE_AND_APPLY_MIGRATIONS=false # Fix for #66 - toggle on for development
# Producer # Producer
RabbitMqConfiguration__Host=rabbitmq RabbitMqConfiguration__Host=rabbitmq

View File

@@ -24,7 +24,7 @@ export const databaseConfig = {
POSTGRES_DB: process.env.POSTGRES_DB || 'knightcrawler', POSTGRES_DB: process.env.POSTGRES_DB || 'knightcrawler',
POSTGRES_USER: process.env.POSTGRES_USER || 'postgres', POSTGRES_USER: process.env.POSTGRES_USER || 'postgres',
POSTGRES_PASSWORD: process.env.POSTGRES_PASSWORD || 'postgres', POSTGRES_PASSWORD: process.env.POSTGRES_PASSWORD || 'postgres',
ENABLE_SYNC: true AUTO_CREATE_AND_APPLY_MIGRATIONS: parseBool(process.env.AUTO_CREATE_AND_APPLY_MIGRATIONS, false)
} }
// Combine the environment variables into a connection string // Combine the environment variables into a connection string

View File

@@ -184,14 +184,15 @@ File.hasMany(Subtitle, { foreignKey: 'fileId', constraints: false });
Subtitle.belongsTo(File, { foreignKey: 'fileId', constraints: false }); Subtitle.belongsTo(File, { foreignKey: 'fileId', constraints: false });
export function connect() { export function connect() {
if (databaseConfig.ENABLE_SYNC) { return database.sync({ alter: databaseConfig.AUTO_CREATE_AND_APPLY_MIGRATIONS })
return database.sync({ alter: true })
.catch(error => { .catch(error => {
console.error('Failed syncing database: ', error); console.error('Failed syncing database: ', error.message);
throw error; throw error;
}); });
} // I'm not convinced this code is needed. If anyone can see where it leads, or what it does, please inform me.
return Promise.resolve(); // For now, I'm commenting it out. I don't think we ever reach this at the moment anyway as the previous ENABLE_SYNC
// was always on.
// return Promise.resolve();
} }
export function getProvider(provider) { export function getProvider(provider) {