-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CSS-4745 Fix remove cloud failure (#1024)
* Add migration `1_3.sql` files Signed-off-by: Babak K. Shandiz <babak.k.shandiz@canonical.com> * Modify cloud credentials foreign key relationship as cascade on-delete Signed-off-by: Babak K. Shandiz <babak.k.shandiz@canonical.com> * Remove unnecessary transaction block Signed-off-by: Babak K. Shandiz <babak.k.shandiz@canonical.com> * Add test to verify migration v1.3 changes are applied Signed-off-by: Babak K. Shandiz <babak.k.shandiz@canonical.com> * Increment schema version Signed-off-by: Babak K. Shandiz <babak.k.shandiz@canonical.com> * Assert cloud credential is deleted after cascaded relationship Signed-off-by: Babak K. Shandiz <babak.k.shandiz@canonical.com> --------- Signed-off-by: Babak K. Shandiz <babak.k.shandiz@canonical.com>
- Loading branch information
Showing
5 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- 1_3.sql is a migration that alters the foreign key relationship `cloud_credentials.cloud_name -> clouds.name` to a cascade on-delete. | ||
|
||
alter table cloud_credentials | ||
drop constraint cloud_credentials_cloud_name_fkey, | ||
add constraint cloud_credentials_cloud_name_fkey | ||
foreign key (cloud_name) | ||
references clouds(name) | ||
on delete cascade; | ||
ALTER TABLE | ||
|
||
UPDATE versions SET major=1, minor=3 WHERE component='jimmdb'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- 1_3.sql is a migration that alters the foreign key relationship `cloud_credentials.cloud_name -> clouds.name` to a cascade on-delete. | ||
-- Followed official instructions under heading "Making Other Kinds Of Table Schema Changes" at: | ||
-- - https://www.sqlite.org/lang_altertable.html | ||
-- - http://web.archive.org/web/20230718062623/https://www.sqlite.org/lang_altertable.html | ||
|
||
PRAGMA schema_version; | ||
PRAGMA writable_schema=ON; | ||
UPDATE sqlite_schema SET sql=REPLACE(sql,'cloud_name TEXT NOT NULL REFERENCES clouds (name)','cloud_name TEXT NOT NULL REFERENCES clouds (name) ON DELETE CASCADE') WHERE type='table' AND name='cloud_credentials'; | ||
PRAGMA schema_version=44; | ||
PRAGMA writable_schema=OFF; | ||
PRAGMA integrity_check; | ||
|
||
UPDATE versions SET major=1, minor=3 WHERE component='jimmdb'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters