@proteinjs/db 1.28.0 → 1.29.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteinjs/db",
3
- "version": "1.28.0",
3
+ "version": "1.29.0",
4
4
  "main": "./dist/generated/index.js",
5
5
  "types": "./dist/generated/index.d.ts",
6
6
  "exports": {
@@ -45,8 +45,8 @@
45
45
  "@proteinjs/logger": "^1.0.21",
46
46
  "@proteinjs/reflection": "^1.1.12",
47
47
  "@proteinjs/serializer": "^1.1.10",
48
- "@proteinjs/server-api": "^3.0.10",
49
- "@proteinjs/service": "^1.5.0",
48
+ "@proteinjs/server-api": "^3.0.11",
49
+ "@proteinjs/service": "^1.5.1",
50
50
  "@proteinjs/user-auth": "^1.3.0",
51
51
  "@proteinjs/util": "^1.6.1",
52
52
  "moment": "2.29.4",
@@ -65,5 +65,6 @@
65
65
  "jest": "29.7.0",
66
66
  "ts-jest": "29.1.1",
67
67
  "typescript": "5.2.2"
68
- }
68
+ },
69
+ "gitHead": "84d29cc38018380203c374ee1a2c35b943704ccd"
69
70
  }
package/src/Table.ts CHANGED
@@ -79,7 +79,12 @@ export abstract class Table<T extends Record> implements Loadable, CustomSeriali
79
79
  public __serializerId = TableSerializerId;
80
80
  abstract name: string;
81
81
  abstract columns: Columns<T>;
82
- public indexes: { columns: (keyof T)[]; name?: string }[] = [];
82
+ /**
83
+ * `unique: true` creates a UNIQUE index (composite uniqueness lives here; single-column
84
+ * uniqueness can also use `ColumnOptions.unique`). Name unique indexes with a `_unique`
85
+ * suffix — schema metadata classifies unique indexes by that suffix.
86
+ */
87
+ public indexes: { columns: (keyof T)[]; name?: string; unique?: boolean }[] = [];
83
88
  /** When records are deleted, delete records having references pointing to deleted records */
84
89
  public cascadeDeleteReferences: () => { table: string; referenceColumn: string }[] = () => [];
85
90
  /**
@@ -246,7 +246,7 @@ export class TableManager {
246
246
  const serializedColumns = JSON.stringify(columns);
247
247
  currentIndexMap[serializedColumns] = true;
248
248
  if (!existingIndexMap[serializedColumns]) {
249
- indexesToCreate.push({ name: index.name, columns });
249
+ indexesToCreate.push({ name: index.name, columns, unique: index.unique });
250
250
  }
251
251
  }
252
252
  }