diff --git a/modules/invenio-accounts/invenio_accounts/alembic/b5c2d8a5bf90_create_invenio_accounts_branch.py b/modules/invenio-accounts/invenio_accounts/alembic/b5c2d8a5bf90_create_invenio_accounts_branch.py deleted file mode 100644 index b6ee682824..0000000000 --- a/modules/invenio-accounts/invenio_accounts/alembic/b5c2d8a5bf90_create_invenio_accounts_branch.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# 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. - -"""Create invenio_accounts branch""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'b5c2d8a5bf90' -down_revision = 'e12419831262' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - with op.batch_alter_table('accounts_user_session_activity') as batch_op: - batch_op.add_column( - sa.Column('orgniazation_name', sa.String(255), nullable=True) - ) - - -def downgrade(): - """Downgrade database.""" - with op.batch_alter_table('accounts_user_session_activity') as batch_op: - batch_op.drop_column('orgniazation_name') diff --git a/modules/invenio-files-rest/invenio_files_rest/alembic/8644b32a3eec_add_column_files_location.py b/modules/invenio-files-rest/invenio_files_rest/alembic/8644b32a3eec_add_column_files_location.py deleted file mode 100644 index ec4c18fa48..0000000000 --- a/modules/invenio-files-rest/invenio_files_rest/alembic/8644b32a3eec_add_column_files_location.py +++ /dev/null @@ -1,35 +0,0 @@ -# -# 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. - -"""add_column_files_location""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '8644b32a3eec' -down_revision = '8ae99b034410' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.add_column('files_location', sa.Column('s3_default_block_size', sa.BigInteger(), nullable=True)) - op.add_column('files_location', sa.Column('s3_maximum_number_of_parts', sa.BigInteger(), nullable=True)) - op.add_column('files_location', sa.Column('s3_region_name', sa.String(length=128), nullable=True)) - op.add_column('files_location', sa.Column('s3_signature_version', sa.String(length=20), nullable=True)) - op.add_column('files_location', sa.Column('s3_url_expiration', sa.BigInteger(), nullable=True)) - -def downgrade(): - """Downgrade database.""" - op.drop_column('files_location', 's3_default_block_size') - op.drop_column('files_location', 's3_maximum_number_of_parts') - op.drop_column('files_location', 's3_region_name') - op.drop_column('files_location', 's3_signature_version') - op.drop_column('files_location', 's3_url_expiration') diff --git a/modules/invenio-mail/invenio_mail/alembic/b1495e98969b_create_mailtemplateusers.py b/modules/invenio-mail/invenio_mail/alembic/b1495e98969b_create_mailtemplateusers.py deleted file mode 100755 index c7f2977684..0000000000 --- a/modules/invenio-mail/invenio_mail/alembic/b1495e98969b_create_mailtemplateusers.py +++ /dev/null @@ -1,37 +0,0 @@ -# -# 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. - -"""Create MailTemplateUsers.""" - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -from invenio_mail.models import MailType - -# revision identifiers, used by Alembic. -revision = 'b1495e98969b' -down_revision = 'ddbb24276fdc' -branch_labels = () -depends_on = None - -def upgrade(): - """Upgrade database.""" - op.create_table( - 'mail_template_users', - sa.Column('created', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), - sa.Column('updated', sa.TIMESTAMP(timezone=True), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), - sa.Column('template_id', sa.Integer, sa.ForeignKey('mail_templates.id', ondelete='CASCADE'), primary_key=True), - sa.Column('user_id', sa.Integer, sa.ForeignKey('accounts_user.id', ondelete='CASCADE'), primary_key=True), - sa.Column('mail_type', sa.Enum(MailType), primary_key=True, nullable=False), - ) - -def downgrade(): - """Downgrade database.""" - op.drop_table('mail_template_users') - mail_type_enum = postgresql.ENUM('recipient', 'cc', 'bcc', name='mailtype') - mail_type_enum.drop(op.get_bind()) diff --git a/modules/invenio-mail/invenio_mail/alembic/ddbb24276fdc_create_mail_templates_table.py b/modules/invenio-mail/invenio_mail/alembic/ddbb24276fdc_create_mail_templates_table.py deleted file mode 100644 index a651f8413d..0000000000 --- a/modules/invenio-mail/invenio_mail/alembic/ddbb24276fdc_create_mail_templates_table.py +++ /dev/null @@ -1,49 +0,0 @@ -# -# 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. - -"""Create mail_templates table""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'ddbb24276fdc' -down_revision = 'c509a18eb6a0' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.create_table( - 'mail_template_genres', - sa.Column('id', sa.Integer, primary_key=True, autoincrement=True), - sa.Column('name', sa.String(255), nullable=False, server_default=''), - ) - - op.create_table( - 'mail_templates', - sa.Column('id', sa.Integer, primary_key=True, autoincrement=True), - sa.Column('mail_subject', sa.String(255), nullable=True), - sa.Column('mail_body', sa.Text, nullable=True), - sa.Column('default_mail', sa.Boolean, nullable=True), - sa.Column('genre_id', sa.Integer, nullable=False, server_default='3'), - sa.ForeignKeyConstraint( - ['genre_id'], ['mail_template_genres.id'], - name='fk_mail_templates_genre_id_mail_template_genres', - ondelete='RESTRICT', - onupdate='CASCADE' - ) - ) - - -def downgrade(): - """Downgrade database.""" - op.drop_table('mail_templates') - op.drop_table('mail_template_genres') - diff --git a/modules/weko-accounts/setup.py b/modules/weko-accounts/setup.py index 3079aa2ff3..78cf61109e 100644 --- a/modules/weko-accounts/setup.py +++ b/modules/weko-accounts/setup.py @@ -111,6 +111,12 @@ 'weko_accounts_suggest_js = weko_accounts.bundles:suggest_js', 'weko_accounts_shibuser_css = weko_accounts.bundles:shibuser_css', ], + 'invenio_db.models': [ + 'weko_accounts = weko_accounts.models', + ], + 'invenio_db.alembic': [ + 'weko_accounts = weko_accounts:alembic', + ], }, extras_require=extras_require, install_requires=install_requires, diff --git a/modules/invenio-resourcesyncclient/invenio_resourcesyncclient/alembic/d758395731f2_initial.py b/modules/weko-accounts/weko_accounts/alembic/a8e506eb5e32_create_weko_accounts_branch.py similarity index 82% rename from modules/invenio-resourcesyncclient/invenio_resourcesyncclient/alembic/d758395731f2_initial.py rename to modules/weko-accounts/weko_accounts/alembic/a8e506eb5e32_create_weko_accounts_branch.py index 128f42fcd9..5623ae5925 100644 --- a/modules/invenio-resourcesyncclient/invenio_resourcesyncclient/alembic/d758395731f2_initial.py +++ b/modules/weko-accounts/weko_accounts/alembic/a8e506eb5e32_create_weko_accounts_branch.py @@ -5,16 +5,16 @@ # 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. -"""initial""" +"""Create weko_accounts branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'd758395731f2' +revision = 'a8e506eb5e32' down_revision = None -branch_labels = ('invenio_resourcesyncclient',) +branch_labels = ('weko_accounts',) depends_on = None diff --git a/modules/weko-admin/weko_admin/alembic/45bf6e63b05a_initial.py b/modules/weko-admin/weko_admin/alembic/06db73ed4026_create_weko_admin_branch.py similarity index 89% rename from modules/weko-admin/weko_admin/alembic/45bf6e63b05a_initial.py rename to modules/weko-admin/weko_admin/alembic/06db73ed4026_create_weko_admin_branch.py index f3942549fc..dd3293538c 100644 --- a/modules/weko-admin/weko_admin/alembic/45bf6e63b05a_initial.py +++ b/modules/weko-admin/weko_admin/alembic/06db73ed4026_create_weko_admin_branch.py @@ -5,14 +5,14 @@ # 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. -"""initial""" +"""Create weko_admin branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '45bf6e63b05a' +revision = '06db73ed4026' down_revision = None branch_labels = ('weko_admin',) depends_on = None diff --git a/modules/weko-admin/weko_admin/alembic/7dc0b1ab5631_add_columns.py b/modules/weko-admin/weko_admin/alembic/7dc0b1ab5631_add_columns.py deleted file mode 100644 index e703062ba4..0000000000 --- a/modules/weko-admin/weko_admin/alembic/7dc0b1ab5631_add_columns.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# 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. - -"""Add columns""" - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '7dc0b1ab5631' -down_revision = 'b4d2f3c0734b' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.add_column('feedback_email_setting', sa.Column('repository_id', sa.String(length=100), nullable=False, server_default='Root Index')) - op.add_column('feedback_mail_history', sa.Column('repository_id', sa.String(length=100), nullable=False, server_default='Root Index')) - op.add_column('stats_email_address', sa.Column('repository_id', sa.String(length=100), nullable=True, server_default='Root Index')) - - -def downgrade(): - """Downgrade database.""" - op.drop_column('stats_email_address', 'repository_id') - op.drop_column('feedback_mail_history', 'repository_id') - op.drop_column('feedback_email_setting', 'repository_id') - diff --git a/modules/weko-admin/weko_admin/alembic/b4d2f3c0734b_update.py b/modules/weko-admin/weko_admin/alembic/b4d2f3c0734b_update.py deleted file mode 100644 index a6623f5840..0000000000 --- a/modules/weko-admin/weko_admin/alembic/b4d2f3c0734b_update.py +++ /dev/null @@ -1,38 +0,0 @@ -# -# 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. - -"""update""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'b4d2f3c0734b' -down_revision = '45bf6e63b05a' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.create_unique_constraint(op.f('uq_admin_lang_settings_lang_code'), 'admin_lang_settings', ['lang_code']) - op.create_unique_constraint(op.f('uq_api_certificate_api_code'), 'api_certificate', ['api_code']) - op.create_unique_constraint(op.f('uq_billing_permission_user_id'), 'billing_permission', ['user_id']) - op.create_unique_constraint(op.f('uq_doi_identifier_id'), 'doi_identifier', ['id']) - op.create_unique_constraint(op.f('uq_stats_report_target_target_id'), 'stats_report_target', ['target_id']) - op.create_unique_constraint(op.f('uq_stats_report_unit_unit_id'), 'stats_report_unit', ['unit_id']) - - -def downgrade(): - """Downgrade database.""" - op.drop_constraint(op.f('uq_stats_report_unit_unit_id'), 'stats_report_unit', type_='unique') - op.drop_constraint(op.f('uq_stats_report_target_target_id'), 'stats_report_target', type_='unique') - op.drop_constraint(op.f('uq_doi_identifier_id'), 'doi_identifier', type_='unique') - op.drop_constraint(op.f('uq_billing_permission_user_id'), 'billing_permission', type_='unique') - op.drop_constraint(op.f('uq_api_certificate_api_code'), 'api_certificate', type_='unique') - op.drop_constraint(op.f('uq_admin_lang_settings_lang_code'), 'admin_lang_settings', type_='unique') diff --git a/modules/weko-authors/weko_authors/alembic/1e377b157a5d_add_repository_id_column.py b/modules/weko-authors/weko_authors/alembic/1e377b157a5d_add_repository_id_column.py deleted file mode 100644 index 2172a57e81..0000000000 --- a/modules/weko-authors/weko_authors/alembic/1e377b157a5d_add_repository_id_column.py +++ /dev/null @@ -1,79 +0,0 @@ -# -# 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. - -"""Add repository_id column""" - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql -from sqlalchemy_utils import JSONType - -# revision identifiers, used by Alembic. -revision = '1e377b157a5d' -down_revision = 'e471f74f4f27' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.add_column('authors', - sa.Column( - 'repository_id', - sa.JSON().with_variant( - postgresql.JSONB(none_as_null=True), - 'postgresql', - ).with_variant( - JSONType(), - 'sqlite', - ).with_variant( - JSONType(), - 'mysql', - ), - nullable=True - ) - ) - op.add_column('authors_affiliation_settings', - sa.Column( - 'repository_id', - sa.JSON().with_variant( - postgresql.JSONB(none_as_null=True), - 'postgresql', - ).with_variant( - JSONType(), - 'sqlite', - ).with_variant( - JSONType(), - 'mysql', - ), - nullable=True - ) - ) - op.add_column('authors_prefix_settings', - sa.Column( - 'repository_id', - sa.JSON().with_variant( - postgresql.JSONB(none_as_null=True), - 'postgresql', - ).with_variant( - JSONType(), - 'sqlite', - ).with_variant( - JSONType(), - 'mysql', - ), - nullable=True - ) - ) - - -def downgrade(): - """Downgrade database.""" - op.drop_column('authors_prefix_settings', 'repository_id') - op.drop_column('authors_affiliation_settings', 'repository_id') - op.drop_column('authors', 'repository_id') - \ No newline at end of file diff --git a/modules/weko-authors/weko_authors/alembic/5872b2d73941_update.py b/modules/weko-authors/weko_authors/alembic/5872b2d73941_update.py deleted file mode 100644 index fabe523e15..0000000000 --- a/modules/weko-authors/weko_authors/alembic/5872b2d73941_update.py +++ /dev/null @@ -1,30 +0,0 @@ -# -# 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. - -"""update""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '5872b2d73941' -down_revision = '4aadad0a1ff7' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.create_unique_constraint(op.f('uq_authors_id'), 'authors', ['id']) - op.create_unique_constraint(op.f('uq_authors_prefix_settings_id'), 'authors_prefix_settings', ['id']) - - -def downgrade(): - """Downgrade database.""" - op.drop_constraint(op.f('uq_authors_prefix_settings_id'), 'authors_prefix_settings', type_='unique') - op.drop_constraint(op.f('uq_authors_id'), 'authors', type_='unique') diff --git a/modules/weko-authors/weko_authors/alembic/b2ce1889616c_create_author_community_relation_tables.py b/modules/weko-authors/weko_authors/alembic/b2ce1889616c_create_author_community_relation_tables.py deleted file mode 100644 index 6e79020ecf..0000000000 --- a/modules/weko-authors/weko_authors/alembic/b2ce1889616c_create_author_community_relation_tables.py +++ /dev/null @@ -1,66 +0,0 @@ -# -# 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. - -"""Create author community relation tables.""" - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'b2ce1889616c' -down_revision = '1e377b157a5d' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('author_affiliation_community_relations', - sa.Column('created', sa.DateTime(), nullable=False), - sa.Column('updated', sa.DateTime(), nullable=False), - sa.Column('affiliation_id', sa.BigInteger(), nullable=False), - sa.Column('community_id', sa.String(length=100), nullable=False), - sa.ForeignKeyConstraint(['affiliation_id'], ['authors_affiliation_settings.id'], name=op.f('fk_author_affiliation_community_relations_affiliation_id_authors_affiliation_settings'), ondelete='CASCADE'), - sa.ForeignKeyConstraint(['community_id'], ['communities_community.id'], name=op.f('fk_author_affiliation_community_relations_community_id_communities_community'), ondelete='CASCADE'), - sa.PrimaryKeyConstraint('affiliation_id', 'community_id', name=op.f('pk_author_affiliation_community_relations')) - ) - op.create_table('author_community_relations', - sa.Column('created', sa.DateTime(), nullable=False), - sa.Column('updated', sa.DateTime(), nullable=False), - sa.Column('author_id', sa.BigInteger(), nullable=False), - sa.Column('community_id', sa.String(length=100), nullable=False), - sa.ForeignKeyConstraint(['author_id'], ['authors.id'], name=op.f('fk_author_community_relations_author_id_authors'), ondelete='CASCADE'), - sa.ForeignKeyConstraint(['community_id'], ['communities_community.id'], name=op.f('fk_author_community_relations_community_id_communities_community'), ondelete='CASCADE'), - sa.PrimaryKeyConstraint('author_id', 'community_id', name=op.f('pk_author_community_relations')) - ) - op.create_table('author_prefix_community_relations', - sa.Column('created', sa.DateTime(), nullable=False), - sa.Column('updated', sa.DateTime(), nullable=False), - sa.Column('prefix_id', sa.BigInteger(), nullable=False), - sa.Column('community_id', sa.String(length=100), nullable=False), - sa.ForeignKeyConstraint(['community_id'], ['communities_community.id'], name=op.f('fk_author_prefix_community_relations_community_id_communities_community'), ondelete='CASCADE'), - sa.ForeignKeyConstraint(['prefix_id'], ['authors_prefix_settings.id'], name=op.f('fk_author_prefix_community_relations_prefix_id_authors_prefix_settings'), ondelete='CASCADE'), - sa.PrimaryKeyConstraint('prefix_id', 'community_id', name=op.f('pk_author_prefix_community_relations')) - ) - op.drop_column('authors', 'repository_id') - op.drop_column('authors_affiliation_settings', 'repository_id') - op.drop_column('authors_prefix_settings', 'repository_id') - # ### end Alembic commands ### - - -def downgrade(): - """Downgrade database.""" - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('authors_prefix_settings', sa.Column('repository_id', postgresql.JSONB(astext_type=sa.Text()), autoincrement=False, nullable=True)) - op.add_column('authors_affiliation_settings', sa.Column('repository_id', postgresql.JSONB(astext_type=sa.Text()), autoincrement=False, nullable=True)) - op.add_column('authors', sa.Column('repository_id', postgresql.JSONB(astext_type=sa.Text()), autoincrement=False, nullable=True)) - op.drop_table('author_prefix_community_relations') - op.drop_table('author_community_relations') - op.drop_table('author_affiliation_community_relations') - # ### end Alembic commands ### diff --git a/modules/weko-authors/weko_authors/alembic/4aadad0a1ff7_initial.py b/modules/weko-authors/weko_authors/alembic/cb9079814bd2_create_weko_authors_branch.py similarity index 89% rename from modules/weko-authors/weko_authors/alembic/4aadad0a1ff7_initial.py rename to modules/weko-authors/weko_authors/alembic/cb9079814bd2_create_weko_authors_branch.py index 651a1f4264..00ed60e5c2 100644 --- a/modules/weko-authors/weko_authors/alembic/4aadad0a1ff7_initial.py +++ b/modules/weko-authors/weko_authors/alembic/cb9079814bd2_create_weko_authors_branch.py @@ -5,14 +5,14 @@ # 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. -"""initial""" +"""Create weko_authors branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '4aadad0a1ff7' +revision = 'cb9079814bd2' down_revision = None branch_labels = ('weko_authors',) depends_on = None diff --git a/modules/weko-authors/weko_authors/alembic/e471f74f4f27_add_affiliation.py b/modules/weko-authors/weko_authors/alembic/e471f74f4f27_add_affiliation.py deleted file mode 100644 index 1becfbb465..0000000000 --- a/modules/weko-authors/weko_authors/alembic/e471f74f4f27_add_affiliation.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# 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. - -"""add affiliation""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'e471f74f4f27' -down_revision = '5872b2d73941' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('authors_affiliation_settings', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.Text(), nullable=False), - sa.Column('scheme', sa.Text(), nullable=True), - sa.Column('url', sa.Text(), nullable=True), - sa.Column('created', sa.DateTime(), nullable=False), - sa.Column('updated', sa.DateTime(), nullable=False), - sa.PrimaryKeyConstraint('id', name=op.f('pk_authors_affiliation_settings')), - sa.UniqueConstraint('id', name=op.f('uq_authors_affiliation_settings_id')), - sa.UniqueConstraint('scheme', name=op.f('uq_authors_affiliation_settings_scheme')) - ) - # ### end Alembic commands ### - - -def downgrade(): - """Downgrade database.""" - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('authors_affiliation_settings') - # ### end Alembic commands ### diff --git a/modules/weko-gridlayout/weko_gridlayout/alembic/c9ec4c2b278a_initial.py b/modules/weko-gridlayout/weko_gridlayout/alembic/f8c7626d048b_create_weko_gridlayout_branch.py similarity index 88% rename from modules/weko-gridlayout/weko_gridlayout/alembic/c9ec4c2b278a_initial.py rename to modules/weko-gridlayout/weko_gridlayout/alembic/f8c7626d048b_create_weko_gridlayout_branch.py index 8369b8ef28..8fe177f54c 100644 --- a/modules/weko-gridlayout/weko_gridlayout/alembic/c9ec4c2b278a_initial.py +++ b/modules/weko-gridlayout/weko_gridlayout/alembic/f8c7626d048b_create_weko_gridlayout_branch.py @@ -5,14 +5,14 @@ # 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. -"""initial""" +"""Create weko_gridlayout branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'c9ec4c2b278a' +revision = 'f8c7626d048b' down_revision = None branch_labels = ('weko_gridlayout',) depends_on = None diff --git a/modules/weko-groups/weko_groups/alembic/f887f008a2d0_initial.py b/modules/weko-groups/weko_groups/alembic/3686c3a62594_create_weko_groups_branch.py similarity index 89% rename from modules/weko-groups/weko_groups/alembic/f887f008a2d0_initial.py rename to modules/weko-groups/weko_groups/alembic/3686c3a62594_create_weko_groups_branch.py index 560eb1e98f..49b69b5128 100644 --- a/modules/weko-groups/weko_groups/alembic/f887f008a2d0_initial.py +++ b/modules/weko-groups/weko_groups/alembic/3686c3a62594_create_weko_groups_branch.py @@ -5,14 +5,14 @@ # 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. -"""initial""" +"""Create weko_groups branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'f887f008a2d0' +revision = '3686c3a62594' down_revision = None branch_labels = ('weko_groups',) depends_on = None diff --git a/modules/weko-index-tree/weko_index_tree/alembic/0d2fe6767b9c_initial.py b/modules/weko-index-tree/weko_index_tree/alembic/70a7e1c4809b_create_weko_index_tree_branch.py similarity index 88% rename from modules/weko-index-tree/weko_index_tree/alembic/0d2fe6767b9c_initial.py rename to modules/weko-index-tree/weko_index_tree/alembic/70a7e1c4809b_create_weko_index_tree_branch.py index 863e8f802b..e5b4555a2e 100644 --- a/modules/weko-index-tree/weko_index_tree/alembic/0d2fe6767b9c_initial.py +++ b/modules/weko-index-tree/weko_index_tree/alembic/70a7e1c4809b_create_weko_index_tree_branch.py @@ -5,14 +5,14 @@ # 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. -"""initial""" +"""Create weko_index_tree branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '0d2fe6767b9c' +revision = '70a7e1c4809b' down_revision = None branch_labels = ('weko_index_tree',) depends_on = None diff --git a/modules/weko-index-tree/weko_index_tree/alembic/b21aaf04d802_update.py b/modules/weko-index-tree/weko_index_tree/alembic/b21aaf04d802_update.py deleted file mode 100644 index 5813dc7092..0000000000 --- a/modules/weko-index-tree/weko_index_tree/alembic/b21aaf04d802_update.py +++ /dev/null @@ -1,29 +0,0 @@ -# -# 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. - -"""update""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'b21aaf04d802' -down_revision = '0d2fe6767b9c' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.create_unique_constraint(op.f('uq_index_id'), 'index', ['id']) - - -def downgrade(): - """Downgrade database.""" - op.drop_constraint(op.f('uq_index_id'), 'index', type_='unique') - rm \ No newline at end of file diff --git a/modules/weko-index-tree/weko_index_tree/alembic/efd70c593f4b_update_index.py b/modules/weko-index-tree/weko_index_tree/alembic/efd70c593f4b_update_index.py deleted file mode 100644 index 7470c19904..0000000000 --- a/modules/weko-index-tree/weko_index_tree/alembic/efd70c593f4b_update_index.py +++ /dev/null @@ -1,29 +0,0 @@ -# -# 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. - -"""update index""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'efd70c593f4b' -down_revision = 'b21aaf04d802' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.add_column('index', sa.Column('index_url', sa.Text(), nullable=True)) - op.add_column('index', sa.Column('cnri', sa.Text(), nullable=True)) - -def downgrade(): - """Downgrade database.""" - op.drop_column('index', 'index_url') - op.drop_column('index', 'cnri') diff --git a/modules/weko-indextree-journal/weko_indextree_journal/alembic/ad3fd78b0175_update.py b/modules/weko-indextree-journal/weko_indextree_journal/alembic/ad3fd78b0175_update.py deleted file mode 100644 index 4e417fb6df..0000000000 --- a/modules/weko-indextree-journal/weko_indextree_journal/alembic/ad3fd78b0175_update.py +++ /dev/null @@ -1,34 +0,0 @@ -# -# 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. - -"""update.""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'ad3fd78b0175' -down_revision = '9d6b2ebed7eb' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - # ### commands auto generated by Alembic - please adjust! ### - op.create_unique_constraint(op.f('uq_journal_id'), 'journal', ['id']) - op.create_unique_constraint(op.f('uq_journal_export_processing_id'), 'journal_export_processing', ['id']) - # ### end Alembic commands ### - - -def downgrade(): - """Downgrade database.""" - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(op.f('uq_journal_export_processing_id'), 'journal_export_processing', type_='unique') - op.drop_constraint(op.f('uq_journal_id'), 'journal', type_='unique') - # ### end Alembic commands ### diff --git a/modules/weko-indextree-journal/weko_indextree_journal/alembic/b6cb93e7e896_add_column.py b/modules/weko-indextree-journal/weko_indextree_journal/alembic/b6cb93e7e896_add_column.py deleted file mode 100644 index 4bb86b890a..0000000000 --- a/modules/weko-indextree-journal/weko_indextree_journal/alembic/b6cb93e7e896_add_column.py +++ /dev/null @@ -1,29 +0,0 @@ -# -# 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. - -"""add_column""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'b6cb93e7e896' -down_revision = 'ad3fd78b0175' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.add_column('journal', sa.Column('abstract', sa.Text(), nullable=True)) - op.add_column('journal', sa.Column('code_issnl', sa.Text(), nullable=True)) - -def downgrade(): - """Downgrade database.""" - op.drop_column('journal', 'abstract') - op.drop_column('journal', 'code_issnl') diff --git a/modules/weko-indextree-journal/weko_indextree_journal/alembic/9d6b2ebed7eb_initial.py b/modules/weko-indextree-journal/weko_indextree_journal/alembic/fa0f8230e44b_create_weko_indextree_journal_branch.py similarity index 87% rename from modules/weko-indextree-journal/weko_indextree_journal/alembic/9d6b2ebed7eb_initial.py rename to modules/weko-indextree-journal/weko_indextree_journal/alembic/fa0f8230e44b_create_weko_indextree_journal_branch.py index edc3bd7a94..322fd499b2 100644 --- a/modules/weko-indextree-journal/weko_indextree_journal/alembic/9d6b2ebed7eb_initial.py +++ b/modules/weko-indextree-journal/weko_indextree_journal/alembic/fa0f8230e44b_create_weko_indextree_journal_branch.py @@ -5,14 +5,14 @@ # 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. -"""initial""" +"""Create weko_indextree_journal branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '9d6b2ebed7eb' +revision = 'fa0f8230e44b' down_revision = None branch_labels = ('weko_indextree_journal',) depends_on = None diff --git a/modules/weko-items-ui/weko_items_ui/alembic/e4fdaedc126c_create_weko_items_ui_branch.py b/modules/weko-items-ui/weko_items_ui/alembic/3668968dffbd_create_weko_items_ui_branch.py similarity index 84% rename from modules/weko-items-ui/weko_items_ui/alembic/e4fdaedc126c_create_weko_items_ui_branch.py rename to modules/weko-items-ui/weko_items_ui/alembic/3668968dffbd_create_weko_items_ui_branch.py index 7be52f0f97..db4e17ac73 100644 --- a/modules/weko-items-ui/weko_items_ui/alembic/e4fdaedc126c_create_weko_items_ui_branch.py +++ b/modules/weko-items-ui/weko_items_ui/alembic/3668968dffbd_create_weko_items_ui_branch.py @@ -5,17 +5,17 @@ # 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. -"""Create weko-items-ui branch.""" +"""Create weko_items_ui branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'e4fdaedc126c' +revision = '3668968dffbd' down_revision = None branch_labels = ('weko_items_ui',) -depends_on = 'weko_records' +depends_on = None def upgrade(): diff --git a/modules/weko-items-ui/weko_items_ui/alembic/9dc005064658_create_cris_linkage_result_table.py b/modules/weko-items-ui/weko_items_ui/alembic/9dc005064658_create_cris_linkage_result_table.py deleted file mode 100644 index dabafe13d8..0000000000 --- a/modules/weko-items-ui/weko_items_ui/alembic/9dc005064658_create_cris_linkage_result_table.py +++ /dev/null @@ -1,46 +0,0 @@ -# -# 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. - -"""Create cris_linkage_result table""" - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import mysql -import sqlalchemy_utils - -# revision identifiers, used by Alembic. -revision = '9dc005064658' -down_revision = 'e4fdaedc126c' -branch_labels = () -depends_on = 'weko_records' - - -def upgrade(): - """Upgrade database.""" - op.create_table( - 'cris_linkage_result', - sa.Column('created', sa.DateTime(), nullable=False), - sa.Column('updated', sa.DateTime(), nullable=False), - sa.Column('recid', sa.Integer(), nullable=False), - sa.Column('cris_institution', sa.Text(), nullable=False), - sa.Column('last_linked_date', sa.DateTime(), nullable=True), - sa.Column('last_linked_item', sqlalchemy_utils.types.uuid.UUIDType(), - nullable=True), - sa.Column('succeed', sa.Boolean(), nullable=True), - sa.Column('failed_log', sa.Text().with_variant(mysql.VARCHAR(255), 'mysql'), - nullable=False, server_default=''), - sa.ForeignKeyConstraint(['recid'], ['pidstore_recid.recid'], - name='fk_cris_linkage_result_recid_pidstore_recid'), - sa.ForeignKeyConstraint(['last_linked_item'], ['item_metadata.id'], - name='fk_cris_linkage_result_last_linked_item_item_metadata'), - sa.PrimaryKeyConstraint('recid', 'cris_institution'), - ) - - -def downgrade(): - """Downgrade database.""" - op.drop_table('cris_linkage_result') diff --git a/modules/weko-logging/weko_logging/alembic/9135a3e69760_create_user_activity_log_table.py b/modules/weko-logging/weko_logging/alembic/9135a3e69760_create_user_activity_log_table.py deleted file mode 100644 index 74b4823a52..0000000000 --- a/modules/weko-logging/weko_logging/alembic/9135a3e69760_create_user_activity_log_table.py +++ /dev/null @@ -1,68 +0,0 @@ -# -# 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. - -"""Create user activity log table""" - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql, mysql -from sqlalchemy.schema import Sequence, CreateSequence, DropSequence -from sqlalchemy_utils import JSONType - -# revision identifiers, used by Alembic. -revision = '9135a3e69760' -down_revision = 'f97e5ecfc4ec' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.create_table( - 'user_activity_logs', - sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True), - sa.Column("date", sa.DateTime().with_variant( - mysql.DATETIME(fsp=6), - 'mysql' - ), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=False), - sa.Column('community_id', sa.String(100), nullable=True), - sa.Column('log_group_id', sa.Integer(), nullable=True), - sa.Column("log", sa.JSON().with_variant( - postgresql.JSONB(none_as_null=True), - 'postgresql', - ).with_variant( - JSONType(), - 'sqlite', - ).with_variant( - JSONType(), - 'mysql', - ), nullable=False), - sa.Column("remarks", sa.Text(), nullable=True), - sa.ForeignKeyConstraint( - ['user_id'], ['accounts_user.id'], - name='fk_user_activity_active_user_id', - ), - sa.ForeignKeyConstraint( - ["community_id"], ["communities_community.id"], - name="fk_user_activity_community_id", - ), - ) - - # create sequence "user_activity_log_group_id_seq" - op.execute( - CreateSequence(Sequence("user_activity_log_group_id_seq")) - ) - - -def downgrade(): - """Downgrade database.""" - op.drop_table("user_activity_log") - # drop sequence "user_activity_log_group_id_seq" - op.execute( - DropSequence(Sequence("user_activity_log_group_id_seq")) - ) diff --git a/modules/weko-logging/weko_logging/alembic/f97e5ecfc4ec_create_weko_logging_branch.py b/modules/weko-logging/weko_logging/alembic/f0621369ac03_create_weko_logging_branch.py similarity index 89% rename from modules/weko-logging/weko_logging/alembic/f97e5ecfc4ec_create_weko_logging_branch.py rename to modules/weko-logging/weko_logging/alembic/f0621369ac03_create_weko_logging_branch.py index 93bd38aeac..96f681272b 100644 --- a/modules/weko-logging/weko_logging/alembic/f97e5ecfc4ec_create_weko_logging_branch.py +++ b/modules/weko-logging/weko_logging/alembic/f0621369ac03_create_weko_logging_branch.py @@ -5,14 +5,14 @@ # 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. -"""Create weko-logging branch""" +"""Create weko_logging branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'f97e5ecfc4ec' +revision = 'f0621369ac03' down_revision = None branch_labels = ('weko_logging',) depends_on = None diff --git a/modules/weko-notifications/weko_notifications/alembic/1aceb8bc87f2_create_weko_notifications_branch.py b/modules/weko-notifications/weko_notifications/alembic/1aceb8bc87f2_create_weko_notifications_branch.py deleted file mode 100644 index 60ef5f639f..0000000000 --- a/modules/weko-notifications/weko_notifications/alembic/1aceb8bc87f2_create_weko_notifications_branch.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2025 National Institute of Informatics. -# -# WEKO-Notifications is free software; you can redistribute it and/or modify -# it under the terms of the MIT License; see LICENSE file for more details. - -"""Create weko-notifications branch.""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '1aceb8bc87f2' -down_revision = None -branch_labels = ('weko_notifications',) -depends_on = None - - -def upgrade(): - """Upgrade database.""" - pass - - -def downgrade(): - """Downgrade database.""" - pass diff --git a/modules/weko-notifications/weko_notifications/alembic/33c2a0cb8f5f_create_weko_notifications_branch.py b/modules/weko-notifications/weko_notifications/alembic/33c2a0cb8f5f_create_weko_notifications_branch.py new file mode 100644 index 0000000000..ab807df96c --- /dev/null +++ b/modules/weko-notifications/weko_notifications/alembic/33c2a0cb8f5f_create_weko_notifications_branch.py @@ -0,0 +1,28 @@ +# +# 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. + +"""Create weko_notifications branch.""" + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '33c2a0cb8f5f' +down_revision = None +branch_labels = ('weko_notifications',) +depends_on = None + + +def upgrade(): + """Upgrade database.""" + pass + + +def downgrade(): + """Downgrade database.""" + pass diff --git a/modules/weko-notifications/weko_notifications/alembic/9ef65066e0d3_create_notifications_user_settings_table.py b/modules/weko-notifications/weko_notifications/alembic/9ef65066e0d3_create_notifications_user_settings_table.py deleted file mode 100644 index 3244fa4c39..0000000000 --- a/modules/weko-notifications/weko_notifications/alembic/9ef65066e0d3_create_notifications_user_settings_table.py +++ /dev/null @@ -1,49 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2025 National Institute of Informatics. -# -# WEKO-Notifications is free software; you can redistribute it and/or modify -# it under the terms of the MIT License; see LICENSE file for more details. - -"""Create notifications_user_settings table.""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = "9ef65066e0d3" -down_revision = "1aceb8bc87f2" -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.create_table( - "notifications_user_settings", - sa.Column("created", sa.DateTime(), nullable=False), - sa.Column("updated", sa.DateTime(), nullable=False), - sa.Column("user_id", sa.Integer(), nullable=False), - sa.Column("user_profile_id", sa.Integer(), nullable=True), - sa.Column( - "subscribe_email", - sa.Boolean(name="subscribe_email"), - nullable=False - ), - sa.PrimaryKeyConstraint("user_id"), - sa.ForeignKeyConstraint( - ["user_id"], ["accounts_user.id"], - name="fk_notifications_user_settings_user_id_accounts_user", - ondelete="CASCADE" - ), - sa.ForeignKeyConstraint( - ["user_profile_id"], ["userprofiles_userprofile.user_id"], - name="fk_notifications_user_settings_user_profile_id_userprofiles_userprofile", - ) - ) - - -def downgrade(): - """Downgrade database.""" - op.drop_table("notifications_user_settings") diff --git a/modules/weko-records-ui/weko_records_ui/alembic/2750aa1ddc76_create_weko_records_ui_branch.py b/modules/weko-records-ui/weko_records_ui/alembic/d7f12c83cbc6_create_weko_records_ui_branch.py similarity index 83% rename from modules/weko-records-ui/weko_records_ui/alembic/2750aa1ddc76_create_weko_records_ui_branch.py rename to modules/weko-records-ui/weko_records_ui/alembic/d7f12c83cbc6_create_weko_records_ui_branch.py index 2622bdff59..9d74949136 100644 --- a/modules/weko-records-ui/weko_records_ui/alembic/2750aa1ddc76_create_weko_records_ui_branch.py +++ b/modules/weko-records-ui/weko_records_ui/alembic/d7f12c83cbc6_create_weko_records_ui_branch.py @@ -5,17 +5,17 @@ # 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. -"""Create weko-records-ui branch.""" +"""Create weko_records_ui branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '2750aa1ddc76' +revision = 'd7f12c83cbc6' down_revision = None branch_labels = ('weko_records_ui',) -depends_on = 'invenio_accounts' +depends_on = None def upgrade(): diff --git a/modules/weko-records-ui/weko_records_ui/alembic/e0b1ef08d08c_create_file_url_download_log_table.py b/modules/weko-records-ui/weko_records_ui/alembic/e0b1ef08d08c_create_file_url_download_log_table.py deleted file mode 100644 index 95f412e12e..0000000000 --- a/modules/weko-records-ui/weko_records_ui/alembic/e0b1ef08d08c_create_file_url_download_log_table.py +++ /dev/null @@ -1,138 +0,0 @@ -# -# 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. - -"""Create file_url_download_log table.""" - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects.postgresql import INET -from sqlalchemy.orm import Session - - -# revision identifiers, used by Alembic. -revision = 'e0b1ef08d08c' -down_revision = '2750aa1ddc76' -branch_labels = () -depends_on = 'invenio_accounts' - - -def upgrade(): - """Upgrade database.""" - - # Recreate 'file_onetime_download' table - op.drop_table('file_onetime_download') - op.create_table( - 'file_onetime_download', - sa.Column('created', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('updated', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True), - sa.Column('approver_id', sa.Integer(), nullable=True), - sa.Column('record_id', sa.String(255), nullable=False), - sa.Column('file_name', sa.String(255), nullable=False), - sa.Column('expiration_date', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('download_limit', sa.Integer(), nullable=False), - sa.Column('download_count', sa.Integer(), nullable=False, server_default=sa.text('0')), - sa.Column('user_mail', sa.String(255), nullable=False), - sa.Column('is_guest', sa.Boolean(), nullable=False), - sa.Column('is_deleted', sa.Boolean(), nullable=False, server_default=sa.text('FALSE')), - sa.Column('extra_info', sa.JSON(), nullable=False, server_default=sa.text("'{}'")), - sa.ForeignKeyConstraint(['approver_id'], ['accounts_user.id'], name='fk_file_onetime_download_approver_id'), - sa.CheckConstraint('created < expiration_date', name='check_expiration_date'), - sa.CheckConstraint('download_limit > 0', name='check_download_limit_positive'), - sa.CheckConstraint('download_count <= download_limit', name='check_download_count_limit') - ) - - # Recreate 'file_secret_download' table - op.drop_table('file_secret_download') - op.create_table( - 'file_secret_download', - sa.Column('created', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('updated', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True), - sa.Column('creator_id', sa.Integer(), nullable=False), - sa.Column('record_id', sa.String(255), nullable=False), - sa.Column('file_name', sa.String(255), nullable=False), - sa.Column('label_name', sa.String(255), nullable=False), - sa.Column('expiration_date', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('download_limit', sa.Integer(), nullable=False), - sa.Column('download_count', sa.Integer(), nullable=False, server_default=sa.text('0')), - sa.Column('is_deleted', sa.Boolean(), nullable=False, server_default=sa.text('FALSE')), - sa.ForeignKeyConstraint(['creator_id'], ['accounts_user.id'], name='fk_file_secret_download_creator_id'), - sa.CheckConstraint('created < expiration_date', name='check_expiration_date'), - sa.CheckConstraint('download_limit > 0', name='check_download_limit_positive'), - sa.CheckConstraint('download_count <= download_limit', name='check_download_count_limit') - ) - - # Add 'file_url_download_log' table - op.create_table( - 'file_url_download_log', - sa.Column('created', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('updated', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True), - sa.Column('url_type', sa.Enum('SECRET', 'ONETIME', name='urltype'), nullable=False), - sa.Column('secret_url_id', sa.Integer(), sa.ForeignKey('file_secret_download.id'), nullable=True), - sa.Column('onetime_url_id', sa.Integer(), sa.ForeignKey('file_onetime_download.id'), nullable=True), - sa.Column('ip_address', INET().with_variant(sa.String(255), 'sqlite').with_variant(sa.String(255), 'mysql'), nullable=True), - sa.Column('access_status', sa.Enum('OPEN_NO', 'OPEN_DATE', 'OPEN_RESTRICTED', name='accessstatus'), nullable=False), - sa.Column('used_token', sa.String(255), nullable=False), - sa.CheckConstraint( - """ - (url_type = 'SECRET' AND secret_url_id IS NOT NULL AND onetime_url_id IS NULL) - OR - (url_type = 'ONETIME' AND onetime_url_id IS NOT NULL AND secret_url_id IS NULL) - """, - name="chk_url_id" - ), - sa.CheckConstraint( - """ - (url_type = 'SECRET' AND ip_address IS NOT NULL) - OR - (url_type = 'ONETIME' AND ip_address IS NULL) - """, - name="chk_ip_address" - ), - sa.CheckConstraint( - """ - (url_type = 'SECRET' AND (access_status = 'OPEN_NO' OR access_status = 'OPEN_DATE')) - OR - (url_type = 'ONETIME' AND access_status = 'OPEN_RESTRICTED') - """, - name="chk_access_status" - ) - ) - -def downgrade(): - """Downgrade database.""" - - op.drop_table('file_url_download_log') - op.execute("DROP TYPE IF EXISTS urltype;") - op.execute("DROP TYPE IF EXISTS accessstatus;") - op.drop_table('file_onetime_download') - op.create_table( - 'file_onetime_download', - sa.Column('created', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('updated', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True), - sa.Column('file_name', sa.String(255), nullable=False), - sa.Column('user_mail', sa.String(255), nullable=False), - sa.Column('record_id', sa.String(255), nullable=False), - sa.Column('download_count', sa.Integer(), nullable=False, server_default=sa.text('0')), - sa.Column('expiration_date', sa.Integer(), nullable=False, server_default=sa.text('0')), - sa.Column('extra_info', sa.JSON(), nullable=True, server_default=sa.text("'{}'")), - ) - op.drop_table('file_secret_download') - op.create_table( - 'file_secret_download', - sa.Column('created', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('updated', sa.TIMESTAMP(timezone=False), nullable=False), - sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True), - sa.Column('file_name', sa.String(255), nullable=False), - sa.Column('user_mail', sa.String(255), nullable=False), - sa.Column('record_id', sa.String(255), nullable=False), - sa.Column('download_count', sa.Integer(), nullable=False, server_default=sa.text('0')), - sa.Column('expiration_date', sa.Integer(), nullable=False, server_default=sa.text('0')), - ) diff --git a/modules/weko-records/weko_records/alembic/10e311ab03bf_create_weko_records_branch.py b/modules/weko-records/weko_records/alembic/10e311ab03bf_create_weko_records_branch.py deleted file mode 100644 index a9a6f428c9..0000000000 --- a/modules/weko-records/weko_records/alembic/10e311ab03bf_create_weko_records_branch.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2022 National Institute of Informatics. -# -# WEKO-Records is free software; you can redistribute it and/or modify it -# under the terms of the MIT License; see LICENSE file for more details. - -"""Create weko_records branch.""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '10e311ab03bf' -down_revision = None -branch_labels = ('weko_records',) -depends_on = None - - -def upgrade(): - """Upgrade database.""" - pass - - -def downgrade(): - """Downgrade database.""" - pass diff --git a/modules/weko-records/weko_records/alembic/1619a115156f_add_repository_id_column.py b/modules/weko-records/weko_records/alembic/1619a115156f_add_repository_id_column.py deleted file mode 100644 index 46e60969bb..0000000000 --- a/modules/weko-records/weko_records/alembic/1619a115156f_add_repository_id_column.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2022 National Institute of Informatics. -# -# WEKO-Records is free software; you can redistribute it and/or modify it -# under the terms of the MIT License; see LICENSE file for more details. - -"""add repository_id column""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '1619a115156f' -down_revision = '10e311ab03bf' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.add_column('feedback_mail_list', sa.Column('repository_id', sa.String(length=100), nullable=False, server_default='Root Index')) - op.add_column('sitelicense_info', sa.Column('repository_id', sa.String(length=100), nullable=False, server_default='Root Index')) - - -def downgrade(): - """Downgrade database.""" - op.drop_column('sitelicense_info', 'repository_id') - op.drop_column('feedback_mail_list', 'repository_id') diff --git a/modules/invenio-oaiharvester/invenio_oaiharvester/alembic/fe01c386f558_initial.py b/modules/weko-records/weko_records/alembic/32ecd938a01b_create_weko_records_branch.py similarity index 82% rename from modules/invenio-oaiharvester/invenio_oaiharvester/alembic/fe01c386f558_initial.py rename to modules/weko-records/weko_records/alembic/32ecd938a01b_create_weko_records_branch.py index 06370beded..b845bcb137 100644 --- a/modules/invenio-oaiharvester/invenio_oaiharvester/alembic/fe01c386f558_initial.py +++ b/modules/weko-records/weko_records/alembic/32ecd938a01b_create_weko_records_branch.py @@ -5,16 +5,16 @@ # 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. -"""initial""" +"""Create weko_records branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'fe01c386f558' +revision = '32ecd938a01b' down_revision = None -branch_labels = ('invenio_oaiharvester',) +branch_labels = ('weko_records',) depends_on = None diff --git a/modules/weko-records/weko_records/alembic/89c58783bf65_create_jsonld_mappings_table.py b/modules/weko-records/weko_records/alembic/89c58783bf65_create_jsonld_mappings_table.py deleted file mode 100644 index 8e010eac41..0000000000 --- a/modules/weko-records/weko_records/alembic/89c58783bf65_create_jsonld_mappings_table.py +++ /dev/null @@ -1,116 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2022 National Institute of Informatics. -# -# WEKO-Records is free software; you can redistribute it and/or modify it -# under the terms of the MIT License; see LICENSE file for more details. - -"""Create jsonld_mapping table.""" - -from alembic import op -import sqlalchemy as sa - -from sqlalchemy.dialects import postgresql -from sqlalchemy_utils.types import JSONType - -# revision identifiers, used by Alembic. -revision = "89c58783bf65" -down_revision = "1619a115156f" -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.create_table( - "jsonld_mappings", - sa.Column("created", sa.DateTime(), nullable=False), - sa.Column("updated", sa.DateTime(), nullable=False), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(length=255), nullable=False), - sa.Column( - "mapping", - sa.JSON().with_variant( - postgresql.JSONB(none_as_null=False), - "postgresql", - ).with_variant( - JSONType(), - "sqlite", - ).with_variant( - JSONType(), - "mysql", - ), - nullable=False - ), - sa.Column("item_type_id", sa.Integer(), nullable=False), - sa.Column("version_id", sa.Integer(), nullable=False), - sa.Column( - "is_deleted", sa.Boolean(name="is_deleted"), - nullable=False, default=False - ), - sa.Index("ix_jsonld_mappings_item_type_id", "item_type_id"), - sa.ForeignKeyConstraint( - ["item_type_id"], ["item_type.id"], - name="fk_jsonld_mappings_item_type_id_item_type", - ), - sa.PrimaryKeyConstraint("id") - ) - - op.create_table( - "jsonld_mappings_version", - sa.Column("created", sa.DateTime()), - sa.Column("updated", sa.DateTime()), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("name", sa.String(length=255)), - sa.Column( - "mapping", - sa.JSON().with_variant( - postgresql.JSONB(none_as_null=True), - "postgresql", - ).with_variant( - JSONType(), - "sqlite", - ).with_variant( - JSONType(), - "mysql", - ), - default=lambda: {} - ), - sa.Column("item_type_id", sa.Integer()), - sa.Column("version_id", sa.Integer()), - sa.Column("is_deleted", sa.Boolean(name="is_deleted")), - sa.Column("transaction_id", sa.BigInteger(), nullable=False), - sa.Column("end_transaction_id", sa.BigInteger()), - sa.Column("operation_type", sa.SmallInteger(), nullable=False), - sa.PrimaryKeyConstraint("id", "transaction_id"), - ) - op.create_index( - op.f("ix_jsonld_mappings_version_transaction_id"), - "jsonld_mappings_version", - ["transaction_id"], - unique=False, - ) - op.create_index( - op.f("ix_jsonld_mappings_version_operation_type"), - "jsonld_mappings_version", - ["operation_type"], - unique=False, - ) - op.create_index( - op.f("ix_jsonld_mappings_version_end_transaction_id"), - "jsonld_mappings_version", - ["end_transaction_id"], - unique=False, - ) - op.create_index( - op.f("ix_jsonld_mappings_version_item_type_id"), - "jsonld_mappings_version", - ["item_type_id"], - unique=False, - ) - - -def downgrade(): - """Downgrade database.""" - op.drop_table("jsonld_mappings") - op.drop_table("jsonld_mappings_version") diff --git a/modules/weko-records/weko_records/alembic/e0dd9fb514cf_add_constraints_to_mapping.py b/modules/weko-records/weko_records/alembic/e0dd9fb514cf_add_constraints_to_mapping.py index 072add4930..ba81fb0dad 100644 --- a/modules/weko-records/weko_records/alembic/e0dd9fb514cf_add_constraints_to_mapping.py +++ b/modules/weko-records/weko_records/alembic/e0dd9fb514cf_add_constraints_to_mapping.py @@ -13,7 +13,7 @@ # revision identifiers, used by Alembic. revision = 'e0dd9fb514cf' -down_revision = 'e3b07ec6e628' +down_revision = '32ecd938a01b' branch_labels = () depends_on = None diff --git a/modules/weko-records/weko_records/alembic/e3b07ec6e628_add_oa_status_table.py b/modules/weko-records/weko_records/alembic/e3b07ec6e628_add_oa_status_table.py deleted file mode 100644 index c61b73465b..0000000000 --- a/modules/weko-records/weko_records/alembic/e3b07ec6e628_add_oa_status_table.py +++ /dev/null @@ -1,35 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2022 National Institute of Informatics. -# -# WEKO-Records is free software; you can redistribute it and/or modify it -# under the terms of the MIT License; see LICENSE file for more details. - -"""Add oa_status table.""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'e3b07ec6e628' -down_revision = '89c58783bf65' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.create_table( - "oa_status", - sa.Column("created", sa.DateTime(), nullable=False), - sa.Column("updated", sa.DateTime(), nullable=False), - sa.Column("oa_article_id", sa.Integer(), nullable=False), - sa.Column("oa_status", sa.Text(), nullable=True), - sa.Column("weko_item_pid", sa.String(length=255), nullable=True), - sa.PrimaryKeyConstraint("oa_article_id") - ) - -def downgrade(): - """Downgrade database.""" - op.drop_table("oa_status") diff --git a/modules/weko-schema-ui/setup.py b/modules/weko-schema-ui/setup.py index b2bc06ff33..9571652a1b 100644 --- a/modules/weko-schema-ui/setup.py +++ b/modules/weko-schema-ui/setup.py @@ -108,6 +108,12 @@ 'schema_access = ' 'weko_schema_ui.permissions:action_schema_access', ], + 'invenio_db.models': [ + 'weko_schema_ui = weko_schema_ui.models', + ], + 'invenio_db.alembic': [ + 'weko_schema_ui = weko_schema_ui:alembic', + ], }, extras_require=extras_require, install_requires=install_requires, diff --git a/modules/weko-swordserver/weko_swordserver/alembic/05683afc0320_create_weko_swordserver_branch.py b/modules/weko-swordserver/weko_swordserver/alembic/05683afc0320_create_weko_swordserver_branch.py deleted file mode 100644 index 5ce33031f7..0000000000 --- a/modules/weko-swordserver/weko_swordserver/alembic/05683afc0320_create_weko_swordserver_branch.py +++ /dev/null @@ -1,28 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2024 National Institute of Informatics. -# -# WEKO-SWORDServer is free software; you can redistribute it and/or modify it -# under the terms of the MIT License; see LICENSE file for more details. - -"""Create weko-swordserver branch.""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '05683afc0320' -down_revision = None -branch_labels = ('weko_swordserver',) -depends_on = None - - -def upgrade(): - """Upgrade database.""" - pass - - -def downgrade(): - """Downgrade database.""" - pass diff --git a/modules/invenio-resourcesyncserver/invenio_resourcesyncserver/alembic/c65a8505bb99_initial.py b/modules/weko-swordserver/weko_swordserver/alembic/ce1507cfda02_create_weko_swordserver_branch.py similarity index 81% rename from modules/invenio-resourcesyncserver/invenio_resourcesyncserver/alembic/c65a8505bb99_initial.py rename to modules/weko-swordserver/weko_swordserver/alembic/ce1507cfda02_create_weko_swordserver_branch.py index c652d67b1e..ea090314de 100644 --- a/modules/invenio-resourcesyncserver/invenio_resourcesyncserver/alembic/c65a8505bb99_initial.py +++ b/modules/weko-swordserver/weko_swordserver/alembic/ce1507cfda02_create_weko_swordserver_branch.py @@ -5,16 +5,16 @@ # 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. -"""initial""" +"""Create weko_swordserver branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'c65a8505bb99' +revision = 'ce1507cfda02' down_revision = None -branch_labels = ('invenio_resourcesyncserver',) +branch_labels = ('weko_swordserver',) depends_on = None diff --git a/modules/weko-swordserver/weko_swordserver/alembic/ce82f0d78dcb_create_sword_clients_table.py b/modules/weko-swordserver/weko_swordserver/alembic/ce82f0d78dcb_create_sword_clients_table.py deleted file mode 100644 index 68e36d403f..0000000000 --- a/modules/weko-swordserver/weko_swordserver/alembic/ce82f0d78dcb_create_sword_clients_table.py +++ /dev/null @@ -1,70 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2024 National Institute of Informatics. -# -# WEKO-SWORDServer is free software; you can redistribute it and/or modify it -# under the terms of the MIT License; see LICENSE file for more details. - -"""Create sword_clients table.""" - -from alembic import op -import sqlalchemy as sa - -from sqlalchemy.dialects import postgresql -from sqlalchemy_utils.types import JSONType - -# revision identifiers, used by Alembic. -revision = "ce82f0d78dcb" -down_revision = "05683afc0320" -branch_labels = () -depends_on = "89c58783bf65" - - -def upgrade(): - """Upgrade database.""" - op.create_table( - "sword_clients", - sa.Column("created", sa.DateTime(), nullable=False), - sa.Column("updated", sa.DateTime(), nullable=False), - sa.Column("id", sa.Integer(), nullable=False), - sa.Column("client_id", sa.String(length=255), nullable=False), - sa.Column("active", sa.Boolean(name="active")), - sa.Column("registration_type_id", sa.SmallInteger(), nullable=False), - sa.Column("mapping_id", sa.Integer(), nullable=False), - sa.Column("workflow_id", sa.Integer()), - sa.Column("duplicate_check", sa.Boolean(name="duplicate_check"), nullable=False), - sa.Column( - "meta_data_api", - sa.JSON().with_variant( - postgresql.JSONB(none_as_null=True), - 'postgresql', - ).with_variant( - JSONType(), - 'sqlite', - ).with_variant( - JSONType(), - 'mysql', - ), - nullable=True - ), - sa.PrimaryKeyConstraint("id"), - sa.Index("ix_sword_clients_client_id", "client_id", unique=True), - sa.ForeignKeyConstraint( - ["client_id"], ["oauth2server_client.client_id"], - name="fk_sword_clients_client_id_oauth2server_client", - ondelete="CASCADE", - ), - sa.ForeignKeyConstraint( - ["mapping_id"], ["jsonld_mappings.id"], - name="fk_sword_clients_mapping_id_jsonld_mappings", - ), - sa.ForeignKeyConstraint( - ["workflow_id"], ["workflow_workflow.id"], - name="fk_sword_clients_workflow_id_workflow_workflow", - ) - ) - - -def downgrade(): - """Downgrade database.""" - op.drop_table("sword_clients") diff --git a/modules/weko-user-profiles/weko_user_profiles/alembic/250f0661704b_userprofiles_userprofile.py b/modules/weko-user-profiles/weko_user_profiles/alembic/250f0661704b_userprofiles_userprofile.py deleted file mode 100644 index c5cf98fbb9..0000000000 --- a/modules/weko-user-profiles/weko_user_profiles/alembic/250f0661704b_userprofiles_userprofile.py +++ /dev/null @@ -1,34 +0,0 @@ -# -# 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. - -"""userprofiles-userprofile""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '250f0661704b' -down_revision = 'ac4ff52361f4' -branch_labels = () -depends_on = 'invenio_accounts' - - -def upgrade(): - """Upgrade database.""" - with op.batch_alter_table('userprofiles_userprofile') as profile_op: - profile_op.add_column(sa.Column("item13", sa.String(255),nullable=True)) - profile_op.add_column(sa.Column("item14", sa.String(255),nullable=True)) - profile_op.add_column(sa.Column("item15", sa.String(255),nullable=True)) - profile_op.add_column(sa.Column("item16", sa.String(255),nullable=True)) - -def downgrade(): - """Downgrade database.""" - op.drop_column("userprofiles_userprofile", "item13") - op.drop_column("userprofiles_userprofile", "item14") - op.drop_column("userprofiles_userprofile", "item15") - op.drop_column("userprofiles_userprofile", "item16") diff --git a/modules/weko-user-profiles/weko_user_profiles/alembic/c4d16e640acc_initial.py b/modules/weko-user-profiles/weko_user_profiles/alembic/9aa432ab3b84_create_weko_user_profiles_branch.py similarity index 88% rename from modules/weko-user-profiles/weko_user_profiles/alembic/c4d16e640acc_initial.py rename to modules/weko-user-profiles/weko_user_profiles/alembic/9aa432ab3b84_create_weko_user_profiles_branch.py index dcc2995514..1989353b04 100644 --- a/modules/weko-user-profiles/weko_user_profiles/alembic/c4d16e640acc_initial.py +++ b/modules/weko-user-profiles/weko_user_profiles/alembic/9aa432ab3b84_create_weko_user_profiles_branch.py @@ -5,14 +5,14 @@ # 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. -"""initial""" +"""Create weko_user_profiles branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'c4d16e640acc' +revision = '9aa432ab3b84' down_revision = None branch_labels = ('weko_user_profiles',) depends_on = None diff --git a/modules/weko-user-profiles/weko_user_profiles/alembic/ac4ff52361f4_add_column_userprofile.py b/modules/weko-user-profiles/weko_user_profiles/alembic/ac4ff52361f4_add_column_userprofile.py deleted file mode 100644 index 091295c574..0000000000 --- a/modules/weko-user-profiles/weko_user_profiles/alembic/ac4ff52361f4_add_column_userprofile.py +++ /dev/null @@ -1,33 +0,0 @@ -# -# 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. - -"""add_column_userprofile""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'ac4ff52361f4' -down_revision = 'c4d16e640acc' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.add_column('userprofiles_userprofile', sa.Column('s3_endpoint_url', sa.String(length=128), nullable=True)) - op.add_column('userprofiles_userprofile', sa.Column('s3_region_name', sa.String(length=128), nullable=True)) - op.add_column('userprofiles_userprofile', sa.Column('access_key', sa.String(length=128), nullable=True)) - op.add_column('userprofiles_userprofile', sa.Column('secret_key', sa.String(length=128), nullable=True)) - -def downgrade(): - """Downgrade database.""" - op.drop_column('userprofiles_userprofile', 's3_endpoint_url') - op.drop_column('userprofiles_userprofile', 's3_region_name') - op.drop_column('userprofiles_userprofile', 'access_key') - op.drop_column('userprofiles_userprofile', 'secret_key') diff --git a/modules/weko-workflow/weko_workflow/alembic/2084f52e00b7_update.py b/modules/weko-workflow/weko_workflow/alembic/2084f52e00b7_update.py deleted file mode 100644 index f2a2e8fcad..0000000000 --- a/modules/weko-workflow/weko_workflow/alembic/2084f52e00b7_update.py +++ /dev/null @@ -1,32 +0,0 @@ -# -# 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. - -"""update""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '2084f52e00b7' -down_revision = 'd130b9cff95c' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - # ### commands auto generated by Alembic - please adjust! ### - op.create_foreign_key(op.f('fk_workflow_workflow_location_id_files_location'), 'workflow_workflow', 'files_location', ['location_id'], ['id']) - # ### end Alembic commands ### - - -def downgrade(): - """Downgrade database.""" - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(op.f('fk_workflow_workflow_location_id_files_location'), 'workflow_workflow', type_='foreignkey') - # ### end Alembic commands ### diff --git a/modules/weko-workflow/weko_workflow/alembic/841860bb1333_add_activity_request_mail.py b/modules/weko-workflow/weko_workflow/alembic/841860bb1333_add_activity_request_mail.py deleted file mode 100644 index 06734e2e52..0000000000 --- a/modules/weko-workflow/weko_workflow/alembic/841860bb1333_add_activity_request_mail.py +++ /dev/null @@ -1,42 +0,0 @@ -# -# 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. - -"""add activity request mail""" - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '841860bb1333' -down_revision = '2084f52e00b7' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.create_table( - 'workflow_activity_request_mail', - sa.Column('status', sa.String(1), nullable=False), - sa.Column('created', sa.DateTime(), nullable=False), - sa.Column('updated', sa.DateTime(), nullable=False), - sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True, nullable=False), - sa.Column('activity_id', sa.String(length=24), nullable=False, index=True), - sa.Column('display_request_button', sa.Boolean(name='display_request_button'), nullable=False, server_default='0'), - sa.Column('request_maillist', - sa.JSON() - .with_variant(postgresql.JSONB(none_as_null=True), 'postgresql') - .with_variant(sa.JSON(), 'sqlite') - .with_variant(sa.JSON(), 'mysql'), - nullable=True - ), - ) - -def downgrade(): - """Downgrade database.""" - op.drop_table('workflow_activity_request_mail') diff --git a/modules/weko-workflow/weko_workflow/alembic/a560202ff0ac_add_columns_for_deleting_items.py b/modules/weko-workflow/weko_workflow/alembic/a560202ff0ac_add_columns_for_deleting_items.py deleted file mode 100644 index 944a0feeee..0000000000 --- a/modules/weko-workflow/weko_workflow/alembic/a560202ff0ac_add_columns_for_deleting_items.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Copyright (C) 2024 National Institute of Informatics. -# -# WEKO-Workflow is free software; you can redistribute it and/or modify it -# under the terms of the MIT License; see LICENSE file for more details. - - -"""Add columns for deleting items.""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = "a560202ff0ac" -down_revision = "841860bb1333" -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - with op.batch_alter_table("workflow_flow_define") as batch_op: - # Step 1: Add column as nullable - batch_op.add_column( - sa.Column("flow_type", sa.SmallInteger(), nullable=True) - ) - # Step 2: Set default value for existing records - op.execute("UPDATE workflow_flow_define SET flow_type = 1") - # Step 3: Alter column to be NOT NULL - with op.batch_alter_table("workflow_flow_define") as batch_op: - batch_op.alter_column("flow_type", nullable=False) - - with op.batch_alter_table("workflow_workflow") as batch_op: - batch_op.add_column( - sa.Column("delete_flow_id", sa.Integer(), nullable=True) - ) - batch_op.create_foreign_key( - "fk_workflow_workflow_delete_flow_id_workflow_flow_define", - "workflow_flow_define", - ["delete_flow_id"], - ["id"], - ondelete="SET NULL", - ) - - -def downgrade(): - """Downgrade database.""" - with op.batch_alter_table("workflow_workflow") as batch_op: - batch_op.drop_constraint( - "fk_workflow_workflow_delete_flow_id_workflow_flow_define", - type_="foreignkey" - ) - batch_op.drop_column("delete_flow_id") - - with op.batch_alter_table("workflow_flow_define") as batch_op: - batch_op.drop_column("flow_type") diff --git a/modules/weko-workflow/weko_workflow/alembic/d130b9cff95c_initial.py b/modules/weko-workflow/weko_workflow/alembic/b1f5618360f5_create_weko_workflow_branch.py similarity index 88% rename from modules/weko-workflow/weko_workflow/alembic/d130b9cff95c_initial.py rename to modules/weko-workflow/weko_workflow/alembic/b1f5618360f5_create_weko_workflow_branch.py index 41f9481ffc..e8c65bfc6f 100644 --- a/modules/weko-workflow/weko_workflow/alembic/d130b9cff95c_initial.py +++ b/modules/weko-workflow/weko_workflow/alembic/b1f5618360f5_create_weko_workflow_branch.py @@ -5,14 +5,14 @@ # 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. -"""initial""" +"""Create weko_workflow branch.""" from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'd130b9cff95c' +revision = 'b1f5618360f5' down_revision = None branch_labels = ('weko_workflow',) depends_on = None diff --git a/modules/weko-workflow/weko_workflow/alembic/f312b8c2839a_add_columns.py b/modules/weko-workflow/weko_workflow/alembic/f312b8c2839a_add_columns.py deleted file mode 100644 index 5270d2507b..0000000000 --- a/modules/weko-workflow/weko_workflow/alembic/f312b8c2839a_add_columns.py +++ /dev/null @@ -1,30 +0,0 @@ -# -# 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. - -"""Add columns""" - -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'f312b8c2839a' -down_revision = 'a560202ff0ac' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.add_column('workflow_flow_define', sa.Column('repository_id', sa.String(length=100), nullable=False, server_default='Root Index')) - op.add_column('workflow_workflow', sa.Column('repository_id', sa.String(length=100), nullable=False, server_default='Root Index')) - - -def downgrade(): - """Downgrade database.""" - op.drop_column('workflow_workflow', 'repository_id') - op.drop_column('workflow_flow_define', 'repository_id') diff --git a/modules/weko-workspace/weko_workspace/alembic/197013eb095f_add_tables_for_weko_workspace.py b/modules/weko-workspace/weko_workspace/alembic/197013eb095f_add_tables_for_weko_workspace.py deleted file mode 100644 index 1874c3f666..0000000000 --- a/modules/weko-workspace/weko_workspace/alembic/197013eb095f_add_tables_for_weko_workspace.py +++ /dev/null @@ -1,51 +0,0 @@ -# -# 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. - -"""Add tables for weko-workspace.""" - -from datetime import datetime, timezone -from alembic import op -from invenio_db import db -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '197013eb095f' -down_revision = 'fa62eaff62c9' -branch_labels = () -depends_on = None - - -def upgrade(): - """Upgrade database.""" - op.create_table( - "workspace_default_conditions", - sa.Column("created", sa.DateTime(), nullable=False), - sa.Column("updated", sa.DateTime(), nullable=False), - sa.Column("user_id", sa.Integer(), nullable=False), - sa.Column("default_con", db.JSON().with_variant( - sa.dialects.postgresql.JSONB( - none_as_null=True), "postgresql", - ), nullable=False), - sa.PrimaryKeyConstraint("user_id") - ) - op.create_table( - "workspace_status_management", - sa.Column("created", sa.DateTime(), nullable=False), - sa.Column("updated", sa.DateTime(), nullable=False), - sa.Column("user_id", sa.Integer(), nullable=False), - sa.Column("recid", sa.Integer(), nullable=False), - sa.Column("is_favorited", sa.Boolean(name="is_favorited"), nullable=False, default=False), - sa.Column("is_read", sa.Boolean(name="is_read"), nullable=False, default=False), - sa.PrimaryKeyConstraint("user_id", "recid") - ) - - -def downgrade(): - """Downgrade database.""" - op.drop_table("workspace_default_conditions") - op.drop_table("workspace_status_management") diff --git a/modules/weko-workspace/weko_workspace/alembic/fa62eaff62c9_create_weko_workspace_branch.py b/modules/weko-workspace/weko_workspace/alembic/f78348c12d44_create_weko_workspace_branch.py similarity index 95% rename from modules/weko-workspace/weko_workspace/alembic/fa62eaff62c9_create_weko_workspace_branch.py rename to modules/weko-workspace/weko_workspace/alembic/f78348c12d44_create_weko_workspace_branch.py index 01098e6808..31af975332 100644 --- a/modules/weko-workspace/weko_workspace/alembic/fa62eaff62c9_create_weko_workspace_branch.py +++ b/modules/weko-workspace/weko_workspace/alembic/f78348c12d44_create_weko_workspace_branch.py @@ -12,7 +12,7 @@ # revision identifiers, used by Alembic. -revision = 'fa62eaff62c9' +revision = 'f78348c12d44' down_revision = None branch_labels = ('weko_workspace',) depends_on = None diff --git a/postgresql/update/W2025-16.sql b/postgresql/update/W2025-16.sql new file mode 100644 index 0000000000..26403f6fa1 --- /dev/null +++ b/postgresql/update/W2025-16.sql @@ -0,0 +1,13 @@ + +-- Add unique constraint +ALTER TABLE item_type_mapping +ADD CONSTRAINT uq_item_type_mapping_item_type_id UNIQUE (item_type_id); + +-- Add foreign key constraint +ALTER TABLE item_type_mapping +ADD CONSTRAINT fk_item_type_mapping_item_type_id_item_type +FOREIGN KEY (item_type_id) REFERENCES item_type(id) ON DELETE CASCADE; + +-- Drop indexes +DROP INDEX IF EXISTS idx_created_item_type_mapping; +DROP INDEX IF EXISTS idx_item_type_id_item_type_mapping;