fix(db): generator captures inline UNIQUE constraints

SqliteSchemaHelper.getIndexes() drops every unnamed sqlite_autoindex_
entry before entity-generator ever sees it, so a table-level
UNIQUE(...) constraint with no separate named CREATE UNIQUE INDEX
(settings' UNIQUE(user_id, key) among ~40 others) never reached the
generated entity's uniques: metadata. Adds a general
RULE9_addImplicitUniqueConstraints (skips a column set identical to
the table's own primary key — AppSettings.key/Addons.id noise) fed by
a PRAGMA index_list/index_info scan, and regenerates every entity.
This commit is contained in:
jubnl
2026-09-22 14:13:09 +02:00
parent 6db91c8bf3
commit 310a3b0ad3
65 changed files with 276 additions and 4 deletions
@@ -14,6 +14,7 @@ export class NotificationChannelPreferences {
export const NotificationChannelPreferencesSchema = defineEntity({
class: NotificationChannelPreferences,
repository: () => NotificationChannelPreferencesRepository,
uniques: [{ properties: ['user_id', 'event_type', 'channel'] }],
properties: {
user: () => p.manyToOne(Users).primary().ref().deleteRule('cascade').hidden().index('idx_ncp_user'),
user_id: p.integer().persist(false).index('idx_ncp_user'),