Skip to content

Commit

Permalink
Optimise the amount of resources we'll keep - columns, indexes, types
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslav Dimitrov <radoslav@stacklok.com>
  • Loading branch information
rdimitrov committed Jun 5, 2024
1 parent 2419e4b commit dccb268
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 160 deletions.
51 changes: 0 additions & 51 deletions database/migrations/000061_user_invites.up.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,10 @@

BEGIN;

-- drop the indexes
DROP INDEX IF EXISTS idx_user_invites_email;
-- drop the index on the project column
DROP INDEX IF EXISTS idx_user_invites_project;
DROP INDEX IF EXISTS idx_user_invites_invitee;
DROP INDEX IF EXISTS idx_user_invites_sponsor;

-- drop the table
-- drop the user_invites table
DROP TABLE IF EXISTS user_invites;

-- drop the types
DROP TYPE IF EXISTS invite_status;
DROP TYPE IF EXISTS user_role;

COMMIT;
30 changes: 30 additions & 0 deletions database/migrations/000062_user_invites.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
-- 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.

BEGIN;

CREATE TABLE IF NOT EXISTS user_invites (
code TEXT NOT NULL PRIMARY KEY,
email TEXT NOT NULL,
role TEXT NOT NULL DEFAULT 'viewer',
project UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
sponsor INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW()
);

-- create an index on the project column
CREATE INDEX IF NOT EXISTS idx_user_invites_project ON user_invites(project);

COMMIT;
107 changes: 7 additions & 100 deletions internal/db/models.go

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

0 comments on commit dccb268

Please sign in to comment.