Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MaarchCourrier
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maarch
MaarchCourrier
Commits
9dcdfdbf
Commit
9dcdfdbf
authored
2 years ago
by
Jean-Laurent DUZANT
Browse files
Options
Downloads
Patches
Plain Diff
FIX #19580 TIME 0:45 migrate chronos from parameters table to sequences
parent
d3492af6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
migration/21.03/210321.sql
+18
-1
18 additions, 1 deletion
migration/21.03/210321.sql
with
18 additions
and
1 deletion
migration/21.03/210321.sql
+
18
−
1
View file @
9dcdfdbf
...
...
@@ -6,12 +6,29 @@
-- --
-- *************************************************************************--
DO
$$
DECLARE
last_chrono
text
;
chrono
record
;
chrono_id_seq
text
;
BEGIN
FOR
chrono
IN
(
SELECT
id
,
param_value_int
as
value
FROM
parameters
WHERE
id
LIKE
'chrono_%'
)
LOOP
chrono_id_seq
:
=
CONCAT
(
chrono
.
id
,
'_seq'
);
IF
NOT
EXISTS
(
SELECT
0
FROM
pg_class
where
relname
=
chrono_id_seq
)
THEN
EXECUTE
'CREATE SEQUENCE '
||
chrono_id_seq
||
' INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;'
;
END
IF
;
EXECUTE
'SELECT setVal(
''
'
||
chrono_id_seq
||
'
''
,'
||
chrono
.
value
||
',false)'
;
END
LOOP
;
END
$$
;
CREATE
OR
REPLACE
FUNCTION
public
.
increase_chrono
(
chrono_id_seq
text
,
chrono_id_name
text
)
returns
table
(
chrono_id
bigint
)
as
$$
DECLARE
retval
bigint
;
BEGIN
IF
NOT
EXISTS
(
SELECT
0
FROM
pg_class
where
relname
=
chrono_id_seq
)
THEN
EXECUTE
'CREATE SEQUENCE '
||
chrono_id_seq
||
' INCREMENT 1 MINVALUE 1
00
MAXVALUE 9223372036854775807 START 1
00
CACHE 1;'
;
EXECUTE
'CREATE SEQUENCE '
||
chrono_id_seq
||
' INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;'
;
END
IF
;
IF
NOT
EXISTS
(
SELECT
0
FROM
parameters
where
id
=
chrono_id_name
)
THEN
EXECUTE
'INSERT INTO parameters (id, param_value_int) VALUES (
''
'
||
chrono_id_name
||
'
''
, 1)'
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment