Added movability of dialogs
This commit is contained in:
@@ -8,13 +8,14 @@ const sequelize = new Sequelize(process.env.DB_NAME, process.env.DB_USER, proces
|
||||
dialect: 'postgres',
|
||||
define: {
|
||||
timestamps: false
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const createSchemas = async () => {
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS community');
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS logs');
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS type');
|
||||
await sequelize.query('CREATE SCHEMA IF NOT EXISTS service');
|
||||
};
|
||||
|
||||
const initializeDatabase = async () => {
|
||||
@@ -24,21 +25,10 @@ const initializeDatabase = async () => {
|
||||
};
|
||||
|
||||
const syncModels = async (models) => {
|
||||
// Stellen Sie sicher, dass alle Modelle vorhanden sind
|
||||
if (!models.SettingsType || !models.UserParamValue || !models.UserParamType || !models.UserRightType ||
|
||||
!models.User || !models.UserParam || !models.Login || !models.UserRight) {
|
||||
throw new Error('Models are not properly loaded.');
|
||||
// Nur einmaliges sync ohne alter/force
|
||||
for (const model of Object.values(models)) {
|
||||
await model.sync();
|
||||
}
|
||||
|
||||
// Synchronisieren Sie die Modelle in der gewünschten Reihenfolge
|
||||
await models.SettingsType.sync({ alter: true });
|
||||
await models.UserParamValue.sync({ alter: true });
|
||||
await models.UserParamType.sync({ alter: true });
|
||||
await models.UserRightType.sync({ alter: true });
|
||||
await models.User.sync({ alter: true });
|
||||
await models.UserParam.sync({ alter: true });
|
||||
await models.Login.sync({ alter: true });
|
||||
await models.UserRight.sync({ alter: true });
|
||||
};
|
||||
|
||||
export { sequelize, initializeDatabase };
|
||||
|
||||
Reference in New Issue
Block a user