Skip to content

Commit

Permalink
Put subscription foreign key on correct table (#2677)
Browse files Browse the repository at this point in the history
Mixed up profiles and projects again :(
  • Loading branch information
dmjb authored Mar 15, 2024
1 parent 6bfd133 commit 971a4aa
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 34 deletions.
18 changes: 18 additions & 0 deletions database/migrations/000030_subscription_profile_fk.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Copyright 2024 Stacklok, Inc
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

ALTER TABLE profiles DROP COLUMN subscription_id;
ALTER TABLE projects
ADD COLUMN subscription_id UUID DEFAULT NULL
REFERENCES subscriptions(id);
19 changes: 19 additions & 0 deletions database/migrations/000030_subscription_profile_fk.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- Copyright 2024 Stacklok, Inc
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

-- FK was created on wrong table (I mixed up profiles and projects again...)
ALTER TABLE projects DROP COLUMN subscription_id;
ALTER TABLE profiles
ADD COLUMN subscription_id UUID DEFAULT NULL
REFERENCES subscriptions(id);
20 changes: 10 additions & 10 deletions internal/db/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 19 additions & 8 deletions internal/db/profiles.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 8 additions & 16 deletions internal/db/projects.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 971a4aa

Please sign in to comment.