mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 06:05:24 +00:00
feat: give plugins their own tables, migrations and sync entities
This commit is contained in:
1 parent
5796186a1c
commit
c496a093ca
47 files changed
+32595
-290
No files matched your search
@@ -2251,4 +2251,33 @@ export const pluginStorage = sqliteTable(
|
||||
],
|
||||
);
|
||||
|
||||
/**
|
||||
* Which of a plugin's migrations have been applied.
|
||||
*
|
||||
* The checksum is what makes an already-applied migration immutable: editing
|
||||
* one that has run blocks that plugin rather than silently leaving two
|
||||
* databases with different shapes. Cascades with the plugin so removing its
|
||||
* data leaves no ledger behind.
|
||||
*/
|
||||
export const pluginMigrations = sqliteTable(
|
||||
"plugin_migrations",
|
||||
{
|
||||
id: integer("id").primaryKey({ autoIncrement: true }),
|
||||
pluginId: text("plugin_id")
|
||||
.notNull()
|
||||
.references(() => plugins.id, { onDelete: "cascade" }),
|
||||
migrationId: text("migration_id").notNull(),
|
||||
checksum: text("checksum").notNull(),
|
||||
appliedAt: text("applied_at")
|
||||
.notNull()
|
||||
.default(sql`CURRENT_TIMESTAMP`),
|
||||
},
|
||||
(table) => [
|
||||
uniqueIndex("idx_plugin_migrations_plugin_migration").on(
|
||||
table.pluginId,
|
||||
table.migrationId,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
// --- plugins end ---
|
||||
Reference in new issue
Block a user