Skip to content

Commit 7bbac67

Browse files
author
hersveit
committed
migrations
1 parent 2f23665 commit 7bbac67

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const { MigrationInterface, QueryRunner } = require("typeorm");
2+
3+
module.exports = class Init1717961913489 {
4+
name = 'Init1717961913489'
5+
6+
async up(queryRunner) {
7+
await queryRunner.query(`CREATE TABLE "user" ("id" SERIAL NOT NULL, "email" character varying NOT NULL, "hash" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL, "emailConfirmed" boolean NOT NULL DEFAULT false, "refreshTokenHash" character varying, "emailConfirmToken" character varying, CONSTRAINT "UQ_e12875dfb3b1d92d7d7c5377e22" UNIQUE ("email"), CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))`);
8+
}
9+
10+
async down(queryRunner) {
11+
await queryRunner.query(`DROP TABLE "user"`);
12+
}
13+
}

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
1212
"typeorm:generate": "node ./scripts/typeorm/migrationGenerate.js",
1313
"typeorm:run": "node ./scripts/typeorm/migrationRun.js",
14-
"api:build": "nest build api",
1514
"api:dev": "NODE_ENV=development APP=api nest start api --watch",
1615
"api:prod": "NODE_ENV=production APP=api node dist/apps/api/apps/api/src/main.js",
1716
"test": "jest"

scripts/typeorm/migrationGenerate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { execSync } = require('node:child_process');
22

33
const name = process.argv[2];
44
execSync(
5-
`npx typeorm migration:generate -d ./typeorm.datasource.js --outputJs ./libs/repository/src/migrations/${name}`,
5+
`pnpm run build && npx typeorm migration:generate -d ./typeorm.datasource.js --outputJs ./libs/repository/src/migrations/${name}`,
66
{
77
stdio: 'inherit',
88
encoding: 'utf-8',

scripts/typeorm/migrationRun.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const { execSync } = require('node:child_process');
22

3-
execSync(`npx typeorm migration:run -d ./typeorm.datasource.js`, {
3+
execSync(`pnpm run build && npx typeorm migration:run -d ./typeorm.datasource.js`, {
44
stdio: 'inherit',
55
encoding: 'utf-8',
66
});

typeorm.datasource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function getConfig() {
1313
password: env?.parsed['DB_PASSWORD'],
1414
database: env?.parsed['DB_NAME'],
1515
migrations: [resolve(__dirname, 'libs/repository/src/migrations/*.js')],
16-
entities: [resolve(__dirname, 'dist/libs/repository/entities/*.js')],
16+
entities: [resolve(__dirname, 'dist/apps/api/libs/repository/src/entities/*.js')],
1717
});
1818
}
1919

0 commit comments

Comments
 (0)