Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
compendium-v2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
geant-swd
compendium-v2
Commits
d3888e3a
Commit
d3888e3a
authored
Apr 12, 2023
by
Remco Tukker
Browse files
Options
Downloads
Patches
Plain Diff
make migration script work
parent
6778d93f
No related branches found
No related tags found
1 merge request
!1
normalization of nrens including datamigration
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
compendium_v2/migrations/versions/2b698bb45c09_normalize_nrens.py
+26
-5
26 additions, 5 deletions
...um_v2/migrations/versions/2b698bb45c09_normalize_nrens.py
with
26 additions
and
5 deletions
compendium_v2/migrations/versions/2b698bb45c09_normalize_nrens.py
+
26
−
5
View file @
d3888e3a
...
...
@@ -25,6 +25,9 @@ def upgrade():
sa
.
PrimaryKeyConstraint
(
'
id
'
,
name
=
op
.
f
(
'
pk_nren
'
))
)
# TODO before merge: check if this list is ok, its from COMP-118 with UNINETT and LANET added because otherwise
# I wouldn't know how to map them
# TODO also check if the mapping of names in the 3 data migrations below are OK
op
.
execute
(
"
INSERT INTO nren (name) VALUES
"
"
(
'
AAF - Australian Access Federation
'
),
"
...
...
@@ -101,6 +104,7 @@ def upgrade():
"
(
'
KREN
'
),
"
"
(
'
KRENA-AKNET
'
),
"
"
(
'
KREONET
'
),
"
"
(
'
LANET
'
),
"
"
(
'
LAT
'
),
"
"
(
'
LEARN
'
),
"
"
(
'
LERNET
'
),
"
...
...
@@ -179,6 +183,7 @@ def upgrade():
"
(
'
TuRENA
'
),
"
"
(
'
UARNet
'
),
"
"
(
'
ULAKBIM
'
),
"
"
(
'
UNINETT
'
),
"
"
(
'
UNITEC
'
),
"
"
(
'
UNREN
'
),
"
"
(
'
UoM/RicerkaNet
'
),
"
...
...
@@ -191,22 +196,38 @@ def upgrade():
op
.
add_column
(
'
budgets
'
,
sa
.
Column
(
'
nren_id
'
,
sa
.
Integer
()))
op
.
execute
(
"
UPDATE budgets SET nren_id = nren.id FROM nren
"
"
WHERE budgets.nren = nren.name
"
"
OR (budgets.nren =
'
bla_alias
'
AND nren.name =
'
bla
'
)
"
# TODO etc
"
WHERE (UPPER(budgets.nren) = UPPER(nren.name))
"
"
OR (budgets.nren =
'
ASNET
'
AND nren.name =
'
ASNET-AM
'
)
"
"
OR (budgets.nren =
'
KIFU (NIIF)
'
AND nren.name =
'
KIFU
'
)
"
"
OR (budgets.nren =
'
SURFnet
'
AND nren.name =
'
SURF
'
)
"
"
OR (budgets.nren =
'
UoM
'
AND nren.name =
'
UoM/RicerkaNet
'
)
"
)
op
.
alter_column
(
'
budgets
'
,
'
nren_id
'
,
nullable
=
False
)
op
.
create_foreign_key
(
op
.
f
(
'
fk_budgets_nren_id_nren
'
),
'
budgets
'
,
'
nren
'
,
[
'
nren_id
'
],
[
'
id
'
])
op
.
drop_column
(
'
budgets
'
,
'
nren
'
)
op
.
add_column
(
'
funding_source
'
,
sa
.
Column
(
'
nren_id
'
,
sa
.
Integer
()))
# TODO
op
.
execute
(
"
UPDATE funding_source SET nren_id = nren.id FROM nren
"
"
WHERE (UPPER(funding_source.nren) = UPPER(nren.name))
"
"
OR (funding_source.nren =
'
ASNET
'
AND nren.name =
'
ASNET-AM
'
)
"
"
OR (funding_source.nren =
'
KIFU (NIIF)
'
AND nren.name =
'
KIFU
'
)
"
"
OR (funding_source.nren =
'
SURFnet
'
AND nren.name =
'
SURF
'
)
"
"
OR (funding_source.nren =
'
UoM
'
AND nren.name =
'
UoM/RicerkaNet
'
)
"
)
op
.
alter_column
(
'
funding_source
'
,
'
nren_id
'
,
nullable
=
False
)
op
.
create_foreign_key
(
op
.
f
(
'
fk_funding_source_nren_id_nren
'
),
'
funding_source
'
,
'
nren
'
,
[
'
nren_id
'
],
[
'
id
'
])
op
.
drop_column
(
'
funding_source
'
,
'
nren
'
)
op
.
add_column
(
'
charging_structure
'
,
sa
.
Column
(
'
nren_id
'
,
sa
.
Integer
()))
# TODO
op
.
execute
(
"
UPDATE charging_structure SET nren_id = nren.id FROM nren
"
"
WHERE (UPPER(charging_structure.nren) = UPPER(nren.name))
"
"
OR (charging_structure.nren =
'
ASNET
'
AND nren.name =
'
ASNET-AM
'
)
"
"
OR (charging_structure.nren =
'
KIFU (NIIF)
'
AND nren.name =
'
KIFU
'
)
"
"
OR (charging_structure.nren =
'
SURFnet
'
AND nren.name =
'
SURF
'
)
"
"
OR (charging_structure.nren =
'
UoM
'
AND nren.name =
'
UoM/RicerkaNet
'
)
"
)
op
.
alter_column
(
'
charging_structure
'
,
'
nren_id
'
,
nullable
=
False
)
op
.
create_foreign_key
(
op
.
f
(
'
fk_charging_structure_nren_id_nren
'
),
'
charging_structure
'
,
'
nren
'
,
[
'
nren_id
'
],
[
'
id
'
])
op
.
drop_column
(
'
charging_structure
'
,
'
nren
'
)
...
...
...
...
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
sign in
to comment