Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
sispub
openbis
Commits
b5ec1fe4
Commit
b5ec1fe4
authored
15 years ago
by
buczekp
Browse files
Options
Downloads
Patches
Plain Diff
[LMS-1194] migration cd
SVN: 13054
parent
7a573581
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
openbis/source/sql/postgresql/migration/migration-043-044.sql
+52
-0
52 additions, 0 deletions
...bis/source/sql/postgresql/migration/migration-043-044.sql
with
52 additions
and
0 deletions
openbis/source/sql/postgresql/migration/migration-043-044.sql
0 → 100644
+
52
−
0
View file @
b5ec1fe4
-- Migration from 043 to 044
--------------------------------------------------------------------------------------------------
-- Add ordinal and section columns to ETPT tables.
-- 1. Ordinal column is a positive and not null integer to entity type property type tables.
-- Initially ordinal values of property types of one entity type start from 1
-- and increase with increase of ETPT id (so initial order will depend on registration order).
-- Ordinals should be unique inside one ETPT table but because we use bulk update we can't
-- easily create this constraint.
-- 2. Section - string (can be null, don't have to create uniquely named blocks with order)
--------------------------------------------------------------------------------------------------
-- add a common domain
CREATE
DOMAIN
ordinal_int
AS
bigint
CHECK
(
VALUE
>
0
);
ALTER
TABLE
controlled_vocabulary_terms
ALTER
COLUMN
ordinal
TYPE
ORDINAL_INT
;
-- samples
ALTER
TABLE
sample_type_property_types
ADD
COLUMN
section
DESCRIPTION_1000
;
ALTER
TABLE
sample_type_property_types
ADD
COLUMN
ordinal
ORDINAL_INT
;
UPDATE
sample_type_property_types
SET
ordinal
=
(
SELECT
count
(
*
)
FROM
sample_type_property_types
stpt
WHERE
stpt
.
saty_id
=
sample_type_property_types
.
saty_id
AND
stpt
.
id
<=
sample_type_property_types
.
id
);
ALTER
TABLE
sample_type_property_types
ALTER
COLUMN
ordinal
SET
NOT
NULL
;
-- experiments
ALTER
TABLE
experiment_type_property_types
ADD
COLUMN
section
DESCRIPTION_1000
;
ALTER
TABLE
experiment_type_property_types
ADD
COLUMN
ordinal
ORDINAL_INT
;
UPDATE
experiment_type_property_types
SET
ordinal
=
(
SELECT
count
(
*
)
FROM
experiment_type_property_types
etpt
WHERE
etpt
.
exty_id
=
experiment_type_property_types
.
exty_id
AND
etpt
.
id
<=
experiment_type_property_types
.
id
);
ALTER
TABLE
experiment_type_property_types
ALTER
COLUMN
ordinal
SET
NOT
NULL
;
-- data sets
ALTER
TABLE
data_set_type_property_types
ADD
COLUMN
section
DESCRIPTION_1000
;
ALTER
TABLE
data_set_type_property_types
ADD
COLUMN
ordinal
ORDINAL_INT
;
UPDATE
data_set_type_property_types
SET
ordinal
=
(
SELECT
count
(
*
)
FROM
data_set_type_property_types
dstpt
WHERE
dstpt
.
dsty_id
=
data_set_type_property_types
.
dsty_id
AND
dstpt
.
id
<=
data_set_type_property_types
.
id
);
ALTER
TABLE
data_set_type_property_types
ALTER
COLUMN
ordinal
SET
NOT
NULL
;
-- materials
ALTER
TABLE
material_type_property_types
ADD
COLUMN
section
DESCRIPTION_1000
;
ALTER
TABLE
material_type_property_types
ADD
COLUMN
ordinal
ORDINAL_INT
;
UPDATE
material_type_property_types
SET
ordinal
=
(
SELECT
count
(
*
)
FROM
material_type_property_types
mtpt
WHERE
mtpt
.
maty_id
=
material_type_property_types
.
maty_id
AND
mtpt
.
id
<=
material_type_property_types
.
id
);
ALTER
TABLE
material_type_property_types
ALTER
COLUMN
ordinal
SET
NOT
NULL
;
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