Skip to content

Commit be26309

Browse files
committed
Merge commit '780a1da2523acca0741fa5d540621f8b7e3386a9' into alternation-engine
2 parents 43c5f28 + 780a1da commit be26309

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

drizzle-kit/tests/cockroach/constraints.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,8 +1638,8 @@ test('fk multistep #4', async ({ dbc: db }) => {
16381638
const { sqlStatements: st1, next: n1 } = await diff({}, schema1, []);
16391639
const { sqlStatements: pst1 } = await push({ db, to: schema1 });
16401640
const expectedSt1 = [
1641-
'CREATE TABLE "foo" (\n\t"id" integer PRIMARY KEY\n);\n',
1642-
'CREATE TABLE "bar" (\n\t"id" integer PRIMARY KEY,\n\t"fooId" integer\n);\n',
1641+
'CREATE TABLE "foo" (\n\t"id" int4 PRIMARY KEY\n);\n',
1642+
'CREATE TABLE "bar" (\n\t"id" int4 PRIMARY KEY,\n\t"fooId" int4\n);\n',
16431643
'ALTER TABLE "bar" ADD CONSTRAINT "bar_fooId_foo_id_fkey" FOREIGN KEY ("fooId") REFERENCES "foo"("id");',
16441644
];
16451645
expect(st1).toStrictEqual(expectedSt1);
@@ -1897,7 +1897,7 @@ test('drop column with pk and add pk to another column #1', async ({ dbc: db })
18971897
const expectedSt2: string[] = [
18981898
'ALTER TABLE "authors" ADD COLUMN "orcid_id" varchar(64);',
18991899
'ALTER TABLE "authors" DROP CONSTRAINT "authors_pkey";',
1900-
'ALTER TABLE "authors" ADD PRIMARY KEY ("publication_id","author_id","orcid_id");',
1900+
'ALTER TABLE "authors" ADD CONSTRAINT "authors_pkey" PRIMARY KEY("publication_id","author_id","orcid_id");',
19011901
];
19021902

19031903
expect(st2).toStrictEqual(expectedSt2);

drizzle-kit/tests/cockroach/tables.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,8 @@ test('drop tables with fk constraint', async ({ dbc: db }) => {
773773
const { sqlStatements: st1, next: n1 } = await diff({}, schema1, []);
774774
const { sqlStatements: pst1 } = await push({ db, to: schema1 });
775775
const expectedSt1 = [
776-
'CREATE TABLE "table1" (\n\t"column1" integer PRIMARY KEY\n);\n',
777-
'CREATE TABLE "table2" (\n\t"column1" integer PRIMARY KEY,\n\t"column2" integer\n);\n',
776+
'CREATE TABLE "table1" (\n\t"column1" int4 PRIMARY KEY\n);\n',
777+
'CREATE TABLE "table2" (\n\t"column1" int4 PRIMARY KEY,\n\t"column2" int4\n);\n',
778778
'ALTER TABLE "table2" ADD CONSTRAINT "table2_column2_table1_column1_fkey" FOREIGN KEY ("column2") REFERENCES "table1"("column1");',
779779
];
780780
expect(st1).toStrictEqual(expectedSt1);

drizzle-kit/tests/mssql/constraints.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { sql } from 'drizzle-orm';
2-
import { cockroachTable } from 'drizzle-orm/cockroach-core';
32
import {
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);

drizzle-kit/tests/mssql/tables.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,9 @@ test('drop tables with fk constraint', async () => {
622622
const { sqlStatements: st1, next: n1 } = await diff({}, schema1, []);
623623
const { sqlStatements: pst1 } = await push({ db, to: schema1 });
624624
const expectedSt1 = [
625-
'CREATE TABLE [table1] (\n\t[column1] integer PRIMARY KEY\n);\n',
626-
'CREATE TABLE [table2] (\n\t[column1] integer PRIMARY KEY,\n\t[column2] integer\n);\n',
627-
'ALTER TABLE [table2] ADD CONSTRAINT [table2_column2_table1_column1_fkey] FOREIGN KEY ([column2]) REFERENCES [table1]([column1]);',
625+
'CREATE TABLE [table1] (\n\t[column1] int,\n\tCONSTRAINT [table1_pkey] PRIMARY KEY([column1])\n);\n',
626+
'CREATE TABLE [table2] (\n\t[column1] int,\n\t[column2] int,\n\tCONSTRAINT [table2_pkey] PRIMARY KEY([column1])\n);\n',
627+
'ALTER TABLE [table2] ADD CONSTRAINT [table2_column2_table1_column1_fk] FOREIGN KEY ([column2]) REFERENCES [table1]([column1]);',
628628
];
629629
expect(st1).toStrictEqual(expectedSt1);
630630
expect(pst1).toStrictEqual(expectedSt1);

0 commit comments

Comments
 (0)