Skip to content

Commit

Permalink
fix: store migration
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud committed Feb 20, 2024
1 parent c4c243e commit 5a4406a
Show file tree
Hide file tree
Showing 7 changed files with 430 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ tmp
/out-tsc
firebase-admin-sdk.json
dev
cache

# SDK Build
builds
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm'

export class AddUniqueStoreConstrain1708455034835 implements MigrationInterface {
name = 'AddUniqueStoreConstrain1708455034835'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "store-entry"
ADD CONSTRAINT "UQ_6f251cc141de0a8d84d7a4ac17d" UNIQUE ("projectId", "key")
`)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "store-entry" DROP CONSTRAINT "UQ_6f251cc141de0a8d84d7a4ac17d"
`)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class InitialSql3Migration1690195839899 implements MigrationInterface {
'CREATE INDEX "idx_project_owner_id" ON "project" ("ownerId") ',
)
await queryRunner.query(
'CREATE TABLE "store-entry" ("id" varchar(21) PRIMARY KEY NOT NULL, "created" datetime NOT NULL DEFAULT (datetime(\'now\')), "updated" datetime NOT NULL DEFAULT (datetime(\'now\')), "key" varchar NOT NULL, "projectId" varchar(21) NOT NULL, "value" text, CONSTRAINT "UQ_projectid_and_key" UNIQUE("projectId", "key"))',
'CREATE TABLE "store-entry" ("id" varchar(21) PRIMARY KEY NOT NULL, "created" datetime NOT NULL DEFAULT (datetime(\'now\')), "updated" datetime NOT NULL DEFAULT (datetime(\'now\')), "key" varchar NOT NULL, "projectId" varchar(21) NOT NULL, "value" text)',
)
await queryRunner.query(
'CREATE TABLE "user" ("id" varchar(21) PRIMARY KEY NOT NULL, "created" datetime NOT NULL DEFAULT (datetime(\'now\')), "updated" datetime NOT NULL DEFAULT (datetime(\'now\')), "email" varchar NOT NULL, "firstName" varchar NOT NULL, "lastName" varchar NOT NULL, "password" varchar NOT NULL, "status" varchar NOT NULL, "trackEvents" boolean, "newsLetter" boolean, CONSTRAINT "UQ_e12875dfb3b1d92d7d7c5377e22" UNIQUE ("email"))',
Expand Down
Loading

0 comments on commit 5a4406a

Please sign in to comment.