Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix: default DATABASE_SYNCHRONIZE to false to prevent auto-schema changes in production

rmyndharisd25fd12b2639
diff --git a/docker-compose.yml b/docker-compose.yml
index 7dfd43c73..229ea4f43 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -41,7 +41,7 @@ services:
- DATABASE_PORT=${DATABASE_PORT:-5432}
- DATABASE_USERNAME=${DATABASE_USERNAME:-openwa}
- DATABASE_PASSWORD=${DATABASE_PASSWORD:-openwa}
- - DATABASE_SYNCHRONIZE=${DATABASE_SYNCHRONIZE:-true}
+ - DATABASE_SYNCHRONIZE=${DATABASE_SYNCHRONIZE:-false}
# Engine
- ENGINE_TYPE=${ENGINE_TYPE:-whatsapp-web.js}
- SESSION_DATA_PATH=/app/data/sessions
diff --git a/src/app.module.ts b/src/app.module.ts
index 8569c4878..ad3394476 100644
--- a/src/app.module.ts
+++ b/src/app.module.ts
@@ -72,7 +72,7 @@ if (process.env.QUEUE_ENABLED === 'true') {
__dirname + '/modules/webhook/**/*.entity{.ts,.js}',
__dirname + '/modules/message/**/*.entity{.ts,.js}',
],
- synchronize: configService.get<boolean>('dataDatabase.synchronize', true),
+ synchronize: configService.get<boolean>('dataDatabase.synchronize', false),
logging: configService.get<boolean>('dataDatabase.logging', false),
};
diff --git a/src/config/configuration.ts b/src/config/configuration.ts
index 2864d0f91..2df110b07 100644
--- a/src/config/configuration.ts
+++ b/src/config/configuration.ts
@@ -36,7 +36,7 @@ export default () => ({
port: parseInt(process.env.DATABASE_PORT || '5432', 10),
username: process.env.DATABASE_USERNAME,
password: process.env.DATABASE_PASSWORD,
- synchronize: process.env.DATABASE_SYNCHRONIZE !== 'false',
+ synchronize: process.env.DATABASE_SYNCHRONIZE === 'true',
logging: process.env.DATABASE_LOGGING === 'true',
// Connection pooling (PostgreSQL)
poolSize: parseInt(process.env.DATABASE_POOL_SIZE || '10', 10),
diff --git a/src/database/data-source.ts b/src/database/data-source.ts
index 24d07cbb0..f59f9f04f 100644
--- a/src/database/data-source.ts
+++ b/src/database/data-source.ts
@@ -13,7 +13,7 @@ const sqliteDataSource = new DataSource({
database: process.env.DATABASE_NAME || './data/openwa.sqlite',
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
migrations: [__dirname + '/migrations/*{.ts,.js}'],
- synchronize: !isProduction,
+ synchronize: false,
logging: process.env.DATABASE_LOGGING === 'true',
});