feat: add force sync option for db, don't alter by default
parent
f066ab53f6
commit
c4625b77bd
|
@ -6,6 +6,7 @@ DB_USER=root
|
||||||
DB_PASS=root
|
DB_PASS=root
|
||||||
DB_HOST=db # If using docker compose, this should match the container service name
|
DB_HOST=db # If using docker compose, this should match the container service name
|
||||||
DB_PORT=5432
|
DB_PORT=5432
|
||||||
|
DB_FORCE_SYNC=false # Whether or not to DROP all tables and recreate to match the current models
|
||||||
ALLOW_REGISTRATION=true
|
ALLOW_REGISTRATION=true
|
||||||
HTTP_INTERFACE=0.0.0.0
|
HTTP_INTERFACE=0.0.0.0
|
||||||
HTTP_PORT=3000
|
HTTP_PORT=3000
|
||||||
|
|
|
@ -37,8 +37,14 @@ for (const modelDefiner of modelDefiners) {
|
||||||
modelDefiner(sequelize);
|
modelDefiner(sequelize);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create tables if they don't exist
|
/**
|
||||||
// Update columns to match if the table already exists
|
* Synchronise the database (create new tables) to match the models defined
|
||||||
sequelize.sync({ alter: true });
|
* above.
|
||||||
|
*
|
||||||
|
* WARNING: If force is set, sequelize will delete columns and create new ones
|
||||||
|
* if their types have changed!
|
||||||
|
* Use sequelize-cli and migrations instead!
|
||||||
|
*/
|
||||||
|
sequelize.sync({ force: process.env.DB_FORCE_SYNC });
|
||||||
|
|
||||||
export default sequelize;
|
export default sequelize;
|
||||||
|
|
Loading…
Reference in New Issue