This repository has been archived on 2026-03-31. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
jelly/migrations/2018-07-17-173341_create_users/up.sql

21 lines
633 B
PL/PgSQL

CREATE OR REPLACE FUNCTION update_timestamp() RETURNS TRIGGER AS $$
BEGIN
NEW.updated = now();
RETURN NEW;
END;
$$ language 'plpgsql';
create table if not exists users (
id serial primary key,
name text,
email text not null unique,
password text not null,
avatar text,
is_verified bool not null default false,
has_verified_email bool not null default false,
created timestamp with time zone not null default now(),
updated timestamp with time zone not null default now()
);
CREATE TRIGGER user_updated BEFORE INSERT OR UPDATE ON users
FOR EACH ROW EXECUTE PROCEDURE update_timestamp();