Add alter param back to database sync. Default to false. Make toggleable from .env file.

This commit is contained in:
purple_emily
2024-02-05 10:43:20 +00:00
parent ecdae702ad
commit 287507d8e0
3 changed files with 11 additions and 9 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_DATABASE: process.env.POSTGRES_DATABASE || 'knightcrawler', POSTGRES_DATABASE: process.env.POSTGRES_DATABASE || 'knightcrawler',
POSTGRES_USERNAME: process.env.POSTGRES_USERNAME || 'postgres', POSTGRES_USERNAME: process.env.POSTGRES_USERNAME || '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() .catch(error => {
.catch(error => { console.error('Failed syncing database: ', error.message);
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.
} // For now, I'm commenting it out. I don't think we ever reach this at the moment anyway as the previous ENABLE_SYNC
return Promise.resolve(); // was always on.
// return Promise.resolve();
} }
export function getProvider(provider) { export function getProvider(provider) {