-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d83caa
commit 5869a4d
Showing
12 changed files
with
141 additions
and
48 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 |
---|---|---|
|
@@ -29,4 +29,4 @@ cors: | |
# grpc_port: 9000 | ||
|
||
db: | ||
url: file:flipt.db | ||
url: cockroach://root@localhost:26257/defaultdb?sslmode=disable |
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 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