Roughed in verify user. Will resist after restructuring users routes
This commit is contained in:
parent
e6733b2c2e
commit
05ded17aec
7 changed files with 126 additions and 7 deletions
|
@ -1,6 +1,10 @@
|
|||
-- bactdb
|
||||
-- Matthew R Dillon
|
||||
|
||||
-- Need to include something to keep gomigrate happy.
|
||||
-- SELECT 1;
|
||||
|
||||
DROP TABLE users;
|
||||
|
||||
DROP TYPE e_roles;
|
||||
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
-- bactdb
|
||||
-- Matthew R Dillon
|
||||
|
||||
CREATE TYPE e_roles AS ENUM('R', 'W', 'A');
|
||||
-- 'R': read-only, default
|
||||
-- 'W': read-write
|
||||
-- 'A': administrator
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'e_roles') THEN
|
||||
CREATE TYPE e_roles AS ENUM('R', 'W', 'A');
|
||||
-- 'R': read-only, default
|
||||
-- 'W': read-write
|
||||
-- 'A': administrator
|
||||
END IF;
|
||||
END$$;
|
||||
|
||||
CREATE TABLE users (
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id BIGSERIAL NOT NULL,
|
||||
email CHARACTER VARYING(254) NOT NULL UNIQUE,
|
||||
password CHARACTER(60) NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
role e_roles DEFAULT 'R' NOT NULL,
|
||||
verified BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
|
|
5
migrations/00011_AddVerification_down.sql
Normal file
5
migrations/00011_AddVerification_down.sql
Normal file
|
@ -0,0 +1,5 @@
|
|||
-- bactdb
|
||||
-- Matthew R Dillon
|
||||
|
||||
DROP TABLE verification;
|
||||
|
13
migrations/00011_AddVerification_up.sql
Normal file
13
migrations/00011_AddVerification_up.sql
Normal file
|
@ -0,0 +1,13 @@
|
|||
-- bactdb
|
||||
-- Matthew R Dillon
|
||||
|
||||
CREATE TABLE verification (
|
||||
user_id BIGINT NOT NULL,
|
||||
nonce CHARACTER(60) NOT NULL UNIQUE,
|
||||
|
||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
|
||||
CONSTRAINT verification_pkey PRIMARY KEY (user_id),
|
||||
FOREIGN KEY (user_id) REFERENCES users(id)
|
||||
);
|
||||
|
Reference in a new issue