fix: federated spaces in folders + DnD double indicator line

Remove FK constraint on space_folder_members.space_id so federated
space IDs (which don't exist in the local spaces table) can be added
to folders without silently failing. Add migration to recreate the
table for existing databases and explicit cleanup on space deletion.

Offset drop indicator lines by 3px into the mb-1.5 gap so adjacent
items share one visual position instead of showing two lines.

Extract TransferOwnershipModal (~165 lines) to its own file.
This commit is contained in:
Jannis Braun
2026-03-12 04:18:01 +01:00
parent 585988802d
commit b776e0e5b0
6 changed files with 205 additions and 177 deletions
+22
View File
@@ -251,6 +251,28 @@ export function runMigrations(db: Database.Database): void {
}
}
// ─── Remove FK constraint from space_folder_members (federated spaces) ────
{
const tableInfo = db.prepare(
"SELECT sql FROM sqlite_master WHERE type='table' AND name='space_folder_members'"
).get() as { sql: string } | undefined;
if (tableInfo && tableInfo.sql.includes('REFERENCES spaces')) {
console.log('Migrating: Removing FK constraint from space_folder_members...');
db.exec(`
CREATE TABLE space_folder_members_new (
folder_id TEXT NOT NULL REFERENCES space_folders(id) ON DELETE CASCADE,
space_id TEXT NOT NULL,
position INTEGER DEFAULT 0,
PRIMARY KEY (folder_id, space_id)
);
INSERT INTO space_folder_members_new SELECT folder_id, space_id, position FROM space_folder_members;
DROP TABLE space_folder_members;
ALTER TABLE space_folder_members_new RENAME TO space_folder_members;
`);
}
}
console.log('Migrations complete.');
}