@easy-cms/drizzle 0.43.0 → 0.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.js +7 -2
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -38,10 +38,10 @@ interface Dialect {
|
|
|
38
38
|
readonly singleWriter?: boolean;
|
|
39
39
|
table(name: string, columns: Record<string, ColumnBuilder>, indexes: (t: Record<string, AnyColumn>) => IndexBuilder[]): AnyTable;
|
|
40
40
|
index(name: string): {
|
|
41
|
-
on(
|
|
41
|
+
on(...columns: AnyColumn[]): IndexBuilder;
|
|
42
42
|
};
|
|
43
43
|
uniqueIndex(name: string): {
|
|
44
|
-
on(
|
|
44
|
+
on(...columns: AnyColumn[]): IndexBuilder;
|
|
45
45
|
};
|
|
46
46
|
/** Auto-incrementing integer primary key. */
|
|
47
47
|
serial(name: string): ColumnBuilder;
|
package/dist/index.js
CHANGED
|
@@ -386,7 +386,10 @@ function buildTable(builder, name, kind, fields, options) {
|
|
|
386
386
|
defaultLocale: locale === localization?.defaultLocale
|
|
387
387
|
}
|
|
388
388
|
);
|
|
389
|
-
if (topLevel && kind === "root" && (field.unique || field.type === "slug" && field.uniqueWithin
|
|
389
|
+
if (topLevel && kind === "root" && (field.unique || field.type === "slug") && field.uniqueWithin !== void 0) {
|
|
390
|
+
indexes.push({ column, unique: true, within: snake(field.uniqueWithin) });
|
|
391
|
+
indexes.push({ column, unique: false });
|
|
392
|
+
} else if (topLevel && kind === "root" && (field.unique || field.type === "slug")) {
|
|
390
393
|
indexes.push({ column, unique: true });
|
|
391
394
|
} else if (field.index || field.unique || field.type === "slug" || field.type === "relationship" || field.type === "upload") {
|
|
392
395
|
indexes.push({ column, unique: false });
|
|
@@ -399,8 +402,10 @@ function buildTable(builder, name, kind, fields, options) {
|
|
|
399
402
|
const table = dialect.table(
|
|
400
403
|
name,
|
|
401
404
|
columns,
|
|
402
|
-
(t) => indexes.map(({ column, unique }) => {
|
|
405
|
+
(t) => indexes.map(({ column, unique, within }) => {
|
|
403
406
|
const col3 = t[column];
|
|
407
|
+
if (within)
|
|
408
|
+
return dialect.uniqueIndex(`${name}_${within}_${column}_unique`).on(t[within], col3);
|
|
404
409
|
return unique ? dialect.uniqueIndex(`${name}_${column}_unique`).on(col3) : dialect.index(`${name}_${column}_idx`).on(col3);
|
|
405
410
|
})
|
|
406
411
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-cms/drizzle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "Shared Drizzle ORM layer for Easy CMS database adapters",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"drizzle-orm": "0.45.3"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@easy-cms/core": "^0.
|
|
26
|
+
"@easy-cms/core": "^0.44.0"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@easy-cms/core": "^0.
|
|
29
|
+
"@easy-cms/core": "^0.44.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|