File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ import { Kysely , sql } from "kysely" ;
2+
3+ export async function up ( db : Kysely < any > ) : Promise < void > {
4+ await db . schema
5+ . alterTable ( "vot_translations" )
6+ . alterColumn ( "id" , ( col ) => col . dropDefault ( ) )
7+ . alterColumn ( "id" , ( col ) => col . setDataType ( "bigint" ) )
8+ . alterColumn ( "created_at" , ( col ) => col . setDataType ( "timestamptz" ) )
9+ . execute ( ) ;
10+
11+ await sql `DROP SEQUENCE public.vot_translations_id_seq CASCADE` . execute ( db ) ;
12+
13+ await sql `ALTER TABLE vot_translations DROP CONSTRAINT IF EXISTS vot_translations_pkey` . execute (
14+ db ,
15+ ) ;
16+ await sql `ALTER TABLE vot_translations ALTER id ADD GENERATED ALWAYS AS IDENTITY` . execute ( db ) ;
17+ await sql `SELECT setval(pg_get_serial_sequence('vot_translations', 'id'), max(id)) FROM vot_translations;` . execute (
18+ db ,
19+ ) ;
20+ }
21+
22+ export async function down ( db : Kysely < any > ) : Promise < void > {
23+ await db . schema
24+ . alterTable ( "vot_translations" )
25+ . alterColumn ( "id" , ( col ) => col . setDataType ( "serial" ) )
26+ . alterColumn ( "created_at" , ( col ) => col . setDataType ( "timestamp" ) )
27+ . execute ( ) ;
28+
29+ await sql `ALTER TABLE vot_translations ADD CONSTRAINT vot_translations_pkey PRIMARY KEY ("id");` . execute (
30+ db ,
31+ ) ;
32+ }
You can’t perform that action at this time.
0 commit comments