Skip to content

Commit

Permalink
Merge pull request #4078 from activepieces/fiix/remove-unused-index
Browse files Browse the repository at this point in the history
fix: remove unused index
  • Loading branch information
abuaboud committed Mar 3, 2024
2 parents 9d9fd32 + c9bc890 commit f1521d2
Show file tree
Hide file tree
Showing 4 changed files with 59 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")
`)
}

}
@@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm'

export class DropUnusedPlatformIndex1709500873378 implements MigrationInterface {
name = 'DropUnusedPlatformIndex1709500873378'

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "project" DROP CONSTRAINT "fk_project_platform_id"
`)
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
ALTER TABLE "project"
ADD CONSTRAINT "fk_project_platform_id" FOREIGN KEY ("platformId") REFERENCES "platform"("id") ON DELETE NO ACTION ON UPDATE NO ACTION
`)
}

}
8 changes: 7 additions & 1 deletion packages/server/api/src/app/database/postgres-connection.ts
Expand Up @@ -109,6 +109,8 @@ import { AddShowActivityLogToPlatform1708861032399 } from './migration/postgres/
import { MakePlatformNotNullable1705969874745 } from './migration/postgres/1705969874745-MakePlatformNotNullable'
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 @@ -233,6 +235,7 @@ const getMigrations = (): (new () => MigrationInterface)[] => {
AddShowActivityLogToPlatform1708861032399,
MakePlatformNotNullable1705969874745,
AddSlugToGitRepo1709151540095,
DropUnusedPlatformIndex1709500873378,
)
break
case ApEdition.ENTERPRISE:
Expand Down Expand Up @@ -278,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
1 change: 0 additions & 1 deletion packages/server/api/src/app/project/project-entity.ts
Expand Up @@ -33,7 +33,6 @@ export const ProjectEntity = new EntitySchema<ProjectSchema>({
},
platformId: {
...ApIdSchema,
nullable: true,
},
externalId: {
type: String,
Expand Down

0 comments on commit f1521d2

Please sign in to comment.