-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6de3b7
commit f4cb398
Showing
14 changed files
with
103 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE OR REPLACE FUNCTION update_updated_at_column() | ||
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE TABLE IF NOT EXISTS user_notes ( | ||
id UUID PRIMARY KEY, | ||
title TEXT, | ||
content TEXT, | ||
user_id UUID references users(id), | ||
created_at timestamptz DEFAULT now(), | ||
updated_at timestamptz DEFAULT now() | ||
); | ||
|
||
CREATE TRIGGER tr_users_bu BEFORE UPDATE on user_notes | ||
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,12 @@ | ||
CREATE TABLE IF NOT EXISTS Users ( | ||
CREATE TABLE IF NOT EXISTS users ( | ||
id UUID PRIMARY KEY, | ||
email TEXT UNIQUE, | ||
uname TEXT, | ||
phone TEXT, | ||
uaddress TEXT, | ||
created_at timestamptz DEFAULT now(), | ||
updated_at timestamptz DEFAULT now() | ||
) | ||
); | ||
|
||
CREATE OR REPLACE FUNCTION update_updated_at_column() | ||
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'; | ||
-- | ||
CREATE TABLE IF NOT EXISTS UserNotes ( | ||
id UUID PRIMARY KEY, | ||
title TEXT, | ||
content TEXT, | ||
user_id references Users(id), | ||
created_at timestamptz DEFAULT now(), | ||
updated_at timestamptz DEFAULT now() | ||
) | ||
|
||
CREATE OR REPLACE FUNCTION update_updated_at_column() | ||
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'; | ||
CREATE TRIGGER tr_users_bu BEFORE UPDATE on users | ||
FOR EACH ROW EXECUTE FUNCTION update_updated_at_column(); |