8000 migration: create the database migration alembic file by jma · Pull Request #3858 · rero/rero-ils · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

migration: create the database migration alembic file #3858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 94 additions & 0 deletions rero_ils/alembic/c69ea6572971_drop_invoices_tables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# -*- coding: utf-8 -*-
#
# RERO ILS
# Copyright (C) 2024 RERO
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, version 3 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Remove invoices and update the api harvester tables."""

import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = "c69ea6572971"
down_revision = "8d97be2c8ad6"
branch_labels = ()
depends_on = None


def upgrade():
"""Upgrade database."""
op.drop_table("acq_invoice_id")
op.drop_table("acq_invoice_metadata")
op.add_column(
"apiharvester_config",
sa.Column("classname", sa.String(length=255), nullable=False),
)
op.add_column("apiharvester_config", sa.Column("code", sa.Text(), nullable=True))
op.drop_column("apiharvester_config", "comment")
op.drop_column("apiharvester_config", "mimetype")
op.drop_column("apiharvester_config", "size")
op.drop_index("ix_uq_partial_files_object_is_head", table_name="files_object")
# ### end Alembic commands ###


def downgrade():
"""Downgrade database."""
op.create_index(
"ix_uq_partial_files_object_is_head",
"files_object",
["bucket_id", "key"],
unique=False,
)
op.add_column(
"apiharvester_config",
sa.Column("size", sa.INTEGER(), autoincrement=False, nullable=False),
)
op.add_column(
"apiharvester_config",
sa.Column(
"mimetype", sa.VARCHAR(length=255), autoincrement=False, nullable=False
),
)
op.add_column(
"apiharvester_config",
sa.Column("comment", sa.TEXT(), autoincrement=False, nullable=True),
)
op.drop_column("apiharvester_config", "code")
op.drop_column("apiharvester_config", "classname")
op.create_table(
"acq_invoice_metadata",
sa.Column(
"created", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
),
sa.Column(
"updated", postgresql.TIMESTAMP(), autoincrement=False, nullable=False
),
sa.Column("id", postgresql.UUID(), autoincrement=False, nullable=False),
sa.Column(
"json",
postgresql.JSONB(astext_type=sa.Text()),
autoincrement=False,
nullable=True,
),
sa.Column("version_id", sa.INTEGER(), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint("id", name="pk_acq_invoice_metadata"),
)
op.create_table(
"acq_invoice_id",
sa.Column("recid", sa.BIGINT(), autoincrement=True, nullable=False),
sa.PrimaryKeyConstraint("recid", name="pk_acq_invoice_id"),
)
# ### end Alembic commands ###
0