-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove explicit definition of
type_string
in Group
construction
Since the group type strings are now based on the entry point names, the existing group type strings in the database have to be migrated: * `user` -> `core.group` * `data.upf.family` -> `core.upf` * `auto.import` -> `core.import` * `auto.run` -> `core.run`
- Loading branch information
Showing
22 changed files
with
285 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
aiida/backends/djsite/db/migrations/0044_dbgroup_type_string.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# -*- coding: utf-8 -*- | ||
########################################################################### | ||
# Copyright (c), The AiiDA team. All rights reserved. # | ||
# This file is part of the AiiDA code. # | ||
# # | ||
# The code is hosted on GitHub at https://github.com/aiidateam/aiida-core # | ||
# For further information on the license, see the LICENSE.txt file # | ||
# For further information please visit http://www.aiida.net # | ||
########################################################################### | ||
# pylint: disable=invalid-name,too-few-public-methods | ||
"""Migration after the `Group` class became pluginnable and so the group `type_string` changed.""" | ||
|
||
# pylint: disable=no-name-in-module,import-error | ||
from django.db import migrations | ||
from aiida.backends.djsite.db.migrations import upgrade_schema_version | ||
|
||
REVISION = '1.0.44' | ||
DOWN_REVISION = '1.0.43' | ||
|
||
forward_sql = [ | ||
"""UPDATE db_dbgroup SET type_string = 'core.group' WHERE type_string = 'user';""", | ||
"""UPDATE db_dbgroup SET type_string = 'core.upf' WHERE type_string = 'data.upf';""", | ||
"""UPDATE db_dbgroup SET type_string = 'core.import' WHERE type_string = 'auto.import';""", | ||
"""UPDATE db_dbgroup SET type_string = 'core.run' WHERE type_string = 'auto.run';""", | ||
] | ||
|
||
reverse_sql = [ | ||
"""UPDATE db_dbgroup SET type_string = 'user' WHERE type_string = 'core.group';""", | ||
"""UPDATE db_dbgroup SET type_string = 'data.upf' WHERE type_string = 'core.upf';""", | ||
"""UPDATE db_dbgroup SET type_string = 'auto.import' WHERE type_string = 'core.import';""", | ||
"""UPDATE db_dbgroup SET type_string = 'auto.run' WHERE type_string = 'core.run';""", | ||
] | ||
|
||
|
||
class Migration(migrations.Migration): | ||
"""Migration after the update of group `type_string`""" | ||
dependencies = [ | ||
('db', '0043_default_link_label'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL(sql='\n'.join(forward_sql), reverse_sql='\n'.join(reverse_sql)), | ||
upgrade_schema_version(REVISION, DOWN_REVISION), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
aiida/backends/sqlalchemy/migrations/versions/bf591f31dd12_dbgroup_type_string.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Migration after the `Group` class became pluginnable and so the group `type_string` changed. | ||
Revision ID: bf591f31dd12 | ||
Revises: 118349c10896 | ||
Create Date: 2020-03-31 10:00:52.609146 | ||
""" | ||
# pylint: disable=no-name-in-module,import-error,invalid-name,no-member | ||
from alembic import op | ||
from sqlalchemy.sql import text | ||
|
||
forward_sql = [ | ||
"""UPDATE db_dbgroup SET type_string = 'core.group' WHERE type_string = 'user';""", | ||
"""UPDATE db_dbgroup SET type_string = 'core.upf' WHERE type_string = 'data.upf';""", | ||
"""UPDATE db_dbgroup SET type_string = 'core.import' WHERE type_string = 'auto.import';""", | ||
"""UPDATE db_dbgroup SET type_string = 'core.run' WHERE type_string = 'auto.run';""", | ||
] | ||
|
||
reverse_sql = [ | ||
"""UPDATE db_dbgroup SET type_string = 'user' WHERE type_string = 'core.group';""", | ||
"""UPDATE db_dbgroup SET type_string = 'data.upf' WHERE type_string = 'core.upf'';""", | ||
"""UPDATE db_dbgroup SET type_string = 'auto.import' WHERE type_string = 'core.import';""", | ||
"""UPDATE db_dbgroup SET type_string = 'auto.run' WHERE type_string = 'core.run';""", | ||
] | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'bf591f31dd12' | ||
down_revision = '118349c10896' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Migrations for the upgrade.""" | ||
conn = op.get_bind() | ||
statement = text('\n'.join(forward_sql)) | ||
conn.execute(statement) | ||
|
||
|
||
def downgrade(): | ||
"""Migrations for the downgrade.""" | ||
conn = op.get_bind() | ||
statement = text('\n'.join(reverse_sql)) | ||
conn.execute(statement) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.