Add Updated At to Tasks And Libraries
This commit is contained in:
parent
ec645f6162
commit
c04aa74364
14 changed files with 74 additions and 38 deletions
2
migrations/000005_alter_task_table_updated_at.down.sql
Normal file
2
migrations/000005_alter_task_table_updated_at.down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE tasks
|
||||
DROP updated_at;
|
2
migrations/000005_alter_task_table_updated_at.up.sql
Normal file
2
migrations/000005_alter_task_table_updated_at.up.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE tasks
|
||||
ADD updated_at TIMESTAMP NOT NULL DEFAULT current_timestamp;
|
|
@ -0,0 +1 @@
|
|||
DROP FUNCTION update_updated_at_column;
|
|
@ -0,0 +1,7 @@
|
|||
CREATE OR REPLACE FUNCTION update_updated_at_column()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.updated_at = clock_timestamp();
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ language 'plpgsql';
|
|
@ -0,0 +1 @@
|
|||
DROP TRIGGER update_tasks_timestamp;
|
|
@ -0,0 +1 @@
|
|||
CREATE TRIGGER update_tasks_timestamp BEFORE UPDATE ON tasks FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
|
2
migrations/000008_alter_files_table_updated_at.down.sql
Normal file
2
migrations/000008_alter_files_table_updated_at.down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE files
|
||||
DROP updated_at;
|
2
migrations/000008_alter_files_table_updated_at.up.sql
Normal file
2
migrations/000008_alter_files_table_updated_at.up.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
ALTER TABLE files
|
||||
ADD updated_at TIMESTAMP NOT NULL DEFAULT current_timestamp;
|
|
@ -0,0 +1 @@
|
|||
DROP TRIGGER update_files_timestamp;
|
|
@ -0,0 +1 @@
|
|||
CREATE TRIGGER update_files_timestamp BEFORE UPDATE ON files FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column();
|
Loading…
Add table
Add a link
Reference in a new issue