11import { sql } from 'drizzle-orm' ;
2- import { cockroachTable } from 'drizzle-orm/cockroach-core' ;
32import {
43 AnyMsSqlColumn ,
54 check ,
@@ -1688,9 +1687,9 @@ test('fk multistep #3', async () => {
16881687 const { sqlStatements : st1 , next : n1 } = await diff ( { } , schema1 , [ ] ) ;
16891688 const { sqlStatements : pst1 } = await push ( { db, to : schema1 } ) ;
16901689 const expectedSt1 = [
1691- 'CREATE TABLE [foo] (\n\t[id] int PRIMARY KEY\n);\n' ,
1692- 'CREATE TABLE [bar] (\n\t[id] int PRIMARY KEY ,\n\t[fooId] int\n);\n' ,
1693- 'ALTER TABLE [bar] ADD CONSTRAINT [bar_fooId_foo_id_fkey ] FOREIGN KEY ([fooId]) REFERENCES [foo]([id]);' ,
1690+ 'CREATE TABLE [foo] (\n\t[id] int,\n\tCONSTRAINT [foo_pkey] PRIMARY KEY([id]) \n);\n' ,
1691+ 'CREATE TABLE [bar] (\n\t[id] int,\n\t[fooId] int,\n\tCONSTRAINT [bar_pkey] PRIMARY KEY([id]) \n);\n' ,
1692+ 'ALTER TABLE [bar] ADD CONSTRAINT [bar_fooId_foo_id_fk ] FOREIGN KEY ([fooId]) REFERENCES [foo]([id]);' ,
16941693 ] ;
16951694 expect ( st1 ) . toStrictEqual ( expectedSt1 ) ;
16961695 expect ( pst1 ) . toStrictEqual ( expectedSt1 ) ;
@@ -1704,7 +1703,7 @@ test('fk multistep #3', async () => {
17041703 const { sqlStatements : st2 } = await diff ( n1 , schema2 , [ ] ) ;
17051704 const { sqlStatements : pst2 } = await push ( { db, to : schema2 } ) ;
17061705 const expectedSt2 = [
1707- 'ALTER TABLE [bar] DROP CONSTRAINT [bar_fooId_foo_id_fkey ];' ,
1706+ 'ALTER TABLE [bar] DROP CONSTRAINT [bar_fooId_foo_id_fk ];' ,
17081707 'DROP TABLE [foo];' ,
17091708 ] ;
17101709 expect ( st2 ) . toStrictEqual ( expectedSt2 ) ;
@@ -2441,7 +2440,7 @@ test('drop column with pk and add pk to another column #1', async () => {
24412440 expect ( pst1 ) . toStrictEqual ( expectedSt1 ) ;
24422441
24432442 const schema2 = {
2444- authors : cockroachTable ( 'authors' , {
2443+ authors : mssqlTable ( 'authors' , {
24452444 publicationId : varchar ( 'publication_id' , { length : 64 } ) ,
24462445 authorID : varchar ( 'author_id' , { length : 10 } ) ,
24472446 orcidId : varchar ( 'orcid_id' , { length : 64 } ) ,
@@ -2454,9 +2453,9 @@ test('drop column with pk and add pk to another column #1', async () => {
24542453 const { sqlStatements : pst2 } = await push ( { db, to : schema2 } ) ;
24552454
24562455 const expectedSt2 : string [ ] = [
2457- 'ALTER TABLE [authors] ADD COLUMN [orcid_id] varchar(64);' ,
24582456 'ALTER TABLE [authors] DROP CONSTRAINT [authors_pkey];' ,
2459- 'ALTER TABLE [authors] ADD PRIMARY KEY ([publication_id],[author_id],[orcid_id]);' ,
2457+ 'ALTER TABLE [authors] ADD [orcid_id] varchar(64);' ,
2458+ 'ALTER TABLE [authors] ADD CONSTRAINT [authors_pkey] PRIMARY KEY ([publication_id],[author_id],[orcid_id]);' ,
24602459 ] ;
24612460
24622461 expect ( st2 ) . toStrictEqual ( expectedSt2 ) ;
0 commit comments