-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: alembic recipe column not altered
* produces error on the ext.alembic.compare_metadata() test on other packages
- Loading branch information
1 parent
ae121bc
commit c8325de
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
invenio_records/alembic/428b919be0ea_alter_column_from_json_to_jsonb_for_version.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,40 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Invenio. | ||
# Copyright (C) 2024 Graz University of Technology. | ||
# | ||
# 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. | ||
|
||
"""Alter column from json to jsonb.""" | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "428b919be0ea" | ||
down_revision = "07fb52561c5c" | ||
branch_labels = () | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
"""Upgrade database.""" | ||
if op._proxy.migration_context.dialect.name == "postgresql": | ||
op.alter_column( | ||
"records_metadata_version", | ||
"json", | ||
type_=sa.dialects.postgresql.JSONB, | ||
postgresql_using="json::text::jsonb", | ||
) | ||
|
||
|
||
def downgrade(): | ||
"""Downgrade database.""" | ||
if op._proxy.migration_context.dialect.name == "postgresql": | ||
op.alter_column( | ||
"records_metadata_version", | ||
"json", | ||
type_=sa.dialects.postgresql.JSON, | ||
postgresql_using="json::text::json", | ||
) |