diff --git a/internal/db/schema/migrations/oss/postgres/0/01_domain_types.up.sql b/internal/db/schema/migrations/oss/postgres/0/01_domain_types.up.sql index c7a4a66d1a..098e2d5ba5 100644 --- a/internal/db/schema/migrations/oss/postgres/0/01_domain_types.up.sql +++ b/internal/db/schema/migrations/oss/postgres/0/01_domain_types.up.sql @@ -63,6 +63,7 @@ comment on function is 'function used in before update triggers to properly set update_time columns'; +-- Replaced in 21/01_default_time.up.sql create or replace function default_create_time() returns trigger diff --git a/internal/db/schema/migrations/oss/postgres/21/01_default_time.up.sql b/internal/db/schema/migrations/oss/postgres/21/01_default_time.up.sql new file mode 100644 index 0000000000..c10817f27f --- /dev/null +++ b/internal/db/schema/migrations/oss/postgres/21/01_default_time.up.sql @@ -0,0 +1,15 @@ +begin; + +-- Replaces function from 0/01_domain_types.up.sql +create or replace function default_create_time() + returns trigger +as $$ +begin + if new.create_time is distinct from now() then + new.create_time = now(); + end if; + return new; +end; +$$ language plpgsql; + +commit;