bazzar/crates/token_manager/migrations/202204131841_init.sql
2023-06-20 07:03:15 +02:00

28 lines
1.2 KiB
SQL

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
CREATE TYPE "Audience" AS ENUM (
'web',
'mobile',
'feed',
'admin_panel'
);
CREATE TYPE "Role" AS ENUM (
'admin',
'user'
);
CREATE TABLE tokens
(
id integer NOT NULL,
customer_id uuid NOT NULL,
role "Role" NOT NULL,
issuer character varying DEFAULT 'myco'::character varying NOT NULL,
subject integer NOT NULL,
audience "Audience" DEFAULT 'web'::"Audience" NOT NULL,
expiration_time timestamp without time zone DEFAULT (now() + '14 days'::interval) NOT NULL,
not_before_time timestamp without time zone DEFAULT (now() - '00:01:00'::interval) NOT NULL,
issued_at_time timestamp without time zone DEFAULT now() NOT NULL,
jwt_id uuid DEFAULT gen_random_uuid() NOT NULL
);