-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch takedown ids back to ints on pds distribution (#1694)
* switch takedown ids back to ints, consistent with live pds * tidy/fix migration * update migration for sqlite
- Loading branch information
Showing
10 changed files
with
57 additions
and
13 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
packages/pds/src/db/migrations/20230929T213219699Z-takedown-id-as-int.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,47 @@ | ||
import { Kysely, sql } from 'kysely' | ||
import { Dialect } from '..' | ||
|
||
export async function up(db: Kysely<unknown>, dialect: Dialect): Promise<void> { | ||
if (dialect === 'pg') { | ||
await sql` | ||
alter table "repo_root" alter column "takedownId" type integer using "takedownId"::integer; | ||
alter table "repo_blob" alter column "takedownId" type integer using "takedownId"::integer; | ||
alter table "record" alter column "takedownId" type integer using "takedownId"::integer; | ||
`.execute(db) | ||
} else { | ||
await sql`alter table "repo_root" drop column "takedownId"`.execute(db) | ||
await sql`alter table "repo_root" add column "takedownId" integer`.execute( | ||
db, | ||
) | ||
await sql`alter table "repo_blob" drop column "takedownId"`.execute(db) | ||
await sql`alter table "repo_blob" add column "takedownId" integer`.execute( | ||
db, | ||
) | ||
await sql`alter table "record" drop column "takedownId"`.execute(db) | ||
await sql`alter table "record" add column "takedownId" integer`.execute(db) | ||
} | ||
} | ||
|
||
export async function down( | ||
db: Kysely<unknown>, | ||
dialect: Dialect, | ||
): Promise<void> { | ||
if (dialect === 'pg') { | ||
await sql` | ||
alter table "repo_root" alter column "takedownId" type varchar; | ||
alter table "repo_blob" alter column "takedownId" type varchar; | ||
alter table "record" alter column "takedownId" type varchar; | ||
`.execute(db) | ||
} else { | ||
await sql`alter table "repo_root" drop column "takedownId"`.execute(db) | ||
await sql`alter table "repo_root" add column "takedownId" varchar`.execute( | ||
db, | ||
) | ||
await sql`alter table "repo_blob" drop column "takedownId"`.execute(db) | ||
await sql`alter table "repo_blob" add column "takedownId" varchar`.execute( | ||
db, | ||
) | ||
await sql`alter table "record" drop column "takedownId"`.execute(db) | ||
await sql`alter table "record" add column "takedownId" varchar`.execute(db) | ||
} | ||
} |
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
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
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