From 94424f17a271f92ebdd827380c93debe4355ba2a Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 21 Sep 2021 10:24:43 +0200 Subject: [PATCH 1/3] Fixed database tool to read .env config when built. --- database/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/database/package.json b/database/package.json index 4656dab43..172253cea 100644 --- a/database/package.json +++ b/database/package.json @@ -10,9 +10,9 @@ "scripts": { "build": "tsc --build", "clean": "tsc --build --clean", - "up": "cd build && node src/index.js up", - "down": "cd build && node src/index.js down", - "reset": "cd build && node src/index.js reset", + "up": "node build/src/index.js up", + "down": "node build/src/index.js down", + "reset": "node build/src/index.js reset", "dev_up": "nodemon -w ./ --ext ts --exec ts-node src/index.ts up", "dev_down": "nodemon -w ./ --ext ts --exec ts-node src/index.ts down", "dev_reset": "nodemon -w ./ --ext ts --exec ts-node src/index.ts reset", From cebf92c451fbc5c525019a9102a7a44beecb6e23 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 21 Sep 2021 10:34:56 +0200 Subject: [PATCH 2/3] fixed migrations directory to default to the production version. This is the downside of this patch - the .env file has to be different in dev and production version --- database/.env.dist | 5 ++++- database/src/config/index.ts | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/database/.env.dist b/database/.env.dist index 8488fb1bf..07db5fd17 100644 --- a/database/.env.dist +++ b/database/.env.dist @@ -4,4 +4,7 @@ DB_USER=root DB_PASSWORD= DB_DATABASE=gradido_community MIGRATIONS_TABLE=migrations -MIGRATIONS_DIRECTORY=./migrations/ \ No newline at end of file +// This value is set to the default for the built version. +// Therefore you need to overwrite this when using the dev version +// MIGRATIONS_DIRECTORY=./migrations/ +MIGRATIONS_DIRECTORY=./build/migrations/ \ No newline at end of file diff --git a/database/src/config/index.ts b/database/src/config/index.ts index 908d40311..a6a7a3385 100644 --- a/database/src/config/index.ts +++ b/database/src/config/index.ts @@ -13,7 +13,7 @@ const database = { const migrations = { MIGRATIONS_TABLE: process.env.MIGRATIONS_TABLE || 'migrations', - MIGRATIONS_DIRECTORY: process.env.MIGRATIONS_DIRECTORY || './migrations/', + MIGRATIONS_DIRECTORY: process.env.MIGRATIONS_DIRECTORY || './build/migrations/', } const CONFIG = { ...database, ...migrations } From f9a40be53926270250777e9b732e5b36078680f0 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Tue, 21 Sep 2021 19:18:08 +0200 Subject: [PATCH 3/3] use another .env file, else things get too complicated since production and dev .env's are no longer compatible to eachother --- database/.env.dist | 5 +---- database/build/.env.dist | 2 ++ database/package.json | 6 +++--- database/src/config/index.ts | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 database/build/.env.dist diff --git a/database/.env.dist b/database/.env.dist index 07db5fd17..8488fb1bf 100644 --- a/database/.env.dist +++ b/database/.env.dist @@ -4,7 +4,4 @@ DB_USER=root DB_PASSWORD= DB_DATABASE=gradido_community MIGRATIONS_TABLE=migrations -// This value is set to the default for the built version. -// Therefore you need to overwrite this when using the dev version -// MIGRATIONS_DIRECTORY=./migrations/ -MIGRATIONS_DIRECTORY=./build/migrations/ \ No newline at end of file +MIGRATIONS_DIRECTORY=./migrations/ \ No newline at end of file diff --git a/database/build/.env.dist b/database/build/.env.dist new file mode 100644 index 000000000..505546e1b --- /dev/null +++ b/database/build/.env.dist @@ -0,0 +1,2 @@ +// For production you need to put your env file in here. +// Please copy the dist file from the root folder in here and rename it to .env \ No newline at end of file diff --git a/database/package.json b/database/package.json index 172253cea..4656dab43 100644 --- a/database/package.json +++ b/database/package.json @@ -10,9 +10,9 @@ "scripts": { "build": "tsc --build", "clean": "tsc --build --clean", - "up": "node build/src/index.js up", - "down": "node build/src/index.js down", - "reset": "node build/src/index.js reset", + "up": "cd build && node src/index.js up", + "down": "cd build && node src/index.js down", + "reset": "cd build && node src/index.js reset", "dev_up": "nodemon -w ./ --ext ts --exec ts-node src/index.ts up", "dev_down": "nodemon -w ./ --ext ts --exec ts-node src/index.ts down", "dev_reset": "nodemon -w ./ --ext ts --exec ts-node src/index.ts reset", diff --git a/database/src/config/index.ts b/database/src/config/index.ts index a6a7a3385..908d40311 100644 --- a/database/src/config/index.ts +++ b/database/src/config/index.ts @@ -13,7 +13,7 @@ const database = { const migrations = { MIGRATIONS_TABLE: process.env.MIGRATIONS_TABLE || 'migrations', - MIGRATIONS_DIRECTORY: process.env.MIGRATIONS_DIRECTORY || './build/migrations/', + MIGRATIONS_DIRECTORY: process.env.MIGRATIONS_DIRECTORY || './migrations/', } const CONFIG = { ...database, ...migrations }