-
Notifications
You must be signed in to change notification settings - Fork 7
Feature: Adds createdAt, updatedAt and siteId columns in postgres #45
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
base: master
Are you sure you want to change the base?
Conversation
…g created_at and updated_at columns in the schema
| $$ LANGUAGE plpgsql; | ||
|
|
||
| ALTER TABLE IF EXISTS uris | ||
| ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), |
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.
I think the NOT NULL constraint on these columns has the potential to have a major performance penalty in postgres versions before 11. If anyone is running an earlier version, we'll have to break this step down in to a few steps.
james-owen
left a comment
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.
I think this change would require dropping the migrations table and rebuilding it.
| var commands = [], url; | ||
|
|
||
| for (let i = 0; i < ops.length; i++) { | ||
| for (let i = 0, opsLength = ops.length; i < opsLength; i++) { |
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 not ops.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/
Description
QA
In order to be able to test this feature, you should link this package and clay/amphora#665 in a clay project. I've been using https://github.com/clay/clay-starter to develop this feature, that's a good starting point.
Testing steps
clay-starter)makeadmineris up and running usingdocker-compose up -d adminerappdirectory (or where thepackage.jsonfile is located) and link the previously mentioned packages withnpm link amphora && npm link amphora-storage-postgres(make sure the packages are in the correct branch and linked)rs. After it's done, you should a message statingMigrations Completepostgres; password isexample)created_at, which should default to the date the row was created;updated_at, which should default to the date the row was created and update itself if the data changes; andsite_id, which should contain the site slugmake boostrap(where theMakefileis located)