feat(server): add user_federation_registry table and federationRegistryUpdatedAt column
This commit is contained in:
@@ -230,6 +230,12 @@ export function runMigrations(db: Database.Database): void {
|
|||||||
{ name: 'auto_rotate_interval_days', type: 'INTEGER NOT NULL DEFAULT 90' },
|
{ name: 'auto_rotate_interval_days', type: 'INTEGER NOT NULL DEFAULT 90' },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'users',
|
||||||
|
columns: [
|
||||||
|
{ name: 'federation_registry_updated_at', type: 'INTEGER DEFAULT 0' },
|
||||||
|
]
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const table of tables) {
|
for (const table of tables) {
|
||||||
@@ -398,6 +404,23 @@ export function runMigrations(db: Database.Database): void {
|
|||||||
);
|
);
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
// ─── User federation registry ───────────────────────────────────────────────
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS user_federation_registry (
|
||||||
|
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||||
|
origin TEXT NOT NULL,
|
||||||
|
label TEXT NOT NULL DEFAULT '',
|
||||||
|
username TEXT NOT NULL DEFAULT '',
|
||||||
|
remote_user_id TEXT NOT NULL DEFAULT '',
|
||||||
|
status TEXT NOT NULL DEFAULT 'connected',
|
||||||
|
added_at INTEGER NOT NULL,
|
||||||
|
last_connected_at INTEGER,
|
||||||
|
disconnected_at INTEGER,
|
||||||
|
error_message TEXT,
|
||||||
|
PRIMARY KEY (user_id, origin)
|
||||||
|
);
|
||||||
|
`);
|
||||||
|
|
||||||
// ─── Legacy permissions: convert JSON arrays to decimal strings ───────────
|
// ─── Legacy permissions: convert JSON arrays to decimal strings ───────────
|
||||||
migrateLegacyPermissions(db);
|
migrateLegacyPermissions(db);
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ export const users = sqliteTable('users', {
|
|||||||
profileUpdatedAt: integer('profile_updated_at'),
|
profileUpdatedAt: integer('profile_updated_at'),
|
||||||
passwordChangedAt: integer('password_changed_at'),
|
passwordChangedAt: integer('password_changed_at'),
|
||||||
showActivity: integer('show_activity').notNull().default(1),
|
showActivity: integer('show_activity').notNull().default(1),
|
||||||
|
federationRegistryUpdatedAt: integer('federation_registry_updated_at').default(0),
|
||||||
createdAt: integer('created_at').notNull(),
|
createdAt: integer('created_at').notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -371,3 +372,18 @@ export const federationMutationLog = sqliteTable('federation_mutation_log', {
|
|||||||
mutatedAt: integer('mutated_at').notNull(),
|
mutatedAt: integer('mutated_at').notNull(),
|
||||||
payload: text('payload'),
|
payload: text('payload'),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const userFederationRegistry = sqliteTable('user_federation_registry', {
|
||||||
|
userId: text('user_id').notNull().references(() => users.id, { onDelete: 'cascade' }),
|
||||||
|
origin: text('origin').notNull(),
|
||||||
|
label: text('label').notNull().default(''),
|
||||||
|
username: text('username').notNull().default(''),
|
||||||
|
remoteUserId: text('remote_user_id').notNull().default(''),
|
||||||
|
status: text('status').notNull().default('connected'),
|
||||||
|
addedAt: integer('added_at').notNull(),
|
||||||
|
lastConnectedAt: integer('last_connected_at'),
|
||||||
|
disconnectedAt: integer('disconnected_at'),
|
||||||
|
errorMessage: text('error_message'),
|
||||||
|
}, (table) => ({
|
||||||
|
pk: primaryKey({ columns: [table.userId, table.origin] }),
|
||||||
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user