Lists: owner-only database browser/editor for all tables (meta.edit_log audit)
All checks were successful
Deploy production / deploy (push) Successful in 2m33s
All checks were successful
Deploy production / deploy (push) Successful in 2m33s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import {
|
||||
bigint,
|
||||
boolean,
|
||||
check,
|
||||
index,
|
||||
@@ -88,5 +89,29 @@ export const metaColumns = metaSchema.table(
|
||||
]
|
||||
);
|
||||
|
||||
/** Audit trail of every write made through the database browser (/lists/db). */
|
||||
export const metaEditLog = metaSchema.table(
|
||||
'edit_log',
|
||||
{
|
||||
id: bigint('id', { mode: 'number' }).primaryKey().generatedAlwaysAsIdentity(),
|
||||
at: ts('at').notNull().defaultNow(),
|
||||
userId: text('user_id'),
|
||||
userEmail: text('user_email'),
|
||||
schemaName: text('schema_name').notNull(),
|
||||
tableName: text('table_name').notNull(),
|
||||
action: text('action').notNull(),
|
||||
pk: jsonb('pk'),
|
||||
before: jsonb('before'),
|
||||
after: jsonb('after')
|
||||
},
|
||||
(t) => [
|
||||
index('edit_log_table_at_index').on(t.schemaName, t.tableName, t.at),
|
||||
check(
|
||||
'edit_log_action_check',
|
||||
sql`action IN ('insert','update','delete','import','add_column')`
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
export type MetaTable = typeof metaTables.$inferSelect;
|
||||
export type MetaColumn = typeof metaColumns.$inferSelect;
|
||||
|
||||
Reference in New Issue
Block a user