Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TEHIK
TEIS
officials-service
Commits
200e6f48
Commit
200e6f48
authored
Jan 21, 2021
by
Enriko Käsper
Browse files
TEIS-1784: generate created_at and modified_at values in existing records, if null.
parent
9d40caeb
Changes
2
Hide whitespace changes
Inline
Side-by-side
gradle.properties
View file @
200e6f48
theGroup
=
ee.sm.ti.teis
theVersion
=
1.
9.0
theVersion
=
1.
10.0-SNAPSHOT
commonsVersion
=
1.14.0
officeApiGatewayVersion
=
1.14.0
pluginVersion
=
1.2.0
service/src/main/resources/db/changelog/data/2021-01-20.TEIS-1784.generate-created_at-values.sql
0 → 100644
View file @
200e6f48
--liquibase formatted sql
--changeset enriko:2021-01-20.TEIS-1784.generate-created_at-values.sql splitStatements:false
create
or
replace
function
fill_created_at_value
(
tableName
varchar
,
idType
varchar
)
returns
void
as
$$
declare
createdAt
timestamp
;
rec
record
;
begin
select
to_timestamp
(
'2020-03-31 08:00:00'
,
'YYYY-MM-DD HH24:MI:SS'
)
into
createdAt
;
for
rec
in
execute
'select * from '
||
quote_ident
(
tableName
)
||
' where created_at is null'
LOOP
select
createdAt
+
interval
'1 second'
into
createdAt
;
if
idType
=
'uuid'
then
-- RAISE NOTICE 'ID= "%"', rec.id::text;
execute
'update '
||
quote_ident
(
tableName
)
||
' set created_by =
''
SYSTEM
''
, created_at =
''
'
||
createdAt
||
'
''
, modified_at =
''
'
||
createdAt
||
'
''
where id=
''
'
||
rec
.
id
::
text
||
'
''
'
;
else
-- RAISE NOTICE 'ID str= "%"', rec.id;
execute
'update '
||
quote_ident
(
tableName
)
||
' set created_by =
''
SYSTEM
''
, created_at =
''
'
||
createdAt
||
'
''
, modified_at =
''
'
||
createdAt
||
'
''
where id=
''
'
||
rec
.
id
||
'
''
'
;
end
if
;
-- RAISE NOTICE 'createdAt "%"', createdAt;
end
loop
;
end
$$
language
plpgsql
;
select
fill_created_at_value
(
'office'
,
'uuid'
);
drop
function
fill_created_at_value
(
varchar
,
varchar
);
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment