Skip to content

Commit

Permalink
chore: set not null on the community
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud committed Mar 3, 2024
1 parent 36bc79d commit 34fe972
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
@@ -0,0 +1,33 @@
import { MigrationInterface, QueryRunner } from 'typeorm'

export class SetNotNullOnPlatform1709505632771 implements MigrationInterface {
name = 'SetNotNullOnPlatform1709505632771'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
DROP INDEX "public"."idx_project_platform_id_external_id"
`)
await queryRunner.query(`
ALTER TABLE "project"
ALTER COLUMN "platformId"
SET NOT NULL
`)
await queryRunner.query(`
CREATE UNIQUE INDEX "idx_project_platform_id_external_id" ON "project" ("platformId", "externalId")
`)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
DROP INDEX "public"."idx_project_platform_id_external_id"
`)
await queryRunner.query(`
ALTER TABLE "project"
ALTER COLUMN "platformId" DROP NOT NULL
`)
await queryRunner.query(`
CREATE UNIQUE INDEX "idx_project_platform_id_external_id" ON "project" ("platformId", "externalId")
`)
}

}
8 changes: 6 additions & 2 deletions packages/server/api/src/app/database/postgres-connection.ts
Expand Up @@ -110,6 +110,7 @@ import { MakePlatformNotNullable1705969874745 } from './migration/postgres/17059
import { AddPlatformToPostgres1709052740378 } from './migration/postgres/1709052740378-AddPlatformToPostgres'
import { AddSlugToGitRepo1709151540095 } from './migration/postgres/1709151540095-add-slug-to-git-repo'
import { DropUnusedPlatformIndex1709500873378 } from './migration/postgres/1709500873378-DropUnusedPlatformIndex'
import { SetNotNullOnPlatform1709505632771 } from './migration/1709505632771-SetNotNullOnPlatform'

const getSslConfig = (): boolean | TlsOptions => {
const useSsl = system.get(SystemProp.POSTGRES_USE_SSL)
Expand Down Expand Up @@ -182,7 +183,6 @@ const getMigrations = (): (new () => MigrationInterface)[] => {
AddTriggerTestStrategy1707087022764,
AddCategoriesToPieceMetadataPostgres1707231704973,
AddUniqueStoreConstraint1708521505204,
DropUnusedPlatformIndex1709500873378,
]

const edition = getEdition()
Expand Down Expand Up @@ -235,6 +235,7 @@ const getMigrations = (): (new () => MigrationInterface)[] => {
AddShowActivityLogToPlatform1708861032399,
MakePlatformNotNullable1705969874745,
AddSlugToGitRepo1709151540095,
DropUnusedPlatformIndex1709500873378,
)
break
case ApEdition.ENTERPRISE:
Expand Down Expand Up @@ -280,10 +281,13 @@ const getMigrations = (): (new () => MigrationInterface)[] => {
AddShowActivityLogToPlatform1708861032399,
MakePlatformNotNullable1705969874745,
AddSlugToGitRepo1709151540095,
DropUnusedPlatformIndex1709500873378,
)
break
case ApEdition.COMMUNITY:
commonMigration.push(AddPlatformToPostgres1709052740378)
commonMigration.push(
AddPlatformToPostgres1709052740378,
SetNotNullOnPlatform1709505632771)
break
}

Expand Down

0 comments on commit 34fe972

Please sign in to comment.