Skip to content
Snippets Groups Projects
Commit d3888e3a authored by Remco Tukker's avatar Remco Tukker
Browse files

make migration script work

parent 6778d93f
No related branches found
No related tags found
1 merge request!1normalization of nrens including datamigration
......@@ -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')
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment