feat: rebuild workspaces as the reference plugin

This commit is contained in:
LukeGus committed 2026-09-23 07:04:03 -05:00
1 parent d774df8b41
commit f217d8db89
79 files changed
+32995 -2184

No files matched your search

-30
View File
@@ -2839,36 +2839,6 @@ const migrateSchema = () => {
}
// --- fleets end ---
// --- workspaces begin ---
try {
sqlite.prepare("SELECT id FROM user_workspaces LIMIT 1").get();
} catch {
try {
sqlite.exec(`
CREATE TABLE IF NOT EXISTS user_workspaces (
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
name TEXT NOT NULL,
color TEXT,
icon TEXT,
kind TEXT NOT NULL DEFAULT 'manual',
is_default INTEGER NOT NULL DEFAULT 0,
payload TEXT NOT NULL DEFAULT '{}',
sync_id TEXT UNIQUE,
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_used_at TEXT
);
`);
} catch (createError) {
databaseLogger.warn("Failed to create user_workspaces table", {
operation: "schema_migration",
error: createError,
});
}
}
// --- workspaces end ---
// --- sync begin ---
// Stable per-row identity used to match rows across two independently-
// seeded databases (the embedded desktop backend and a connected remote
@@ -152,11 +152,6 @@ export const PERFORMANCE_INDEXES: PerformanceIndex[] = [
table: "user_open_tabs",
columns: "user_id",
},
{
name: "idx_user_workspaces_user_id",
table: "user_workspaces",
columns: "user_id",
},
{
name: "idx_homepage_items_user_id",
table: "homepage_items",
+1 -30
View File
@@ -1780,36 +1780,7 @@ export const fleetInventory = mysqlTable(
);
// --- fleets end ---
// --- workspaces begin ---
export const userWorkspaces = mysqlTable(
"user_workspaces",
{
id: int("id").autoincrement().primaryKey(),
userId: varchar("user_id", { length: 255 })
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
name: varchar("name", { length: 255 }).notNull(),
color: text("color"),
icon: text("icon"),
// "manual" | "last_session" - exactly one last_session row per user.
kind: text("kind").notNull().default("manual"),
isDefault: boolean("is_default")
.notNull()
.default(false),
// JSON-encoded WorkspacePayload: tabs, splitMode, paneTabIds, rowSizes, rowColSizes
payload: text("payload").notNull().default("{}"),
syncId: varchar("sync_id", { length: 255 }).unique(),
createdAt: varchar("created_at", { length: 255 })
.notNull()
.default(sql`(CURRENT_TIMESTAMP)`),
updatedAt: varchar("updated_at", { length: 255 })
.notNull()
.default(sql`(CURRENT_TIMESTAMP)`),
lastUsedAt: text("last_used_at"),
},
(table) => [index("idx_user_workspaces_user_id").on(table.userId)],
);
// --- workspaces end ---
// --- sync begin ---
// Records a delete for a synced entity type so the other side of a sync
+1 -30
View File
@@ -1781,36 +1781,7 @@ export const fleetInventory = pgTable(
);
// --- fleets end ---
// --- workspaces begin ---
export const userWorkspaces = pgTable(
"user_workspaces",
{
id: serial("id").primaryKey(),
userId: varchar("user_id", { length: 255 })
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
name: varchar("name", { length: 255 }).notNull(),
color: text("color"),
icon: text("icon"),
// "manual" | "last_session" - exactly one last_session row per user.
kind: text("kind").notNull().default("manual"),
isDefault: boolean("is_default")
.notNull()
.default(false),
// JSON-encoded WorkspacePayload: tabs, splitMode, paneTabIds, rowSizes, rowColSizes
payload: text("payload").notNull().default("{}"),
syncId: varchar("sync_id", { length: 255 }).unique(),
createdAt: varchar("created_at", { length: 255 })
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
updatedAt: varchar("updated_at", { length: 255 })
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
lastUsedAt: text("last_used_at"),
},
(table) => [index("idx_user_workspaces_user_id").on(table.userId)],
);
// --- workspaces end ---
// --- sync begin ---
// Records a delete for a synced entity type so the other side of a sync
+1 -30
View File
@@ -1779,36 +1779,7 @@ export const fleetInventory = sqliteTable(
);
// --- fleets end ---
// --- workspaces begin ---
export const userWorkspaces = sqliteTable(
"user_workspaces",
{
id: integer("id").primaryKey({ autoIncrement: true }),
userId: text("user_id")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
name: text("name").notNull(),
color: text("color"),
icon: text("icon"),
// "manual" | "last_session" - exactly one last_session row per user.
kind: text("kind").notNull().default("manual"),
isDefault: integer("is_default", { mode: "boolean" })
.notNull()
.default(false),
// JSON-encoded WorkspacePayload: tabs, splitMode, paneTabIds, rowSizes, rowColSizes
payload: text("payload").notNull().default("{}"),
syncId: text("sync_id").unique(),
createdAt: text("created_at")
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
updatedAt: text("updated_at")
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
lastUsedAt: text("last_used_at"),
},
(table) => [index("idx_user_workspaces_user_id").on(table.userId)],
);
// --- workspaces end ---
// --- sync begin ---
// Records a delete for a synced entity type so the other side of a sync