This repository has been archived by the owner on Mar 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is a revert of a revert 232945e. concourse/concourse#1764 Signed-off-by: Topher Bullock <cbullock@pivotal.io>
- Loading branch information
1 parent
dd3361e
commit e704a68
Showing
9 changed files
with
269 additions
and
141 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
Large diffs are not rendered by default.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
db/migration/migrations/1511810746_create_resource_spaces.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,15 @@ | ||
BEGIN; | ||
|
||
ALTER INDEX versioned_resources_resource_space_id_idx RENAME TO versioned_resources_resource_id_idx ; | ||
|
||
ALTER INDEX versioned_resources_resource_space_id_type_version RENAME TO versioned_resources_resource_id_type_version; | ||
|
||
ALTER TABLE versioned_resources DROP CONSTRAINT resource_space_id_fkey; | ||
|
||
ALTER TABLE versioned_resources RENAME resource_space_id TO resource_id; | ||
|
||
ALTER TABLE versioned_resources ADD CONSTRAINT fkey_resource_id FOREIGN KEY (resource_id) REFERENCES resources(id) ON DELETE CASCADE; | ||
|
||
DROP TABLE resource_spaces; | ||
|
||
COMMIT; |
24 changes: 24 additions & 0 deletions
24
db/migration/migrations/1511810746_create_resource_spaces.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,24 @@ | ||
BEGIN; | ||
|
||
CREATE TABLE resource_spaces ( | ||
id serial PRIMARY KEY, | ||
resource_id int REFERENCES resources (id) ON DELETE CASCADE, | ||
name text NOT NULL, | ||
UNIQUE (resource_id, name) | ||
); | ||
|
||
INSERT INTO resource_spaces(id, resource_id, name) SELECT id, id, 'default' from resources; | ||
|
||
SELECT setval('resource_spaces_id_seq', (SELECT max(id) from resource_spaces)); | ||
|
||
ALTER TABLE versioned_resources RENAME resource_id TO resource_space_id; | ||
|
||
ALTER TABLE versioned_resources DROP CONSTRAINT fkey_resource_id; | ||
|
||
ALTER TABLE versioned_resources ADD CONSTRAINT resource_space_id_fkey FOREIGN KEY (resource_space_id) REFERENCES resource_spaces (id) ON DELETE CASCADE; | ||
|
||
ALTER INDEX versioned_resources_resource_id_type_version RENAME TO versioned_resources_resource_space_id_type_version; | ||
|
||
ALTER INDEX versioned_resources_resource_id_idx RENAME TO versioned_resources_resource_space_id_idx; | ||
|
||
COMMIT; |
Oops, something went wrong.