Skip to content

Commit 37dee3d

Browse files
committed
feat: add FORCE_DB_SYNC environment variable
1 parent 37895e6 commit 37dee3d

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/database.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { DataSource, DataSourceOptions } from 'typeorm';
2+
23
import { TypeORMLogger } from '~/helpers/logTypeorm';
34

45
const MySQLDataSourceOptions = {
@@ -12,7 +13,7 @@ const MySQLDataSourceOptions = {
1213
database: process.env.TYPEORM_DATABASE,
1314
logging: ['error'],
1415
logger: new TypeORMLogger(),
15-
synchronize: false,
16+
synchronize: process.env.FORCE_DB_SYNC === 'IKnowWhatIamDoing',
1617
migrationsRun: true,
1718
entities: [ 'dest/database/entity/*.js' ],
1819
subscribers: [ 'dest/database/entity/*.js' ],
@@ -28,7 +29,7 @@ const PGDataSourceOptions = {
2829
database: process.env.TYPEORM_DATABASE,
2930
logging: ['error'],
3031
logger: new TypeORMLogger(),
31-
synchronize: false,
32+
synchronize: process.env.FORCE_DB_SYNC === 'IKnowWhatIamDoing',
3233
migrationsRun: true,
3334
entities: [ 'dest/database/entity/*.js' ],
3435
subscribers: [ 'dest/database/entity/*.js' ],
@@ -40,7 +41,7 @@ const SQLiteDataSourceOptions = {
4041
database: process.env.TYPEORM_DATABASE ?? 'sogebot.db',
4142
logging: ['error'],
4243
logger: new TypeORMLogger(),
43-
synchronize: false,
44+
synchronize: process.env.FORCE_DB_SYNC === 'IKnowWhatIamDoing',
4445
migrationsRun: true,
4546
entities: [ 'dest/database/entity/*.js' ],
4647
subscribers: [ 'dest/database/entity/*.js' ],

0 commit comments

Comments
 (0)