Use pug
This commit is contained in:
@@ -0,0 +1 @@
|
||||
DROP FUNCTION set_updated_timestamp;
|
||||
11
sql/migrations/patches/20190925000000-updated-at/up.sql
Normal file
11
sql/migrations/patches/20190925000000-updated-at/up.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE OR REPLACE FUNCTION set_updated_timestamp()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
IF row(NEW.*) IS DISTINCT FROM row(OLD.*) THEN
|
||||
NEW.updated_at = now();
|
||||
RETURN NEW;
|
||||
ELSE
|
||||
RETURN OLD;
|
||||
END IF;
|
||||
END;
|
||||
$$ language 'plpgsql';
|
||||
1
sql/migrations/patches/20190925000001-users/down.sql
Normal file
1
sql/migrations/patches/20190925000001-users/down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE users;
|
||||
9
sql/migrations/patches/20190925000001-users/up.sql
Normal file
9
sql/migrations/patches/20190925000001-users/up.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE users (
|
||||
id integer GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
||||
email text NOT NULL UNIQUE,
|
||||
encrypted_password text NOT NULL,
|
||||
created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
CREATE TRIGGER set_users_updated BEFORE UPDATE ON users FOR EACH ROW EXECUTE PROCEDURE set_updated_timestamp();
|
||||
Reference in New Issue
Block a user