Merge pull request #367 from getmaxun/login-rob
feat: db sync in dev mode
This commit is contained in:
@@ -29,7 +29,13 @@ export const connectDB = async () => {
|
|||||||
export const syncDB = async () => {
|
export const syncDB = async () => {
|
||||||
try {
|
try {
|
||||||
//setupAssociations();
|
//setupAssociations();
|
||||||
await sequelize.sync({ force: false }); // force: true will drop and recreate tables on every run
|
const isDevelopment = process.env.NODE_ENV === 'development';
|
||||||
|
// force: true will drop and recreate tables on every run
|
||||||
|
// Use `alter: true` only in development mode
|
||||||
|
await sequelize.sync({
|
||||||
|
force: false,
|
||||||
|
alter: isDevelopment
|
||||||
|
});
|
||||||
console.log('Database synced successfully!');
|
console.log('Database synced successfully!');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Failed to sync database:', error);
|
console.error('Failed to sync database:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user