-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds account api key db migration (#558)
- Loading branch information
Showing
3 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
backend/sql/postgresql/schema/20231110174028_account-api-keys.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 @@ | ||
DROP TABLE IF EXISTS neosync_api.account_api_keys; |
22 changes: 22 additions & 0 deletions
22
backend/sql/postgresql/schema/20231110174028_account-api-keys.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,22 @@ | ||
CREATE TABLE IF NOT EXISTS neosync_api.account_api_keys ( | ||
id uuid NOT NULL DEFAULT gen_random_uuid(), | ||
account_id uuid NOT NULL, | ||
|
||
key_value text NOT NULL, | ||
|
||
created_by_id uuid NOT NULL, | ||
updated_By_id uuid NOT NULL, | ||
created_at timestamp NOT NULL DEFAULT now(), | ||
updated_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
expires_at timestamp NOT NULL, | ||
|
||
CONSTRAINT account_api_keys_pkey PRIMARY KEY (id), | ||
CONSTRAINT account_api_keys_account_id_key_value UNIQUE(account_id, key_value), | ||
CONSTRAINT fk_account_api_keys_accounts_id FOREIGN KEY (account_id) REFERENCES neosync_api.accounts(id) ON DELETE CASCADE, | ||
CONSTRAINT fk_account_api_keys_created_by_id FOREIGN KEY (created_by_id) REFERENCES neosync_api.users(id), | ||
CONSTRAINT fk_account_api_keys_updated_by_id FOREIGN KEY (updated_by_id) REFERENCES neosync_api.users(id) | ||
); | ||
ALTER TABLE neosync_api.account_api_keys OWNER TO neosync_api_owner; | ||
GRANT ALL ON TABLE neosync_api.account_api_keys TO neosync_api_owner; | ||
GRANT INSERT, DELETE, UPDATE, SELECT ON TABLE neosync_api.account_api_keys TO neosync_api_readwrite; | ||
GRANT SELECT ON TABLE neosync_api.account_api_keys TO neosync_api_readonly; |