omnivore/packages/db/migrations/0085.do.api_key.sql

22 lines
557 B
MySQL
Raw Normal View History

2022-05-27 02:41:29 +00:00
-- Type: DO
-- Name: api_key
-- Description: api_key model
BEGIN;
CREATE TABLE omnivore.api_key (
id uuid PRIMARY KEY DEFAULT uuid_generate_v1mc(),
user_id uuid NOT NULL REFERENCES omnivore.user (id) ON DELETE CASCADE,
name text NOT NULL,
key text NOT NULL,
scopes text[] NOT NULL DEFAULT '{}',
expires_at timestamptz NOT NULL,
created_at timestamptz NOT NULL DEFAULT current_timestamp,
2022-05-27 03:22:50 +00:00
used_at timestamptz,
UNIQUE (user_id, name)
2022-05-27 02:41:29 +00:00
);
GRANT SELECT, INSERT, UPDATE, DELETE ON omnivore.api_key TO omnivore_user;
2022-05-27 02:41:29 +00:00
COMMIT;