Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into refactor/webhook
- Loading branch information
Showing
11 changed files
with
244 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...database/migration/postgres/1709566642531-add-platform-foreign-key-to-project-postgres.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm' | ||
import { logger } from 'server-shared' | ||
|
||
export class AddPlatformForeignKeyToProjectPostgres1709566642531 implements MigrationInterface { | ||
name = 'AddPlatformForeignKeyToProjectPostgres1709566642531' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "project" | ||
ADD CONSTRAINT "fk_project_platform_id" FOREIGN KEY ("platformId") REFERENCES "platform"("id") | ||
ON DELETE RESTRICT ON UPDATE RESTRICT | ||
`) | ||
|
||
logger.info({ name: this.name }, 'up') | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "project" DROP CONSTRAINT "fk_project_platform_id" | ||
`) | ||
|
||
logger.info({ name: this.name }, 'down') | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
124 changes: 124 additions & 0 deletions
124
...app/database/migration/sqlite/1709566629593-add-platform-foreign-key-to-project-sqlite.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm' | ||
import { logger } from 'server-shared' | ||
|
||
export class AddPlatformForeignKeyToProjectSqlite1709566629593 implements MigrationInterface { | ||
name = 'AddPlatformForeignKeyToProjectSqlite1709566629593' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
DROP INDEX "idx_project_owner_id" | ||
`) | ||
await queryRunner.query(` | ||
DROP INDEX "idx_project_platform_id_external_id" | ||
`) | ||
await queryRunner.query(` | ||
CREATE TABLE "temporary_project" ( | ||
"id" varchar(21) PRIMARY KEY NOT NULL, | ||
"created" datetime NOT NULL DEFAULT (datetime('now')), | ||
"updated" datetime NOT NULL DEFAULT (datetime('now')), | ||
"ownerId" varchar(21) NOT NULL, | ||
"displayName" varchar NOT NULL, | ||
"notifyStatus" varchar NOT NULL, | ||
"platformId" varchar(21) NOT NULL, | ||
"externalId" varchar, | ||
CONSTRAINT "fk_project_owner_id" FOREIGN KEY ("ownerId") REFERENCES "user" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, | ||
CONSTRAINT "fk_project_platform_id" FOREIGN KEY ("platformId") REFERENCES "platform" ("id") ON DELETE RESTRICT ON UPDATE RESTRICT | ||
) | ||
`) | ||
await queryRunner.query(` | ||
INSERT INTO "temporary_project"( | ||
"id", | ||
"created", | ||
"updated", | ||
"ownerId", | ||
"displayName", | ||
"notifyStatus", | ||
"platformId", | ||
"externalId" | ||
) | ||
SELECT "id", | ||
"created", | ||
"updated", | ||
"ownerId", | ||
"displayName", | ||
"notifyStatus", | ||
"platformId", | ||
"externalId" | ||
FROM "project" | ||
`) | ||
await queryRunner.query(` | ||
DROP TABLE "project" | ||
`) | ||
await queryRunner.query(` | ||
ALTER TABLE "temporary_project" | ||
RENAME TO "project" | ||
`) | ||
await queryRunner.query(` | ||
CREATE INDEX "idx_project_owner_id" ON "project" ("ownerId") | ||
`) | ||
await queryRunner.query(` | ||
CREATE UNIQUE INDEX "idx_project_platform_id_external_id" ON "project" ("platformId", "externalId") | ||
`) | ||
|
||
logger.info({ name: this.name }, 'up') | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
DROP INDEX "idx_project_platform_id_external_id" | ||
`) | ||
await queryRunner.query(` | ||
DROP INDEX "idx_project_owner_id" | ||
`) | ||
await queryRunner.query(` | ||
ALTER TABLE "project" | ||
RENAME TO "temporary_project" | ||
`) | ||
await queryRunner.query(` | ||
CREATE TABLE "project" ( | ||
"id" varchar(21) PRIMARY KEY NOT NULL, | ||
"created" datetime NOT NULL DEFAULT (datetime('now')), | ||
"updated" datetime NOT NULL DEFAULT (datetime('now')), | ||
"ownerId" varchar(21) NOT NULL, | ||
"displayName" varchar NOT NULL, | ||
"notifyStatus" varchar NOT NULL, | ||
"platformId" varchar(21), | ||
"externalId" varchar, | ||
CONSTRAINT "fk_project_owner_id" FOREIGN KEY ("ownerId") REFERENCES "user" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION | ||
) | ||
`) | ||
await queryRunner.query(` | ||
INSERT INTO "project"( | ||
"id", | ||
"created", | ||
"updated", | ||
"ownerId", | ||
"displayName", | ||
"notifyStatus", | ||
"platformId", | ||
"externalId" | ||
) | ||
SELECT "id", | ||
"created", | ||
"updated", | ||
"ownerId", | ||
"displayName", | ||
"notifyStatus", | ||
"platformId", | ||
"externalId" | ||
FROM "temporary_project" | ||
`) | ||
await queryRunner.query(` | ||
DROP TABLE "temporary_project" | ||
`) | ||
await queryRunner.query(` | ||
CREATE UNIQUE INDEX "idx_project_platform_id_external_id" ON "project" ("platformId", "externalId") | ||
`) | ||
await queryRunner.query(` | ||
CREATE INDEX "idx_project_owner_id" ON "project" ("ownerId") | ||
`) | ||
|
||
logger.info({ name: this.name }, 'down') | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.