diff --git a/src/migrations/20210304115810-change-default-timestamp-to-now.js b/src/migrations/20210304115810-change-default-timestamp-to-now.js new file mode 100644 index 0000000000..e1dfe617e1 --- /dev/null +++ b/src/migrations/20210304115810-change-default-timestamp-to-now.js @@ -0,0 +1,30 @@ +'use strict'; + +exports.up = function(db, cb) { + db.runSql( + ` + ALTER TABLE client_applications ALTER COLUMN created_at SET DEFAULT now(); + ALTER TABLE client_applications ALTER COLUMN updated_at SET DEFAULT now(); + ALTER TABLE context_fields ALTER COLUMN created_at SET DEFAULT now(); + ALTER TABLE context_fields ALTER COLUMN updated_at SET DEFAULT now(); + ALTER TABLE projects ALTER COLUMN created_at SET DEFAULT now(); + ALTER TABLE users ALTER COLUMN created_at SET DEFAULT now(); + `, + cb, + ); +}; + +exports.down = function(db, cb) { + db.runSql( + ` + ALTER TABLE client_applications ALTER COLUMN created_at SET DEFAULT 'now()'; + ALTER TABLE client_applications ALTER COLUMN updated_at SET DEFAULT 'now()'; + ALTER TABLE context_fields ALTER COLUMN created_at SET DEFAULT 'now()'; + ALTER TABLE context_fields ALTER COLUMN updated_at SET DEFAULT 'now()'; + ALTER TABLE projects ALTER COLUMN created_at SET DEFAULT 'now()'; + ALTER TABLE users ALTER COLUMN created_at SET DEFAULT 'now()'; + + `, + cb, + ); +};