-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added migration recipe * closes inveniosoftware/invenio-app-rdm#2186
- Loading branch information
Showing
2 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
invenio_access/alembic/842a62b56e60_change_fk_accountsrole_to_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,71 @@ | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2016-2018 CERN. | ||
# | ||
# Invenio is free software; you can redistribute it and/or modify it | ||
# under the terms of the MIT License; see LICENSE file for more details. | ||
|
||
"""Change FK AccountsRole to string.""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "842a62b56e60" | ||
down_revision = "04480be1593e" | ||
branch_labels = () | ||
depends_on = "8f11b75e0995" | ||
|
||
|
||
def upgrade(): | ||
"""Upgrade database.""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
# op.drop_index("ix_uq_partial_files_object_is_head", table_name="files_object") | ||
# ### end Alembic commands ### | ||
|
||
#op.drop_constraint( | ||
# "fk_access_actionsroles_role_id_accounts_role", | ||
# "access_actionsroles", | ||
# type_="foreignkey", | ||
#) | ||
|
||
op.alter_column( | ||
"access_actionsroles", | ||
"role_id", | ||
existing_type=sa.Integer, | ||
type_=sa.String(80), | ||
postgresql_using="role_id::integer", | ||
) | ||
#op.create_foreign_key( | ||
# op.f("fk_access_actionsroles_role_id_accounts_role"), | ||
# "access_actionsroles", | ||
# "accounts_role", | ||
# ["role_id"], | ||
# ["id"], | ||
# ondelete="CASCADE", | ||
#) | ||
|
||
|
||
def downgrade(): | ||
"""Downgrade database.""" | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint( | ||
"fk_access_actionsroles_role_id_accounts_role", | ||
"access_actionsroles", | ||
type_="foreignkey", | ||
) | ||
op.alter_column( | ||
"access_actionsroles", | ||
"role_id", | ||
existing_type=sa.String(80), | ||
type_=sa.Integer, | ||
postgresql_using="role_id::integer", | ||
) | ||
op.create_foreign_key( | ||
op.f("fk_access_actionsroles_role_id_accounts_role"), | ||
"access_actionsroles", | ||
"accounts_role", | ||
["role_id"], | ||
["id"], | ||
ondelete="CASCADE", | ||
) |
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