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
c7696e77
Commit
c7696e77
authored
8 years ago
by
Florian Azizian
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' of labs.maarch.org:maarch/MaarchCourrier into develop
parents
5e69ac68
4f9d96eb
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
sql/160_to_161.sql
+21
-3
21 additions, 3 deletions
sql/160_to_161.sql
with
21 additions
and
3 deletions
sql/160_to_161.sql
+
21
−
3
View file @
c7696e77
...
@@ -16,7 +16,8 @@ $$ LANGUAGE SQL;
...
@@ -16,7 +16,8 @@ $$ LANGUAGE SQL;
/* MIGRATION NOUVEL STRUCT MOTS CLEES*/
/* MIGRATION NOUVEL STRUCT MOTS CLES*/
DROP
SEQUENCE
IF
EXISTS
tag_id_seq
CASCADE
;
CREATE
SEQUENCE
tag_id_seq
CREATE
SEQUENCE
tag_id_seq
INCREMENT
1
INCREMENT
1
MINVALUE
1
MINVALUE
1
...
@@ -24,9 +25,13 @@ CREATE SEQUENCE tag_id_seq
...
@@ -24,9 +25,13 @@ CREATE SEQUENCE tag_id_seq
START
7
START
7
CACHE
1
;
CACHE
1
;
ALTER
TABLE
tags
DROP
COLUMN
IF
EXISTS
tag_id
;
ALTER
TABLE
tags
ADD
tag_id
bigint
NOT
NULL
DEFAULT
nextval
(
'tag_id_seq'
::
regclass
);
ALTER
TABLE
tags
ADD
tag_id
bigint
NOT
NULL
DEFAULT
nextval
(
'tag_id_seq'
::
regclass
);
ALTER
TABLE
tags
DROP
COLUMN
IF
EXISTS
entity_id_owner
;
ALTER
TABLE
tags
ADD
entity_id_owner
character
varying
(
32
);
ALTER
TABLE
tags
ADD
entity_id_owner
character
varying
(
32
);
DROP
SEQUENCE
IF
EXISTS
tmp_tag_id_seq
;
CREATE
SEQUENCE
tmp_tag_id_seq
CREATE
SEQUENCE
tmp_tag_id_seq
INCREMENT
1
INCREMENT
1
MINVALUE
1
MINVALUE
1
...
@@ -34,6 +39,7 @@ CREATE SEQUENCE tmp_tag_id_seq
...
@@ -34,6 +39,7 @@ CREATE SEQUENCE tmp_tag_id_seq
START
7
START
7
CACHE
1
;
CACHE
1
;
DROP
TABLE
IF
EXISTS
tmp_tags
;
CREATE
TABLE
tmp_tags
CREATE
TABLE
tmp_tags
(
(
tag_id
bigint
NOT
NULL
DEFAULT
nextval
(
'tmp_tag_id_seq'
::
regclass
),
tag_id
bigint
NOT
NULL
DEFAULT
nextval
(
'tmp_tag_id_seq'
::
regclass
),
...
@@ -46,6 +52,7 @@ WITH (
...
@@ -46,6 +52,7 @@ WITH (
INSERT
INTO
tmp_tags
(
tag_label
)
INSERT
INTO
tmp_tags
(
tag_label
)
SELECT
distinct
(
lower
(
tag_label
))
from
tags
;
SELECT
distinct
(
lower
(
tag_label
))
from
tags
;
DROP
TABLE
IF
EXISTS
tag_res
;
CREATE
TABLE
tag_res
CREATE
TABLE
tag_res
(
(
res_id
bigint
NOT
NULL
,
res_id
bigint
NOT
NULL
,
...
@@ -56,10 +63,20 @@ WITH (
...
@@ -56,10 +63,20 @@ WITH (
OIDS
=
FALSE
OIDS
=
FALSE
);
);
DO
$$
BEGIN
BEGIN
ALTER
TABLE
tags
ADD
res_id
bigint
;
EXCEPTION
WHEN
duplicate_column
THEN
RAISE
NOTICE
'column res_id already exists in tags. skipping...'
;
END
;
END
;
$$
;
INSERT
INTO
tag_res
(
res_id
,
tag_id
)
INSERT
INTO
tag_res
(
res_id
,
tag_id
)
SELECT
tags
.
res_id
,
tmp_tags
.
tag_id
FROM
tags
,
tmp_tags
WHERE
tmp_tags
.
tag_label
=
lower
(
tags
.
tag_label
);
SELECT
tags
.
res_id
,
tmp_tags
.
tag_id
FROM
tags
,
tmp_tags
WHERE
tmp_tags
.
tag_label
=
lower
(
tags
.
tag_label
)
AND
tags
.
res_id
IS
NOT
NULL
;
TRUNCATE
TABLE
tags
;
TRUNCATE
TABLE
tags
;
ALTER
TABLE
tags
DROP
CONSTRAINT
IF
EXISTS
tagsjoin_pkey
;
ALTER
TABLE
tags
DROP
CONSTRAINT
IF
EXISTS
tagsjoin_pkey
;
ALTER
TABLE
tags
DROP
COLUMN
IF
EXISTS
res_id
;
ALTER
TABLE
tags
DROP
COLUMN
IF
EXISTS
res_id
;
...
@@ -67,9 +84,10 @@ INSERT INTO tags (tag_label, coll_id, tag_id)
...
@@ -67,9 +84,10 @@ INSERT INTO tags (tag_label, coll_id, tag_id)
SELECT
tag_label
,
'letterbox_coll'
,
tag_id
FROM
tmp_tags
;
SELECT
tag_label
,
'letterbox_coll'
,
tag_id
FROM
tmp_tags
;
DROP
TABLE
tmp_tags
;
DROP
TABLE
IF
EXISTS
tmp_tags
;
DROP
SEQUENCE
IF
EXISTS
tmp_tag_id_seq
;
DROP
SEQUENCE
IF
EXISTS
tmp_tag_id_seq
;
DROP
TABLE
IF
EXISTS
tags_entities
;
CREATE
TABLE
tags_entities
CREATE
TABLE
tags_entities
(
(
tag_id
bigint
,
tag_id
bigint
,
...
...
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