-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Adds createdAt, updatedAt and siteId columns in postgres #45
Open
manuelurenah
wants to merge
14
commits into
master
Choose a base branch
from
migrate-updated-at
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
13c9925
Adds sql queries to migrate pages, users, uris and lists tables addin…
manuelurenah bd07c4b
Adds migration for the site_id column
manuelurenah a696762
Fixes error in site id column migration
manuelurenah 498d702
Modifies migration script and put logic
manuelurenah 47e010a
Fixes issue that prevent pages from publishing and adding the site_id…
manuelurenah d1113fc
Updates test cases that were affected by the changes:
manuelurenah ba398ff
Fixes issue that prevented pages from unpublishing
manuelurenah 58d9c56
Fixes user data not being stored
manuelurenah 51fd22d
Applies PR code review feedback
manuelurenah 8f07b36
Modifies migration run time
manuelurenah f8c2556
Removes sql queries to create schemas and tables
manuelurenah bddc24a
Removes uris condition
manuelurenah 345017c
Adds uris table creation statement
manuelurenah 5d2076e
Updates migration queries
manuelurenah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 was deleted.
Oops, something went wrong.
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,7 @@ | ||
CREATE OR REPLACE FUNCTION trigger_set_timestamp() | ||
RETURNS TRIGGER AS $$ | ||
BEGIN | ||
NEW.updated_at = NOW(); | ||
RETURN NEW; | ||
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,8 @@ | ||
ALTER TABLE IF EXISTS uris | ||
ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ DEFAULT NOW(), | ||
ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ DEFAULT NOW(); | ||
|
||
CREATE TRIGGER set_timestamp | ||
BEFORE UPDATE ON uris | ||
FOR EACH ROW | ||
EXECUTE PROCEDURE trigger_set_timestamp(); |
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
CREATE OR REPLACE FUNCTION trigger_set_timestamp() | ||
RETURNS TRIGGER AS $$ | ||
BEGIN | ||
NEW.updated_at = NOW(); | ||
RETURN NEW; | ||
END; | ||
$$ LANGUAGE plpgsql; | ||
|
||
ALTER TABLE IF EXISTS lists | ||
ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ DEFAULT NOW(), | ||
ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ DEFAULT NOW(); | ||
|
||
CREATE TRIGGER set_timestamp | ||
BEFORE UPDATE ON lists | ||
FOR EACH ROW | ||
EXECUTE PROCEDURE trigger_set_timestamp(); |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
ALTER TABLE IF EXISTS pages | ||
ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ DEFAULT NOW(), | ||
ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ DEFAULT NOW(); | ||
|
||
CREATE TRIGGER set_timestamp | ||
BEFORE UPDATE ON pages | ||
FOR EACH ROW | ||
EXECUTE PROCEDURE trigger_set_timestamp(); |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
ALTER TABLE IF EXISTS users | ||
ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ DEFAULT NOW(), | ||
ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ DEFAULT NOW(); | ||
|
||
CREATE TRIGGER set_timestamp | ||
BEFORE UPDATE ON users | ||
FOR EACH ROW | ||
EXECUTE PROCEDURE trigger_set_timestamp(); |
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,2 @@ | ||
ALTER TABLE IF EXISTS pages | ||
ADD COLUMN IF NOT EXISTS site_id VARCHAR(255); |
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,2 @@ | ||
ALTER TABLE IF EXISTS lists | ||
ADD COLUMN IF NOT EXISTS site_id VARCHAR(255); |
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,2 @@ | ||
ALTER TABLE IF EXISTS uris | ||
ADD COLUMN IF NOT EXISTS site_id VARCHAR(255); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we using
opsLength
here and notops.length
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done for loop optimization, we assign the value of
length
to a property to avoid having to look it up at every iteration. You can read more about it here: https://jaysoo.ca/2009/12/23/javascript-optimizing-loops/