Skip to content

Commit

Permalink
fix: api_keys -> api_key and foreign key constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
Knoblauchpilze committed Mar 31, 2024
1 parent 8686bab commit 59cea8f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions database/migrations/100_seed_users.down.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

DELETE FROM api_key;
DELETE FROM api_user;
12 changes: 6 additions & 6 deletions database/migrations/100_seed_users.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ INSERT INTO user_service_schema.api_user ("id", "email", "password")
'strong-password'
);

INSERT INTO user_service_schema.api_keys ("id", "key", "api_user")
INSERT INTO user_service_schema.api_key ("id", "key", "api_user")
VALUES (
'a5eff7a9-9bd6-4f51-9b42-a7ca5ffd3f5e',
'3e8d49a3-9220-4ea0-88eb-299520c6ab85',
Expand All @@ -22,13 +22,13 @@ INSERT INTO user_service_schema.api_user ("id", "email", "password")
'super-strong-password'
);

INSERT INTO user_service_schema.api_keys ("id", "key", "api_user")
INSERT INTO user_service_schema.api_key ("id", "key", "api_user")
VALUES (
'fd8136c4-c584-4bbf-a390-53d5c2548fb8',
'2da3e9ec-7299-473a-be0f-d722d870f51a',
'4f26321f-d0ea-46a3-83dd-6aa1c6053aaf'
);
INSERT INTO user_service_schema.api_keys ("id", "key", "api_user")
INSERT INTO user_service_schema.api_key ("id", "key", "api_user")
VALUES (
'2e791bfe-7e35-465d-8269-1bbd7b4e86c5',
'7ba9182e-f4a6-4eec-b216-d2a9f5179fc2',
Expand All @@ -43,20 +43,20 @@ INSERT INTO user_service_schema.api_user ("id", "email", "password")
'weakpassword'
);

INSERT INTO user_service_schema.api_keys ("id", "key", "api_user")
INSERT INTO user_service_schema.api_key ("id", "key", "api_user")
VALUES (
'42698272-5b8f-42db-a43c-8108eaad66e1',
'e9c3ce0d-d6d6-45cb-ad93-c407d429469f',
'00b265e6-6638-4b1b-aeac-5898c7307eb8'
);
INSERT INTO user_service_schema.api_keys ("id", "key", "api_user", "enabled")
INSERT INTO user_service_schema.api_key ("id", "key", "api_user", "enabled")
VALUES (
'f79d5502-4c57-41de-8237-893c6e1983f0',
'586e86f0-b981-4d16-90ee-99114ae36d19',
'00b265e6-6638-4b1b-aeac-5898c7307eb8',
FALSE
);
INSERT INTO user_service_schema.api_keys ("id", "key", "api_user", "enabled")
INSERT INTO user_service_schema.api_key ("id", "key", "api_user", "enabled")
VALUES (
'7087e425-7c3e-40b3-9736-b2f77fefc0fb',
'627a4de2-263e-4a2d-a24f-07bea157aabd',
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/3_create_api_keys.down.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

DROP TABLE api_keys;
DROP TABLE api_key;
5 changes: 3 additions & 2 deletions database/migrations/3_create_api_keys.up.sql
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@

CREATE TABLE api_keys (
CREATE TABLE api_key (
id UUID NOT NULL,
key UUID NOT NULL,
api_user UUID NOT NULL,
enabled boolean DEFAULT TRUE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
PRIMARY KEY (id),
FOREIGN KEY (api_user) REFERENCES api_user(id)
);

0 comments on commit 59cea8f

Please sign in to comment.