-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(modules/entities): change unique constraints
- Loading branch information
Showing
6 changed files
with
84 additions
and
22 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
src/migrations/1711444943012-change-unique-constraints-for-entities.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,67 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm' | ||
|
||
export class ChangeUniqueConstraintsForEntities1711444943012 | ||
implements MigrationInterface | ||
{ | ||
name = 'ChangeUniqueConstraintsForEntities1711444943012' | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "track" DROP CONSTRAINT "UQ_2315a3e4d182a2a460f2e773693"` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "track" DROP CONSTRAINT "UQ_10a3b0c40212c31ba55419523a4"` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "album" DROP CONSTRAINT "UQ_d9c245cc24c616be9b5d72900f5"` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "album" DROP CONSTRAINT "UQ_195b9a4b8052042a431847461ab"` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "artist" DROP CONSTRAINT "UQ_941b1071e844e94caec980a929c"` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "artist" DROP CONSTRAINT "UQ_3df7b480e9f4bc6eecca12a31a0"` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "track" ADD CONSTRAINT "TRACK_UNIQUE" UNIQUE ("externalId", "href")` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "album" ADD CONSTRAINT "ALBUM_UNIQUE" UNIQUE ("externalId", "href")` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "artist" ADD CONSTRAINT "ARTIST_UNIQUE" UNIQUE ("externalId", "href")` | ||
) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "artist" DROP CONSTRAINT "ARTIST_UNIQUE"` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "album" DROP CONSTRAINT "ALBUM_UNIQUE"` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "track" DROP CONSTRAINT "TRACK_UNIQUE"` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "artist" ADD CONSTRAINT "UQ_3df7b480e9f4bc6eecca12a31a0" UNIQUE ("href")` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "artist" ADD CONSTRAINT "UQ_941b1071e844e94caec980a929c" UNIQUE ("externalId")` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "album" ADD CONSTRAINT "UQ_195b9a4b8052042a431847461ab" UNIQUE ("href")` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "album" ADD CONSTRAINT "UQ_d9c245cc24c616be9b5d72900f5" UNIQUE ("externalId")` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "track" ADD CONSTRAINT "UQ_10a3b0c40212c31ba55419523a4" UNIQUE ("href")` | ||
) | ||
await queryRunner.query( | ||
`ALTER TABLE "track" ADD CONSTRAINT "UQ_2315a3e4d182a2a460f2e773693" UNIQUE ("externalId")` | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { Migration1697539455661 } from './1697539455661-migration' | ||
import { FixUserProfileRelation1701713313421 } from './1701713313421-fix-user-profile-relation' | ||
import { HistoryMigration1711027664648 } from './1711027664648-history-migration' | ||
import { ChangeUniqueConstraintsForEntities1711444943012 } from './1711444943012-change-unique-constraints-for-entities' | ||
|
||
export const migrations = [ | ||
Migration1697539455661, | ||
FixUserProfileRelation1701713313421, | ||
HistoryMigration1711027664648, | ||
ChangeUniqueConstraintsForEntities1711444943012, | ||
] |
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