Changed SQLez migrations to be executed eagerly

Added fix for terminal working directory's sometimes getting lost
co-authored-by: Kay <kay@zed.dev>
This commit is contained in:
Mikayla Maki 2023-01-30 14:38:48 -08:00
parent 65641b1d3e
commit e682e2dd72
5 changed files with 130 additions and 3 deletions

View file

@ -14,6 +14,26 @@ define_connection! {
FOREIGN KEY(workspace_id) REFERENCES workspaces(workspace_id)
ON DELETE CASCADE
) STRICT;
),
// Remove the unique constraint on the item_id table
// SQLite doesn't have a way of doing this automatically, so
// we have to do this silly copying.
sql!(
CREATE TABLE terminals2 (
workspace_id INTEGER,
item_id INTEGER,
working_directory BLOB,
PRIMARY KEY(workspace_id, item_id),
FOREIGN KEY(workspace_id) REFERENCES workspaces(workspace_id)
ON DELETE CASCADE
) STRICT;
INSERT INTO terminals2 (workspace_id, item_id, working_directory)
SELECT workspace_id, item_id, working_directory FROM terminals;
DROP TABLE terminals;
ALTER TABLE terminals2 RENAME TO terminals;
)];
}