fixed crdt

This commit is contained in:
2025-08-28 12:16:22 +02:00
parent 0c304d7900
commit 91db0475cd
11 changed files with 703 additions and 305 deletions

View File

@ -1,6 +1,6 @@
import { blob, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
export const haexCrdtMessages = sqliteTable('haex_crdt_messages', {
export const haexCrdtLogs = sqliteTable('haex_crdt_logs', {
hlc_timestamp: text().primaryKey(),
table_name: text(),
row_pks: text({ mode: 'json' }),
@ -9,8 +9,8 @@ export const haexCrdtMessages = sqliteTable('haex_crdt_messages', {
new_value: text({ mode: 'json' }),
old_value: text({ mode: 'json' }),
})
export type InsertHaexCrdtMessages = typeof haexCrdtMessages.$inferInsert
export type SelectHaexCrdtMessages = typeof haexCrdtMessages.$inferSelect
export type InsertHaexCrdtLogs = typeof haexCrdtLogs.$inferInsert
export type SelectHaexCrdtLogs = typeof haexCrdtLogs.$inferSelect
export const haexCrdtSnapshots = sqliteTable('haex_crdt_snapshots', {
snapshot_id: text().primaryKey(),
@ -21,7 +21,6 @@ export const haexCrdtSnapshots = sqliteTable('haex_crdt_snapshots', {
})
export const haexCrdtSettings = sqliteTable('haex_crdt_settings', {
id: text().primaryKey(),
type: text({ enum: ['hlc_timestamp'] }).unique(),
type: text().primaryKey(),
value: text(),
})

View File

@ -13,6 +13,7 @@ export const haexSettings = sqliteTable('haex_settings', {
key: text(),
type: text(),
value: text(),
haex_tombstone: integer({ mode: 'boolean' }),
})
export type InsertHaexSettings = typeof haexSettings.$inferInsert
export type SelectHaexSettings = typeof haexSettings.$inferSelect
@ -25,6 +26,7 @@ export const haexExtensions = sqliteTable('haex_extensions', {
name: text(),
url: text(),
version: text(),
haex_tombstone: integer({ mode: 'boolean' }),
})
export type InsertHaexExtensions = typeof haexExtensions.$inferInsert
export type SelectHaexExtensions = typeof haexExtensions.$inferSelect
@ -43,6 +45,7 @@ export const haexExtensionsPermissions = sqliteTable(
updateAt: integer('updated_at', { mode: 'timestamp' }).$onUpdate(
() => new Date(),
),
haex_tombstone: integer({ mode: 'boolean' }),
},
(table) => [
unique().on(table.extensionId, table.resource, table.operation, table.path),
@ -66,6 +69,7 @@ export const haexNotifications = sqliteTable('haex_notifications', {
type: text({
enum: ['error', 'success', 'warning', 'info', 'log'],
}).notNull(),
haex_tombstone: integer({ mode: 'boolean' }),
})
export type InsertHaexNotifications = typeof haexNotifications.$inferInsert
export type SelectHaexNotifications = typeof haexNotifications.$inferSelect
@ -85,6 +89,7 @@ export const haexPasswordsItemDetails = sqliteTable(
updateAt: integer('updated_at', { mode: 'timestamp' }).$onUpdate(
() => new Date(),
),
haex_tombstone: integer({ mode: 'boolean' }),
},
)
export type InsertHaexPasswordsItemDetails =
@ -104,6 +109,7 @@ export const haexPasswordsItemKeyValues = sqliteTable(
updateAt: integer('updated_at', { mode: 'timestamp' }).$onUpdate(
() => new Date(),
),
haex_tombstone: integer({ mode: 'boolean' }),
},
)
export type InserthaexPasswordsItemKeyValues =
@ -123,6 +129,7 @@ export const haexPasswordsItemHistory = sqliteTable(
oldValue: text('old_value'),
newValue: text('new_value'),
createdAt: text('created_at').default(sql`(CURRENT_TIMESTAMP)`),
haex_tombstone: integer({ mode: 'boolean' }),
},
)
export type InserthaexPasswordsItemHistory =
@ -144,6 +151,7 @@ export const haexPasswordsGroups = sqliteTable('haex_passwords_groups', {
updateAt: integer('updated_at', { mode: 'timestamp' }).$onUpdate(
() => new Date(),
),
haex_tombstone: integer({ mode: 'boolean' }),
})
export type InsertHaexPasswordsGroups = typeof haexPasswordsGroups.$inferInsert
export type SelectHaexPasswordsGroups = typeof haexPasswordsGroups.$inferSelect
@ -157,6 +165,7 @@ export const haexPasswordsGroupItems = sqliteTable(
itemId: text('item_id').references(
(): AnySQLiteColumn => haexPasswordsItemDetails.id,
),
haex_tombstone: integer({ mode: 'boolean' }),
},
(table) => [primaryKey({ columns: [table.itemId, table.groupId] })],
)