-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: namespaces down migrations (#1396)
- Loading branch information
1 parent
f80825b
commit 419d919
Showing
36 changed files
with
699 additions
and
276 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
/* TODO */ | ||
DROP TABLE IF EXISTS namespaces CASCADE; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
70 changes: 70 additions & 0 deletions
70
config/migrations/cockroachdb/4_namespaces_relationships.down.sql
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,70 @@ | ||
-- Flags | ||
---------------- | ||
|
||
-- Drop foreign key constraint on namespace_key column | ||
ALTER TABLE flags DROP CONSTRAINT IF EXISTS flags_namespace_key_fkey CASCADE; | ||
|
||
-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns | ||
ALTER TABLE flags ALTER PRIMARY KEY USING COLUMNS (key); | ||
DROP INDEX IF EXISTS flags_namespace_key_key_key CASCADE; | ||
|
||
-- Drop column namespace_key | ||
ALTER TABLE flags DROP COLUMN IF EXISTS namespace_key; | ||
|
||
-- Variants | ||
---------------- | ||
|
||
-- Drop foreign key constraints on namespace_key and flag_key columns | ||
ALTER TABLE variants DROP CONSTRAINT IF EXISTS variants_namespace_flag_key_fkey CASCADE; | ||
ALTER TABLE variants DROP CONSTRAINT IF EXISTS variants_namespace_key_fkey CASCADE; | ||
|
||
-- Add foreign key constraint on flag_key column referencing key column of flags table | ||
ALTER TABLE variants ADD FOREIGN KEY (flag_key) REFERENCES flags(key) ON DELETE CASCADE; | ||
|
||
-- Drop unique constraint created by previous migration and add a new unique constraint on flag_key and key columns | ||
ALTER TABLE variants ADD CONSTRAINT variants_flag_key UNIQUE (flag_key, key); | ||
|
||
-- Drop column namespace_key | ||
ALTER TABLE variants DROP COLUMN IF EXISTS namespace_key; | ||
|
||
-- Segments | ||
---------------- | ||
|
||
-- Drop foreign key constraint on namespace_key column | ||
ALTER TABLE segments DROP CONSTRAINT IF EXISTS segments_namespace_key_fkey CASCADE; | ||
|
||
-- Drop primary key constraint and add a new primary key constraint on key column | ||
ALTER TABLE segments ALTER PRIMARY KEY USING COLUMNS (key); | ||
DROP INDEX IF EXISTS segments_namespace_key_key_key CASCADE; | ||
|
||
-- Drop column namespace_key | ||
ALTER TABLE segments DROP COLUMN IF EXISTS namespace_key; | ||
|
||
-- Constraints | ||
---------------- | ||
|
||
-- Drop foreign key constraints on namespace_key and segment_key columns | ||
ALTER TABLE constraints DROP CONSTRAINT IF EXISTS constraints_namespace_key_fkey CASCADE; | ||
|
||
-- Add foreign key constraint on segment_key column referencing key column of segments table | ||
ALTER TABLE constraints ADD FOREIGN KEY (segment_key) REFERENCES segments(key) ON DELETE CASCADE; | ||
|
||
-- Drop column namespace_key | ||
ALTER TABLE constraints DROP COLUMN IF EXISTS namespace_key; | ||
|
||
-- Rules | ||
---------------- | ||
|
||
-- Drop foreign key constraints on namespace_key, flag_key and segment_key columns | ||
ALTER TABLE rules DROP CONSTRAINT IF EXISTS rules_namespace_key_fkey CASCADE; | ||
ALTER TABLE rules DROP CONSTRAINT IF EXISTS rules_namespace_key_flag_key_fkey CASCADE; | ||
ALTER TABLE rules DROP CONSTRAINT IF EXISTS rules_namespace_key_segment_key_fkey CASCADE; | ||
|
||
-- Add foreign key constraint on flag_key column referencing key column of flags table | ||
ALTER TABLE rules ADD FOREIGN KEY (flag_key) REFERENCES flags(key) ON DELETE CASCADE; | ||
|
||
-- Add foreign key constraint on segment_key column referencing key column of segments table | ||
ALTER TABLE rules ADD FOREIGN KEY (segment_key) REFERENCES segments(key) ON DELETE CASCADE; | ||
|
||
-- Drop column namespace_key | ||
ALTER TABLE rules DROP COLUMN IF EXISTS namespace_key; |
66 changes: 66 additions & 0 deletions
66
config/migrations/cockroachdb/4_namespaces_relationships.up.sql
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,66 @@ | ||
-- Flags | ||
------------------ | ||
|
||
-- Add column namespace_key with a default value | ||
ALTER TABLE flags ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; | ||
|
||
-- Add foreign key constraint on namespace_key column referencing key column of namespaces table | ||
ALTER TABLE flags ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; | ||
|
||
-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns | ||
ALTER TABLE flags ALTER PRIMARY KEY USING COLUMNS (namespace_key, key); | ||
DROP INDEX IF EXISTS flags_key_key CASCADE; | ||
|
||
-- Variants | ||
------------------ | ||
|
||
-- Add column namespace_key with a default value | ||
ALTER TABLE variants ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; | ||
|
||
-- Drop previously created unique index | ||
DROP INDEX IF EXISTS "variants_flag_key_key" CASCADE; | ||
|
||
-- Add unique index on namespace_key, flag_key and key columns | ||
ALTER TABLE variants ADD CONSTRAINT "variants_namespace_flag_key" UNIQUE (namespace_key, flag_key, key); | ||
|
||
-- Add foreign key constraint on namespace_key column referencing key column of namespaces table | ||
ALTER TABLE variants ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; | ||
|
||
-- Add foreign key constraint on namespace_key and flag_key columns referencing namespace_key and key columns of flags table | ||
ALTER TABLE variants ADD FOREIGN KEY (namespace_key, flag_key) REFERENCES flags(namespace_key, key) ON DELETE CASCADE; | ||
|
||
-- Segments | ||
------------------ | ||
|
||
-- Add column namespace_key with a default value | ||
ALTER TABLE segments ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; | ||
|
||
-- Add foreign key constraint on namespace_key column referencing key column of namespaces table | ||
ALTER TABLE segments ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; | ||
|
||
-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns | ||
ALTER TABLE segments ALTER PRIMARY KEY USING COLUMNS (namespace_key, key); | ||
DROP INDEX IF EXISTS segments_key_key CASCADE; | ||
|
||
-- Constraints | ||
------------------ | ||
|
||
-- Add column namespace_key with a default value | ||
ALTER TABLE constraints ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; | ||
|
||
-- Add foreign key constraint on namespace_key column referencing key column of namespaces table | ||
ALTER TABLE constraints ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; | ||
|
||
-- Add foreign key constraint on namespace_key and segment_key columns referencing namespace_key and key columns of segments table | ||
ALTER TABLE constraints ADD FOREIGN KEY (namespace_key, segment_key) REFERENCES segments(namespace_key, key) ON DELETE CASCADE; | ||
|
||
-- Rules | ||
------------------ | ||
|
||
-- Add column namespace_key with a default value | ||
ALTER TABLE rules ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; | ||
|
||
-- Add foreign key constraint on namespace_key column referencing key column of namespaces table | ||
ALTER TABLE rules ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(key) ON DELETE CASCADE; | ||
ALTER TABLE rules ADD FOREIGN KEY (namespace_key, flag_key) REFERENCES flags(namespace_key, key) ON DELETE CASCADE; | ||
ALTER TABLE rules ADD FOREIGN KEY (namespace_key, segment_key) REFERENCES segments(namespace_key, key) ON DELETE CASCADE; |
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
config/migrations/cockroachdb/5_namespaces_segments.up.sql
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
config/migrations/mysql/5_namespaces_relationships.down.sql
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,79 @@ | ||
-- Rules | ||
|
||
-- Drop foreign key constraint on namespace_key column | ||
ALTER TABLE rules DROP FOREIGN KEY `rules_ibfk_1`; | ||
|
||
-- Drop foreign key constraint on namespace_key and flag_key columns | ||
ALTER TABLE rules DROP FOREIGN KEY `rules_ibfk_2`; | ||
|
||
-- Drop foreign key constraint on namespace_key and segment_key columns | ||
ALTER TABLE rules DROP FOREIGN KEY `rules_ibfk_3`; | ||
|
||
-- Drop previously created index and add a new index on flag_key and segment_key columns | ||
ALTER TABLE rules DROP INDEX `rules_namespace_flag_key`, ADD INDEX `flag_key` (`flag_key`) USING BTREE; | ||
ALTER TABLE rules DROP INDEX `rules_namespace_segment_key`, ADD INDEX `segment_key` (`segment_key`) USING BTREE; | ||
|
||
-- Add foreign key constraint on flag_key column referencing key column of flags table | ||
ALTER TABLE rules ADD FOREIGN KEY (flag_key) REFERENCES flags(`key`) ON DELETE CASCADE; | ||
|
||
-- Add foreign key constraint on segment_key column referencing key column of segments table | ||
ALTER TABLE rules ADD FOREIGN KEY (segment_key) REFERENCES segments(`key`) ON DELETE CASCADE; | ||
|
||
-- Drop column namespace_key | ||
ALTER TABLE rules DROP COLUMN namespace_key; | ||
|
||
-- Variants | ||
|
||
-- Drop foreign key constraint on namespace_key column | ||
ALTER TABLE variants DROP FOREIGN KEY `variants_ibfk_1`; | ||
|
||
-- Drop foreign key constraint on namespace_key and flag_key columns | ||
ALTER TABLE variants DROP FOREIGN KEY `variants_ibfk_2`; | ||
|
||
-- Add foreign key constraint on flag_key column referencing key column of flags table | ||
ALTER TABLE variants ADD FOREIGN KEY (flag_key) REFERENCES flags(`key`) ON DELETE CASCADE; | ||
|
||
-- Drop previously created unique index and add a new unique index on flag_key and key columns | ||
ALTER TABLE variants DROP INDEX `variants_namespace_flag_key`, ADD UNIQUE INDEX `variants_flag_key_key` (`flag_key`, `key`) USING BTREE; | ||
|
||
-- Drop column namespace_key | ||
ALTER TABLE variants DROP COLUMN namespace_key; | ||
|
||
-- Flags | ||
|
||
-- Drop foreign key constraint on namespace_key column | ||
ALTER TABLE flags DROP FOREIGN KEY `flags_ibfk_1`; | ||
|
||
-- Drop primary key constraint and add a new primary key on key column | ||
ALTER TABLE flags DROP PRIMARY KEY, ADD PRIMARY KEY (`key`); | ||
|
||
-- Drop column namespace_key | ||
ALTER TABLE flags DROP COLUMN namespace_key; | ||
|
||
-- Constraints | ||
|
||
-- Drop foreign key constraint on namespace_key column | ||
ALTER TABLE constraints DROP FOREIGN KEY `constraints_ibfk_1`; | ||
|
||
-- Drop foreign key constraint on namespace_key and segment_key columns | ||
ALTER TABLE constraints DROP FOREIGN KEY `constraints_ibfk_2`; | ||
|
||
-- Add foreign key constraint on segment_key column referencing key column of segments table | ||
ALTER TABLE constraints ADD FOREIGN KEY (segment_key) REFERENCES segments(`key`) ON DELETE CASCADE; | ||
|
||
-- Drop index on namespace_key and segment_key columns and add a new index on segment_key column | ||
ALTER TABLE constraints DROP INDEX `constraints_namespace_segment_key`, ADD INDEX `segment_key` (`segment_key`) USING BTREE; | ||
|
||
-- Drop column namespace_key | ||
ALTER TABLE constraints DROP COLUMN namespace_key; | ||
|
||
-- Segments | ||
|
||
-- Drop foreign key constraint on namespace_key column | ||
ALTER TABLE segments DROP FOREIGN KEY `segments_ibfk_1`; | ||
|
||
-- Drop primary key constraint and add a new primary key on key column | ||
ALTER TABLE segments DROP PRIMARY KEY, ADD PRIMARY KEY (`key`); | ||
|
||
-- Drop column namespace_key | ||
ALTER TABLE segments DROP COLUMN namespace_key; |
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,83 @@ | ||
-- Flags | ||
|
||
-- Add column namespace_key with a default value | ||
ALTER TABLE flags ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; | ||
|
||
-- Drop previously created unique index | ||
ALTER TABLE flags DROP INDEX `key`, ADD INDEX `key` (`key`) USING BTREE; | ||
|
||
-- Add foreign key constraint on namespace_key column referencing key column of namespaces table | ||
ALTER TABLE flags ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(`key`) ON DELETE CASCADE; | ||
|
||
-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns | ||
ALTER TABLE flags DROP PRIMARY KEY, ADD PRIMARY KEY (`namespace_key`, `key`); | ||
|
||
-- Variants | ||
|
||
-- Add column namespace_key with a default value | ||
ALTER TABLE variants ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; | ||
|
||
-- Drop previously created foreign key | ||
ALTER TABLE variants DROP FOREIGN KEY `variants_ibfk_1`; | ||
|
||
-- Drop previously created unique index and add a new unique index on namespace_key, flag_key and key columns | ||
ALTER TABLE variants DROP INDEX `variants_flag_key_key`, ADD UNIQUE INDEX `variants_namespace_flag_key` (`namespace_key`, `flag_key`, `key`) USING BTREE; | ||
|
||
-- Add foreign key constraint on namespace_key column referencing key column of namespaces table | ||
ALTER TABLE variants ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(`key`) ON DELETE CASCADE; | ||
|
||
-- Add foreign key constraint on namespace_key and flag_key columns referencing namespace_key and key columns of flags table | ||
ALTER TABLE variants ADD FOREIGN KEY (namespace_key, flag_key) REFERENCES flags(`namespace_key`, `key`) ON DELETE CASCADE; | ||
|
||
-- Segments | ||
|
||
-- Add column namespace_key with a default value | ||
ALTER TABLE segments ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; | ||
|
||
-- Drop previously created unique index and add a new unique index on namespace_key and key columns | ||
ALTER TABLE segments DROP INDEX `key`, ADD INDEX `key` (`key`) USING BTREE; | ||
|
||
-- Add foreign key constraint on namespace_key column referencing key column of namespaces table | ||
ALTER TABLE segments ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(`key`) ON DELETE CASCADE; | ||
|
||
-- Drop primary key constraint and add a new composite primary key on namespace_key and key columns | ||
ALTER TABLE segments DROP PRIMARY KEY, ADD PRIMARY KEY (`namespace_key`, `key`); | ||
|
||
-- Constraints | ||
|
||
-- Add column namespace_key with a default value | ||
ALTER TABLE constraints ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; | ||
|
||
-- Drop previously created foreign key | ||
ALTER TABLE constraints DROP FOREIGN KEY `constraints_ibfk_1`; | ||
|
||
-- Drop previously created index and add a new index on namespace_key and segment_key columns | ||
ALTER TABLE constraints DROP INDEX `segment_key`, ADD INDEX `constraints_namespace_segment_key` (`namespace_key`, `segment_key`) USING BTREE; | ||
|
||
-- Add foreign key constraint on namespace_key column referencing key column of namespaces table | ||
ALTER TABLE constraints ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(`key`) ON DELETE CASCADE; | ||
|
||
-- Add foreign key constraint on namespace_key and segment_key columns referencing namespace_key and key columns of segments table | ||
ALTER TABLE constraints ADD FOREIGN KEY (namespace_key, segment_key) REFERENCES segments(`namespace_key`, `key`) ON DELETE CASCADE; | ||
|
||
-- Rules | ||
|
||
-- Add column namespace_key with a default value | ||
ALTER TABLE rules ADD COLUMN namespace_key VARCHAR(255) NOT NULL DEFAULT 'default'; | ||
|
||
-- Drop previously created foreign keys | ||
ALTER TABLE rules DROP FOREIGN KEY `rules_ibfk_1`; | ||
ALTER TABLE rules DROP FOREIGN KEY `rules_ibfk_2`; | ||
|
||
-- Drop previously created index and add a new index on namespace_key, flag_key and segment_key columns | ||
ALTER TABLE rules DROP INDEX `flag_key`, ADD INDEX `rules_namespace_flag_key` (`namespace_key`, `flag_key`) USING BTREE; | ||
ALTER TABLE rules DROP INDEX `segment_key`, ADD INDEX `rules_namespace_segment_key` (`namespace_key`, `segment_key`) USING BTREE; | ||
|
||
-- Add foreign key constraint on namespace_key column referencing key column of namespaces table | ||
ALTER TABLE rules ADD FOREIGN KEY (namespace_key) REFERENCES namespaces(`key`) ON DELETE CASCADE; | ||
|
||
-- Add foreign key constraint on namespace_key and flag_key columns referencing namespace_key and key columns of flags table | ||
ALTER TABLE rules ADD FOREIGN KEY (namespace_key, flag_key) REFERENCES flags(`namespace_key`, `key`) ON DELETE CASCADE; | ||
|
||
-- Add foreign key constraint on namespace_key and segment_key columns referencing namespace_key and key columns of segments table | ||
ALTER TABLE rules ADD FOREIGN KEY (namespace_key, segment_key) REFERENCES segments(`namespace_key`, `key`) ON DELETE CASCADE; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.