Merge pull request #68 from FunkeCoder23/66-remove-sync-alter
Remove alter param from database sync
This commit is contained in:
@@ -24,7 +24,7 @@ export const databaseConfig = {
|
||||
POSTGRES_DB: process.env.POSTGRES_DB || 'knightcrawler',
|
||||
POSTGRES_USER: process.env.POSTGRES_USER || '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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import moment from 'moment';
|
||||
import { Sequelize, Op, DataTypes, fn, col, literal } from 'sequelize';
|
||||
import { databaseConfig } from './config.js';
|
||||
import {logger} from "./logger.js";
|
||||
import { logger } from "./logger.js";
|
||||
import * as Promises from './promises.js';
|
||||
|
||||
const database = new Sequelize(
|
||||
@@ -184,14 +184,15 @@ File.hasMany(Subtitle, { foreignKey: 'fileId', constraints: false });
|
||||
Subtitle.belongsTo(File, { foreignKey: 'fileId', constraints: false });
|
||||
|
||||
export function connect() {
|
||||
if (databaseConfig.ENABLE_SYNC) {
|
||||
return database.sync({ alter: true })
|
||||
.catch(error => {
|
||||
console.error('Failed syncing database: ', error);
|
||||
throw error;
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
return database.sync({ alter: databaseConfig.AUTO_CREATE_AND_APPLY_MIGRATIONS })
|
||||
.catch(error => {
|
||||
console.error('Failed syncing database: ', error.message);
|
||||
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
|
||||
// was always on.
|
||||
// return Promise.resolve();
|
||||
}
|
||||
|
||||
export function getProvider(provider) {
|
||||
|
||||
Reference in New Issue
Block a user