add migration to cd up to current project root

This commit is contained in:
Mitchell Rosen 2024-05-14 16:46:27 -04:00
parent 4f4ed49831
commit ecd323faa7
4 changed files with 15 additions and 3 deletions

View File

@ -251,6 +251,7 @@ module U.Codebase.Sqlite.Queries
addMostRecentNamespaceTable,
addSquashResultTable,
addSquashResultTableIfNotExists,
cdToProjectRoot,
-- ** schema version
currentSchemaVersion,
@ -411,7 +412,7 @@ type TextPathSegments = [Text]
-- * main squeeze
currentSchemaVersion :: SchemaVersion
currentSchemaVersion = 15
currentSchemaVersion = 16
createSchema :: Transaction ()
createSchema = do
@ -475,6 +476,10 @@ addSquashResultTableIfNotExists :: Transaction ()
addSquashResultTableIfNotExists =
executeStatements $(embedProjectStringFile "sql/010-ensure-squash-cache-table.sql")
cdToProjectRoot :: Transaction ()
cdToProjectRoot =
executeStatements $(embedProjectStringFile "sql/011-cd-to-project-root.sql")
schemaVersion :: Transaction SchemaVersion
schemaVersion =
queryOneCol

View File

@ -0,0 +1,5 @@
-- As part of deprecating cd, we want users who have cd'd deeper than their project root to be parked at the root instead.
UPDATE "most_recent_namespace"
SET "namespace" = json_array("namespace" -> 0, "namespace" -> 1, "namespace" -> 2, "namespace" -> 3)
WHERE "namespace" ->> 0 = '__projects'
AND json_array_length("namespace") > 4;

View File

@ -1,6 +1,6 @@
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.35.2.
-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack
@ -20,6 +20,7 @@ extra-source-files:
sql/008-add-most-recent-namespace-table.sql
sql/009-add-squash-cache-table.sql
sql/010-ensure-squash-cache-table.sql
sql/011-cd-to-project-root.sql
sql/create.sql
source-repository head

View File

@ -80,7 +80,8 @@ migrations getDeclType termBuffer declBuffer rootCodebasePath =
(12, migrateSchema11To12),
sqlMigration 13 Q.addMostRecentNamespaceTable,
sqlMigration 14 Q.addSquashResultTable,
sqlMigration 15 Q.addSquashResultTableIfNotExists
sqlMigration 15 Q.addSquashResultTableIfNotExists,
sqlMigration 16 Q.cdToProjectRoot
]
where
sqlMigration :: SchemaVersion -> Sqlite.Transaction () -> (SchemaVersion, Sqlite.Transaction ())