Skip to content

Commit

Permalink
Run migrations with TS sources (#3610)
Browse files Browse the repository at this point in the history
  • Loading branch information
rakyi authored May 16, 2024
1 parent e1a927d commit e24de9c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions db/dataSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const dataSource = new DataSource({
username: GRAPHER_DB_USER || "root",
password: GRAPHER_DB_PASS || "",
database: GRAPHER_DB_NAME,
entities: ["itsJustJavascript/db/model/**/!(*.test).js"],
migrations: ["itsJustJavascript/db/migration/**/!(*.test).js"],
entities: ["db/model/**/!(*.test).ts"],
migrations: ["db/migration/**/!(*.test).ts"],
charset: "utf8mb4",
})
4 changes: 2 additions & 2 deletions db/tests/dataSource.dbtests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const dataSource = new DataSource({
username: GRAPHER_TEST_DB_USER || "root",
password: GRAPHER_TEST_DB_PASS || "",
database: GRAPHER_TEST_DB_NAME,
entities: ["itsJustJavascript/db/model/**/!(*.test).js"],
migrations: ["itsJustJavascript/db/migration/**/!(*.test).js"],
entities: ["db/model/**/!(*.test).ts"],
migrations: ["db/migration/**/!(*.test).ts"],
charset: "utf8mb4",
})
2 changes: 1 addition & 1 deletion db/tests/run-db-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ docker compose -f docker-compose.dbtests.yml up -d

echo '==> Running migrations'

yarn tsx node_modules/typeorm/cli.js migration:run -d db/tests/dataSource.dbtests.ts
yarn tsx --tsconfig tsconfig.tsx.json node_modules/typeorm/cli.js migration:run -d db/tests/dataSource.dbtests.ts

echo '==> Running tests'
if ! yarn run jest --config=jest.db.config.js --runInBand # runInBand runs multiple test files serially - useful to avoid weird race conditions
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
"fixLint": "eslint . --fix",
"fixPrettierAll": "yarn prettier --write \"**/*.{tsx,ts,jsx,js,json,md,html,css,scss,yml}\"",
"runRegionsUpdater": "tsx --tsconfig tsconfig.tsx.json devTools/regionsUpdater/update.ts",
"runDbMigrations": "tsx node_modules/typeorm/cli.js migration:run -d db/dataSource.ts",
"runDbMigrations": "tsx --tsconfig tsconfig.tsx.json node_modules/typeorm/cli.js migration:run -d db/dataSource.ts",
"refreshPageviews": "tsx --tsconfig tsconfig.tsx.json db/refreshPageviewsFromDatasette.ts",
"revertLastDbMigration": "tsx node_modules/typeorm/cli.js migration:revert -d db/dataSource.ts",
"revertLastDbMigration": "tsx --tsconfig tsconfig.tsx.json node_modules/typeorm/cli.js migration:revert -d db/dataSource.ts",
"startAdminServer": "node --enable-source-maps ./itsJustJavascript/adminSiteServer/app.js",
"startAdminDevServer": "tsx watch --tsconfig tsconfig.tsx.json adminSiteServer/app.tsx",
"startLocalCloudflareFunctions": "wrangler pages dev localBake --compatibility-date 2023-10-09",
Expand Down

0 comments on commit e24de9c

Please sign in to comment.