Skip to content

Commit

Permalink
fix(database): fix migration service
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemajesty committed Dec 8, 2023
1 parent 80e668e commit 6b31ffe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 18 deletions.
4 changes: 2 additions & 2 deletions dist/src/infra/repository/postgres/repository.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"infra": "./scripts/mongo/start-replicaset.sh",
"scaffold": "./node_modules/@mikemajesty/microservice-crud/bin/microservice-crud",
"typeorm": "ts-node \"./node_modules/typeorm/cli.js\"",
"migration-postgres:create": "yarn typeorm migration:create \"./src/infra/database/postgres/migrations/migration\"",
"migration-postgres:create": "yarn typeorm migration:create \"./src/infra/database/postgres/migrations/rename\"",
"migration-postgres:run": "npm run typeorm migration:run -- -d ./src/infra/database/postgres/config --transaction none",
"make-badges": "istanbul-badges-readme"
},
Expand Down Expand Up @@ -115,6 +115,6 @@
"ts-loader": "^9.2.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "4.1.1",
"typescript": "^4.7.4"
"typescript": "5.1.6"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class createTableCats1679532974085 implements MigrationInterface {
transaction = false;

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE IF NOT EXISTS schema1.cats (
await queryRunner.query(`CREATE TABLE IF NOT EXISTS public.cats (
id uuid NOT NULL,
"name" text NOT NULL,
breed text NOT NULL,
Expand All @@ -14,21 +14,9 @@ export class createTableCats1679532974085 implements MigrationInterface {
"deletedAt" timestamp NULL,
CONSTRAINT "PK_611e3c0a930b4ddc1541422864c" PRIMARY KEY (id)
);`);

await queryRunner.query(`CREATE TABLE IF NOT EXISTS schema2.cats (
id uuid NOT NULL,
"name" text NOT NULL,
breed text NOT NULL,
age int4 NOT NULL,
"createdAt" timestamp NOT NULL DEFAULT now(),
"updatedAt" timestamp NOT NULL DEFAULT now(),
"deletedAt" timestamp NULL,
CONSTRAINT "PK_611e3c0a930b4ddc1541422864c" PRIMARY KEY (id)
);`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE IF EXISTS schema1.cats;`);
await queryRunner.query(`DROP TABLE IF EXISTS schema2.cats;`);
await queryRunner.query(`DROP TABLE IF EXISTS public.cats;`);
}
}

0 comments on commit 6b31ffe

Please sign in to comment.