Skip to content

Commit

Permalink
adds account api key db migration (#558)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzelei authored Nov 10, 2023
1 parent ec58558 commit 1bae8df
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/gen/go/db/models.go

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

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP TABLE IF EXISTS neosync_api.account_api_keys;
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;

0 comments on commit 1bae8df

Please sign in to comment.