Skip to content

Commit 8ac5f75

Browse files
committed
feat(indices): update primary and unique indices for prisma 2.29
1 parent b32bcfc commit 8ac5f75

4 files changed

Lines changed: 281 additions & 219 deletions

File tree

__tests__/table.test.ts

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ describe('Tables', () => {
2020
name String [not null]
2121
age Int
2222
}`;
23-
const enums = generateTables(dmmf.datamodel.models);
23+
const tables = generateTables(dmmf.datamodel.models);
2424

25-
expect(enums.length).toEqual(1);
26-
expect(enums[0]).toMatch(expected);
25+
expect(tables.length).toEqual(1);
26+
expect(tables[0]).toMatch(expected);
2727
});
2828

2929
test('generate a table with empty string default', async () => {
@@ -34,10 +34,10 @@ describe('Tables', () => {
3434
title String [not null, default: '']
3535
color String [not null, default: 'blue']
3636
}`;
37-
const enums = generateTables(dmmf.datamodel.models);
37+
const tables = generateTables(dmmf.datamodel.models);
3838

39-
expect(enums.length).toEqual(1);
40-
expect(enums[0]).toMatch(expected);
39+
expect(tables.length).toEqual(1);
40+
expect(tables[0]).toMatch(expected);
4141
});
4242

4343
test('generate a table with single composite unique index', async () => {
@@ -47,17 +47,13 @@ describe('Tables', () => {
4747

4848
const expected = `Table A {
4949
id Int [pk, increment]
50-
b String [not null]
51-
52-
indexes {
53-
(b) [unique]
54-
}
50+
b String [unique, not null]
5551
}`;
5652

57-
const enums = generateTables(dmmf.datamodel.models);
53+
const tables = generateTables(dmmf.datamodel.models);
5854

59-
expect(enums.length).toEqual(1);
60-
expect(enums[0]).toMatch(expected);
55+
expect(tables.length).toEqual(1);
56+
expect(tables[0]).toMatch(expected);
6157
});
6258

6359
test('generate a table with three fields as composite unique index', async () => {
@@ -76,10 +72,10 @@ describe('Tables', () => {
7672
}
7773
}`;
7874

79-
const enums = generateTables(dmmf.datamodel.models);
75+
const tables = generateTables(dmmf.datamodel.models);
8076

81-
expect(enums.length).toEqual(1);
82-
expect(enums[0]).toMatch(expected);
77+
expect(tables.length).toEqual(1);
78+
expect(tables[0]).toMatch(expected);
8379
});
8480

8581
test('generate a table with one composite unique index', async () => {
@@ -95,10 +91,10 @@ describe('Tables', () => {
9591
}
9692
}`;
9793

98-
const enums = generateTables(dmmf.datamodel.models);
94+
const tables = generateTables(dmmf.datamodel.models);
9995

100-
expect(enums.length).toEqual(1);
101-
expect(enums[0]).toMatch(expected);
96+
expect(tables.length).toEqual(1);
97+
expect(tables[0]).toMatch(expected);
10298
});
10399

104100
test('generate a table with two composite unique index', async () => {
@@ -117,10 +113,10 @@ describe('Tables', () => {
117113
}
118114
}`;
119115

120-
const enums = generateTables(dmmf.datamodel.models);
116+
const tables = generateTables(dmmf.datamodel.models);
121117

122-
expect(enums.length).toEqual(1);
123-
expect(enums[0]).toMatch(expected);
118+
expect(tables.length).toEqual(1);
119+
expect(tables[0]).toMatch(expected);
124120
});
125121

126122
test('generate a table with block id', async () => {
@@ -137,10 +133,10 @@ describe('Tables', () => {
137133
}
138134
}`;
139135

140-
const enums = generateTables(dmmf.datamodel.models);
136+
const tables = generateTables(dmmf.datamodel.models);
141137

142-
expect(enums.length).toEqual(1);
143-
expect(enums[0]).toMatch(expected);
138+
expect(tables.length).toEqual(1);
139+
expect(tables[0]).toMatch(expected);
144140
});
145141
test('generate a table with block id and composite unique index', async () => {
146142
const dmmf = await generateDMMF(
@@ -160,9 +156,9 @@ describe('Tables', () => {
160156
}
161157
}`;
162158

163-
const enums = generateTables(dmmf.datamodel.models);
159+
const tables = generateTables(dmmf.datamodel.models);
164160

165-
expect(enums.length).toEqual(1);
166-
expect(enums[0]).toMatch(expected);
161+
expect(tables.length).toEqual(1);
162+
expect(tables[0]).toMatch(expected);
167163
});
168164
});

0 commit comments

Comments
 (0)