repos / pico

pico services - prose.sh, pastes.sh, imgs.sh, feeds.sh, pgs.sh
git clone https://github.com/picosh/pico.git

pico / sql / migrations
Eric Bower · 23 Sep 23

20230921_add_tokens_table.sql

 1CREATE TABLE IF NOT EXISTS tokens (
 2  id uuid NOT NULL DEFAULT uuid_generate_v4(),
 3  user_id uuid NOT NULL,
 4  name varchar(256) NOT NULL,
 5  token varchar(256) NOT NULL DEFAULT uuid_generate_v4(),
 6  created_at timestamp without time zone NOT NULL DEFAULT NOW(),
 7  expires_at timestamp without time zone NOT NULL DEFAULT '2100-01-01 00:00:00',
 8  CONSTRAINT user_tokens_pkey PRIMARY KEY (id),
 9  CONSTRAINT unique_token UNIQUE (token),
10  CONSTRAINT unique_user_name UNIQUE (user_id, name),
11  CONSTRAINT fk_user_tokens_owner
12    FOREIGN KEY(user_id)
13  REFERENCES app_users(id)
14  ON DELETE CASCADE
15  ON UPDATE CASCADE
16);