feature: add creation dates

This commit is contained in:
Sammy Teillet
2023-04-20 12:15:58 +02:00
parent 63c31b4290
commit 38e2e930b6
18 changed files with 144 additions and 0 deletions

View File

@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."person" add column "created_at" timestamptz
-- null default now();

View File

@ -0,0 +1,2 @@
alter table "public"."person" add column "created_at" timestamptz
null default now();

View File

@ -0,0 +1,21 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."person" add column "updated_at" timestamptz
-- null default now();
--
-- CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
-- RETURNS TRIGGER AS $$
-- DECLARE
-- _new record;
-- BEGIN
-- _new := NEW;
-- _new."updated_at" = NOW();
-- RETURN _new;
-- END;
-- $$ LANGUAGE plpgsql;
-- CREATE TRIGGER "set_public_person_updated_at"
-- BEFORE UPDATE ON "public"."person"
-- FOR EACH ROW
-- EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
-- COMMENT ON TRIGGER "set_public_person_updated_at" ON "public"."person"
-- IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@ -0,0 +1,19 @@
alter table "public"."person" add column "updated_at" timestamptz
null default now();
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_person_updated_at"
BEFORE UPDATE ON "public"."person"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_person_updated_at" ON "public"."person"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."company" add column "created_at" timestamptz
-- null default now();

View File

@ -0,0 +1,2 @@
alter table "public"."company" add column "created_at" timestamptz
null default now();

View File

@ -0,0 +1,21 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."company" add column "updated_at" timestamptz
-- not null default now();
--
-- CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
-- RETURNS TRIGGER AS $$
-- DECLARE
-- _new record;
-- BEGIN
-- _new := NEW;
-- _new."updated_at" = NOW();
-- RETURN _new;
-- END;
-- $$ LANGUAGE plpgsql;
-- CREATE TRIGGER "set_public_company_updated_at"
-- BEFORE UPDATE ON "public"."company"
-- FOR EACH ROW
-- EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
-- COMMENT ON TRIGGER "set_public_company_updated_at" ON "public"."company"
-- IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@ -0,0 +1,19 @@
alter table "public"."company" add column "updated_at" timestamptz
not null default now();
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_company_updated_at"
BEFORE UPDATE ON "public"."company"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_company_updated_at" ON "public"."company"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@ -0,0 +1 @@
alter table "public"."company" alter column "created_at" drop not null;

View File

@ -0,0 +1 @@
alter table "public"."company" alter column "created_at" set not null;

View File

@ -0,0 +1 @@
alter table "public"."person" alter column "created_at" drop not null;

View File

@ -0,0 +1 @@
alter table "public"."person" alter column "created_at" set not null;

View File

@ -0,0 +1 @@
alter table "public"."person" alter column "updated_at" drop not null;

View File

@ -0,0 +1 @@
alter table "public"."person" alter column "updated_at" set not null;

View File

@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."workspaces" add column "created_at" timestamptz
-- not null default now();

View File

@ -0,0 +1,2 @@
alter table "public"."workspaces" add column "created_at" timestamptz
not null default now();

View File

@ -0,0 +1,21 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."workspaces" add column "updated_at" timestamptz
-- not null default now();
--
-- CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
-- RETURNS TRIGGER AS $$
-- DECLARE
-- _new record;
-- BEGIN
-- _new := NEW;
-- _new."updated_at" = NOW();
-- RETURN _new;
-- END;
-- $$ LANGUAGE plpgsql;
-- CREATE TRIGGER "set_public_workspaces_updated_at"
-- BEFORE UPDATE ON "public"."workspaces"
-- FOR EACH ROW
-- EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
-- COMMENT ON TRIGGER "set_public_workspaces_updated_at" ON "public"."workspaces"
-- IS 'trigger to set value of column "updated_at" to current timestamp on row update';

View File

@ -0,0 +1,19 @@
alter table "public"."workspaces" add column "updated_at" timestamptz
not null default now();
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_workspaces_updated_at"
BEFORE UPDATE ON "public"."workspaces"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_workspaces_updated_at" ON "public"."workspaces"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';