From 987962424e006f8e284b0cc829a914895e69bab2 Mon Sep 17 00:00:00 2001 From: Avni Salhotra <132402145+avni-work@users.noreply.github.com> Date: Thu, 29 Aug 2024 11:21:08 -0700 Subject: [PATCH 1/8] update version number for release 2.10.5 (#2985) --- queue_services/account-mailer/src/account_mailer/version.py | 1 + 1 file changed, 1 insertion(+) diff --git a/queue_services/account-mailer/src/account_mailer/version.py b/queue_services/account-mailer/src/account_mailer/version.py index dc116fa97a..ed2ae0453e 100644 --- a/queue_services/account-mailer/src/account_mailer/version.py +++ b/queue_services/account-mailer/src/account_mailer/version.py @@ -23,3 +23,4 @@ """ __version__ = '2.18.4' # pylint: disable=invalid-name +__version__ = '2.18.4' # pylint: disable=invalid-name From ace24bd3891ef1101801574b9b9d7d68cdfb64f1 Mon Sep 17 00:00:00 2001 From: pwei1018 Date: Fri, 20 Sep 2024 11:30:46 -0700 Subject: [PATCH 2/8] Fixed history table, token and linting issues. --- .../versions/2024_09_20_aa74003de9d8_.py | 697 ++++++++++++++++++ auth-api/poetry.lock | 202 ++--- auth-api/pyproject.toml | 2 +- .../auth_api/exceptions/exception_handler.py | 12 +- auth-api/src/auth_api/models/activity_log.py | 2 +- auth-api/src/auth_api/models/entity.py | 2 - auth-api/src/auth_api/models/user.py | 2 +- auth-api/src/auth_api/models/user_settings.py | 2 +- auth-api/src/auth_api/services/invitation.py | 2 +- auth-api/src/auth_api/services/org.py | 2 +- .../src/auth_api/services/rest_service.py | 12 +- 11 files changed, 820 insertions(+), 117 deletions(-) create mode 100644 auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py diff --git a/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py b/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py new file mode 100644 index 0000000000..4327a03289 --- /dev/null +++ b/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py @@ -0,0 +1,697 @@ +"""empty message + +Revision ID: aa74003de9d8 +Revises: 69f7b110a98c +Create Date: 2024-09-20 11:19:42.551199 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = 'aa74003de9d8' +down_revision = '69f7b110a98c' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('affidavits_history', + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('document_id', sa.String(length=60), autoincrement=False, nullable=True), + sa.Column('issuer', sa.String(length=250), autoincrement=False, nullable=True), + sa.Column('status_code', sa.String(length=15), autoincrement=False, nullable=False), + sa.Column('decision_made_by', sa.String(length=250), autoincrement=False, nullable=True), + sa.Column('decision_made_on', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('user_id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('changed', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['status_code'], ['affidavit_statuses.code'], ), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id', 'version'), + sqlite_autoincrement=True + ) + with op.batch_alter_table('affidavits_history', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_affidavits_history_document_id'), ['document_id'], unique=False) + + op.create_table('orgs_history', + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('uuid', sa.UUID(), autoincrement=False, nullable=False), + sa.Column('type_code', sa.String(length=15), autoincrement=False, nullable=False), + sa.Column('status_code', sa.String(length=30), autoincrement=False, nullable=False), + sa.Column('name', sa.String(length=250), autoincrement=False, nullable=True), + sa.Column('branch_name', sa.String(length=100), autoincrement=False, nullable=True), + sa.Column('access_type', sa.String(length=250), autoincrement=False, nullable=True), + sa.Column('decision_made_by', sa.String(length=250), autoincrement=False, nullable=True), + sa.Column('decision_made_on', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('bcol_user_id', sa.String(length=20), autoincrement=False, nullable=True), + sa.Column('bcol_account_id', sa.String(length=20), autoincrement=False, nullable=True), + sa.Column('bcol_account_name', sa.String(length=250), autoincrement=False, nullable=True), + sa.Column('suspended_on', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('suspension_reason_code', sa.String(length=15), autoincrement=False, nullable=True), + sa.Column('has_api_access', sa.Boolean(), autoincrement=False, nullable=True), + sa.Column('business_type', sa.String(length=15), autoincrement=False, nullable=True), + sa.Column('business_size', sa.String(length=15), autoincrement=False, nullable=True), + sa.Column('is_business_account', sa.Boolean(), autoincrement=False, nullable=True), + sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('changed', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['business_size'], ['business_size_codes.code'], name='orgs_business_size_fkey', ondelete='SET NULL'), + sa.ForeignKeyConstraint(['business_type'], ['business_type_codes.code'], name='orgs_business_type_fkey', ondelete='SET NULL'), + sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['status_code'], ['org_statuses.code'], ), + sa.ForeignKeyConstraint(['suspension_reason_code'], ['suspension_reason_codes.code'], name='orgs_suspension_reason_code_fkey', ondelete='SET NULL'), + sa.ForeignKeyConstraint(['type_code'], ['org_types.code'], ), + sa.PrimaryKeyConstraint('id', 'version'), + sqlite_autoincrement=True + ) + with op.batch_alter_table('orgs_history', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_orgs_history_access_type'), ['access_type'], unique=False) + batch_op.create_index(batch_op.f('ix_orgs_history_name'), ['name'], unique=False) + + op.create_table('account_login_options_history', + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('login_source', sa.String(length=20), autoincrement=False, nullable=False), + sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('is_active', sa.Boolean(), autoincrement=False, nullable=True), + sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('changed', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), + sa.PrimaryKeyConstraint('id', 'version'), + sqlite_autoincrement=True + ) + op.create_table('affiliations_history', + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('entity_id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('certified_by_name', sa.String(length=100), autoincrement=False, nullable=True), + sa.Column('environment', sa.String(length=20), autoincrement=False, nullable=True), + sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('changed', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['entity_id'], ['entities.id'], ), + sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), + sa.PrimaryKeyConstraint('id', 'version'), + sqlite_autoincrement=True + ) + with op.batch_alter_table('affiliations_history', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_affiliations_history_entity_id'), ['entity_id'], unique=False) + batch_op.create_index(batch_op.f('ix_affiliations_history_environment'), ['environment'], unique=False) + + op.create_table('contacts_history', + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('street', sa.String(length=250), autoincrement=False, nullable=True), + sa.Column('street_additional', sa.String(length=250), autoincrement=False, nullable=True), + sa.Column('city', sa.String(length=100), autoincrement=False, nullable=True), + sa.Column('region', sa.String(length=100), autoincrement=False, nullable=True), + sa.Column('country', sa.String(length=20), autoincrement=False, nullable=True), + sa.Column('postal_code', sa.String(length=15), autoincrement=False, nullable=True), + sa.Column('delivery_instructions', sa.String(length=4096), autoincrement=False, nullable=True), + sa.Column('phone', sa.String(length=15), autoincrement=False, nullable=True), + sa.Column('phone_extension', sa.String(length=10), autoincrement=False, nullable=True), + sa.Column('email', sa.String(length=100), autoincrement=False, nullable=True), + sa.Column('entity_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('changed', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['entity_id'], ['entities.id'], ), + sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id', 'version'), + sqlite_autoincrement=True + ) + with op.batch_alter_table('contacts_history', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_contacts_history_street'), ['street'], unique=False) + + op.create_table('memberships_history', + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('user_id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('membership_type_code', sa.String(length=15), autoincrement=False, nullable=False), + sa.Column('status', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('changed', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['membership_type_code'], ['membership_types.code'], ), + sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), + sa.ForeignKeyConstraint(['status'], ['membership_status_codes.id'], ), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id', 'version'), + sqlite_autoincrement=True + ) + with op.batch_alter_table('memberships_history', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_memberships_history_org_id'), ['org_id'], unique=False) + batch_op.create_index(batch_op.f('ix_memberships_history_status'), ['status'], unique=False) + batch_op.create_index(batch_op.f('ix_memberships_history_user_id'), ['user_id'], unique=False) + + op.create_table('org_settings_history', + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('setting', sa.String(length=100), autoincrement=False, nullable=True), + sa.Column('enabled', sa.Boolean(), autoincrement=False, nullable=False), + sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('changed', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), + sa.PrimaryKeyConstraint('id', 'version'), + sqlite_autoincrement=True + ) + op.create_table('product_subscriptions_history', + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('product_code', sa.String(length=15), autoincrement=False, nullable=False), + sa.Column('status_code', sa.String(length=30), autoincrement=False, nullable=False), + sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('changed', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), + sa.ForeignKeyConstraint(['product_code'], ['product_codes.code'], ), + sa.ForeignKeyConstraint(['status_code'], ['product_subscriptions_statuses.code'], ), + sa.PrimaryKeyConstraint('id', 'version'), + sqlite_autoincrement=True + ) + with op.batch_alter_table('product_subscriptions_history', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_product_subscriptions_history_org_id'), ['org_id'], unique=False) + + op.create_table('contact_links_history', + sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('contact_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('entity_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('user_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('affidavit_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), + sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), + sa.Column('changed', sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(['affidavit_id'], ['affidavits.id'], ), + sa.ForeignKeyConstraint(['contact_id'], ['contacts.id'], ), + sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['entity_id'], ['entities.id'], ), + sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id', 'version'), + sqlite_autoincrement=True + ) + with op.batch_alter_table('contact_links_history', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_contact_links_history_contact_id'), ['contact_id'], unique=False) + batch_op.create_index(batch_op.f('ix_contact_links_history_entity_id'), ['entity_id'], unique=False) + batch_op.create_index(batch_op.f('ix_contact_links_history_org_id'), ['org_id'], unique=False) + batch_op.create_index(batch_op.f('ix_contact_links_history_user_id'), ['user_id'], unique=False) + + with op.batch_alter_table('activity', schema=None) as batch_op: + batch_op.drop_index('ix_activity_transaction_id') + + op.drop_table('activity') + with op.batch_alter_table('memberships_version', schema=None) as batch_op: + batch_op.drop_index('ix_memberships_version_end_transaction_id') + batch_op.drop_index('ix_memberships_version_operation_type') + batch_op.drop_index('ix_memberships_version_org_id') + batch_op.drop_index('ix_memberships_version_status') + batch_op.drop_index('ix_memberships_version_transaction_id') + batch_op.drop_index('ix_memberships_version_user_id') + + op.drop_table('memberships_version') + with op.batch_alter_table('users_version', schema=None) as batch_op: + batch_op.drop_index('ix_users_version_email') + batch_op.drop_index('ix_users_version_end_transaction_id') + batch_op.drop_index('ix_users_version_first_name') + batch_op.drop_index('ix_users_version_idp_userid') + batch_op.drop_index('ix_users_version_last_name') + batch_op.drop_index('ix_users_version_operation_type') + batch_op.drop_index('ix_users_version_transaction_id') + batch_op.drop_index('ix_users_version_username') + + op.drop_table('users_version') + with op.batch_alter_table('account_login_options_version', schema=None) as batch_op: + batch_op.drop_index('ix_account_login_options_version_end_transaction_id') + batch_op.drop_index('ix_account_login_options_version_operation_type') + batch_op.drop_index('ix_account_login_options_version_transaction_id') + + op.drop_table('account_login_options_version') + with op.batch_alter_table('affiliations_version', schema=None) as batch_op: + batch_op.drop_index('ix_affiliations_version_end_transaction_id') + batch_op.drop_index('ix_affiliations_version_entity_id') + batch_op.drop_index('ix_affiliations_version_environment') + batch_op.drop_index('ix_affiliations_version_operation_type') + batch_op.drop_index('ix_affiliations_version_transaction_id') + + op.drop_table('affiliations_version') + with op.batch_alter_table('contact_links_version', schema=None) as batch_op: + batch_op.drop_index('ix_contact_links_version_contact_id') + batch_op.drop_index('ix_contact_links_version_end_transaction_id') + batch_op.drop_index('ix_contact_links_version_entity_id') + batch_op.drop_index('ix_contact_links_version_operation_type') + batch_op.drop_index('ix_contact_links_version_org_id') + batch_op.drop_index('ix_contact_links_version_transaction_id') + batch_op.drop_index('ix_contact_links_version_user_id') + + op.drop_table('contact_links_version') + with op.batch_alter_table('affidavits_version', schema=None) as batch_op: + batch_op.drop_index('ix_affidavits_version_document_id') + batch_op.drop_index('ix_affidavits_version_end_transaction_id') + batch_op.drop_index('ix_affidavits_version_operation_type') + batch_op.drop_index('ix_affidavits_version_transaction_id') + + op.drop_table('affidavits_version') + with op.batch_alter_table('org_settings_version', schema=None) as batch_op: + batch_op.drop_index('ix_org_settings_version_end_transaction_id') + batch_op.drop_index('ix_org_settings_version_operation_type') + batch_op.drop_index('ix_org_settings_version_transaction_id') + + op.drop_table('org_settings_version') + with op.batch_alter_table('product_subscriptions_version', schema=None) as batch_op: + batch_op.drop_index('ix_product_subscriptions_version_end_transaction_id') + batch_op.drop_index('ix_product_subscriptions_version_operation_type') + batch_op.drop_index('ix_product_subscriptions_version_org_id') + batch_op.drop_index('ix_product_subscriptions_version_transaction_id') + + op.drop_table('product_subscriptions_version') + with op.batch_alter_table('orgs_version', schema=None) as batch_op: + batch_op.drop_index('ix_orgs_version_access_type') + batch_op.drop_index('ix_orgs_version_end_transaction_id') + batch_op.drop_index('ix_orgs_version_name') + batch_op.drop_index('ix_orgs_version_operation_type') + batch_op.drop_index('ix_orgs_version_transaction_id') + + op.drop_table('orgs_version') + op.drop_table('transaction') + with op.batch_alter_table('contacts_version', schema=None) as batch_op: + batch_op.drop_index('ix_contacts_version_end_transaction_id') + batch_op.drop_index('ix_contacts_version_operation_type') + batch_op.drop_index('ix_contacts_version_street') + batch_op.drop_index('ix_contacts_version_transaction_id') + + op.drop_table('contacts_version') + with op.batch_alter_table('affiliation_invitation_types', schema=None) as batch_op: + batch_op.alter_column('description', + existing_type=sa.VARCHAR(length=100), + nullable=True) + + with op.batch_alter_table('affiliation_invitations', schema=None) as batch_op: + batch_op.alter_column('token', + existing_type=sa.VARCHAR(length=150), + type_=sa.String(length=100), + existing_nullable=True) + batch_op.alter_column('is_deleted', + existing_type=sa.BOOLEAN(), + nullable=True, + existing_server_default=sa.text('false')) + batch_op.create_index(batch_op.f('ix_affiliation_invitations_affiliation_id'), ['affiliation_id'], unique=False) + batch_op.create_index(batch_op.f('ix_affiliation_invitations_entity_id'), ['entity_id'], unique=False) + batch_op.create_index(batch_op.f('ix_affiliation_invitations_from_org_id'), ['from_org_id'], unique=False) + batch_op.create_index(batch_op.f('ix_affiliation_invitations_to_org_id'), ['to_org_id'], unique=False) + batch_op.create_foreign_key(None, 'affiliations', ['affiliation_id'], ['id']) + + with op.batch_alter_table('product_codes', schema=None) as batch_op: + batch_op.alter_column('parent_code', + existing_type=sa.VARCHAR(length=15), + type_=sa.String(length=75), + existing_nullable=True) + + with op.batch_alter_table('users', schema=None) as batch_op: + batch_op.drop_column('version') + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('users', schema=None) as batch_op: + batch_op.add_column(sa.Column('version', sa.INTEGER(), server_default=sa.text('1'), autoincrement=False, nullable=False)) + + with op.batch_alter_table('product_codes', schema=None) as batch_op: + batch_op.alter_column('parent_code', + existing_type=sa.String(length=75), + type_=sa.VARCHAR(length=15), + existing_nullable=True) + + with op.batch_alter_table('affiliation_invitations', schema=None) as batch_op: + batch_op.drop_constraint(None, type_='foreignkey') + batch_op.drop_index(batch_op.f('ix_affiliation_invitations_to_org_id')) + batch_op.drop_index(batch_op.f('ix_affiliation_invitations_from_org_id')) + batch_op.drop_index(batch_op.f('ix_affiliation_invitations_entity_id')) + batch_op.drop_index(batch_op.f('ix_affiliation_invitations_affiliation_id')) + batch_op.alter_column('is_deleted', + existing_type=sa.BOOLEAN(), + nullable=False, + existing_server_default=sa.text('false')) + batch_op.alter_column('token', + existing_type=sa.String(length=100), + type_=sa.VARCHAR(length=150), + existing_nullable=True) + + with op.batch_alter_table('affiliation_invitation_types', schema=None) as batch_op: + batch_op.alter_column('description', + existing_type=sa.VARCHAR(length=100), + nullable=False) + + op.create_table('contacts_version', + sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('street', sa.VARCHAR(length=250), autoincrement=False, nullable=True), + sa.Column('street_additional', sa.VARCHAR(length=250), autoincrement=False, nullable=True), + sa.Column('city', sa.VARCHAR(length=100), autoincrement=False, nullable=True), + sa.Column('region', sa.VARCHAR(length=100), autoincrement=False, nullable=True), + sa.Column('country', sa.VARCHAR(length=20), autoincrement=False, nullable=True), + sa.Column('postal_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), + sa.Column('delivery_instructions', sa.VARCHAR(length=4096), autoincrement=False, nullable=True), + sa.Column('phone', sa.VARCHAR(length=15), autoincrement=False, nullable=True), + sa.Column('phone_extension', sa.VARCHAR(length=10), autoincrement=False, nullable=True), + sa.Column('email', sa.VARCHAR(length=100), autoincrement=False, nullable=True), + sa.Column('entity_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), + sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', 'transaction_id', name='contact_version_pkey') + ) + with op.batch_alter_table('contacts_version', schema=None) as batch_op: + batch_op.create_index('ix_contacts_version_transaction_id', ['transaction_id'], unique=False) + batch_op.create_index('ix_contacts_version_street', ['street'], unique=False) + batch_op.create_index('ix_contacts_version_operation_type', ['operation_type'], unique=False) + batch_op.create_index('ix_contacts_version_end_transaction_id', ['end_transaction_id'], unique=False) + + op.create_table('transaction', + sa.Column('issued_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('id', sa.BIGINT(), autoincrement=True, nullable=False), + sa.Column('remote_addr', sa.VARCHAR(length=50), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', name='transaction_pkey') + ) + op.create_table('orgs_version', + sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('type_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), + sa.Column('status_code', sa.VARCHAR(length=30), autoincrement=False, nullable=True), + sa.Column('name', sa.VARCHAR(length=250), autoincrement=False, nullable=True), + sa.Column('access_type', sa.VARCHAR(length=250), autoincrement=False, nullable=True), + sa.Column('decision_made_by', sa.VARCHAR(length=250), autoincrement=False, nullable=True), + sa.Column('decision_made_on', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), + sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('bcol_account_id', sa.VARCHAR(length=20), autoincrement=False, nullable=True), + sa.Column('bcol_user_id', sa.VARCHAR(length=20), autoincrement=False, nullable=True), + sa.Column('suspended_on', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('bcol_account_name', sa.VARCHAR(length=250), autoincrement=False, nullable=True), + sa.Column('suspension_reason_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), + sa.Column('branch_name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), + sa.Column('has_api_access', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.Column('is_business_account', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.Column('business_size', sa.VARCHAR(length=15), autoincrement=False, nullable=True), + sa.Column('business_type', sa.VARCHAR(length=15), autoincrement=False, nullable=True), + sa.Column('uuid', sa.UUID(), server_default=sa.text('uuid_generate_v4()'), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', 'transaction_id', name='org_version_pkey') + ) + with op.batch_alter_table('orgs_version', schema=None) as batch_op: + batch_op.create_index('ix_orgs_version_transaction_id', ['transaction_id'], unique=False) + batch_op.create_index('ix_orgs_version_operation_type', ['operation_type'], unique=False) + batch_op.create_index('ix_orgs_version_name', ['name'], unique=False) + batch_op.create_index('ix_orgs_version_end_transaction_id', ['end_transaction_id'], unique=False) + batch_op.create_index('ix_orgs_version_access_type', ['access_type'], unique=False) + + op.create_table('product_subscriptions_version', + sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('product_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), + sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('status_code', sa.VARCHAR(length=30), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', 'transaction_id', name='product_subscription_version_pkey') + ) + with op.batch_alter_table('product_subscriptions_version', schema=None) as batch_op: + batch_op.create_index('ix_product_subscriptions_version_transaction_id', ['transaction_id'], unique=False) + batch_op.create_index('ix_product_subscriptions_version_org_id', ['org_id'], unique=False) + batch_op.create_index('ix_product_subscriptions_version_operation_type', ['operation_type'], unique=False) + batch_op.create_index('ix_product_subscriptions_version_end_transaction_id', ['end_transaction_id'], unique=False) + + op.create_table('org_settings_version', + sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('setting', sa.VARCHAR(length=100), autoincrement=False, nullable=True), + sa.Column('enabled', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), + sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', 'transaction_id', name='org_settings_version_pkey') + ) + with op.batch_alter_table('org_settings_version', schema=None) as batch_op: + batch_op.create_index('ix_org_settings_version_transaction_id', ['transaction_id'], unique=False) + batch_op.create_index('ix_org_settings_version_operation_type', ['operation_type'], unique=False) + batch_op.create_index('ix_org_settings_version_end_transaction_id', ['end_transaction_id'], unique=False) + + op.create_table('affidavits_version', + sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('document_id', sa.VARCHAR(length=60), autoincrement=False, nullable=True), + sa.Column('issuer', sa.VARCHAR(length=250), autoincrement=False, nullable=True), + sa.Column('status_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), + sa.Column('decision_made_by', sa.VARCHAR(length=250), autoincrement=False, nullable=True), + sa.Column('decision_made_on', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), + sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', 'transaction_id', name='affidavit_version_pkey') + ) + with op.batch_alter_table('affidavits_version', schema=None) as batch_op: + batch_op.create_index('ix_affidavits_version_transaction_id', ['transaction_id'], unique=False) + batch_op.create_index('ix_affidavits_version_operation_type', ['operation_type'], unique=False) + batch_op.create_index('ix_affidavits_version_end_transaction_id', ['end_transaction_id'], unique=False) + batch_op.create_index('ix_affidavits_version_document_id', ['document_id'], unique=False) + + op.create_table('contact_links_version', + sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('contact_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('entity_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('affidavit_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), + sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', 'transaction_id', name='contact_link_version_pkey') + ) + with op.batch_alter_table('contact_links_version', schema=None) as batch_op: + batch_op.create_index('ix_contact_links_version_user_id', ['user_id'], unique=False) + batch_op.create_index('ix_contact_links_version_transaction_id', ['transaction_id'], unique=False) + batch_op.create_index('ix_contact_links_version_org_id', ['org_id'], unique=False) + batch_op.create_index('ix_contact_links_version_operation_type', ['operation_type'], unique=False) + batch_op.create_index('ix_contact_links_version_entity_id', ['entity_id'], unique=False) + batch_op.create_index('ix_contact_links_version_end_transaction_id', ['end_transaction_id'], unique=False) + batch_op.create_index('ix_contact_links_version_contact_id', ['contact_id'], unique=False) + + op.create_table('affiliations_version', + sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('entity_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), + sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('certified_by_name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), + sa.Column('environment', sa.VARCHAR(length=20), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', 'transaction_id', name='affiliation_version_pkey') + ) + with op.batch_alter_table('affiliations_version', schema=None) as batch_op: + batch_op.create_index('ix_affiliations_version_transaction_id', ['transaction_id'], unique=False) + batch_op.create_index('ix_affiliations_version_operation_type', ['operation_type'], unique=False) + batch_op.create_index('ix_affiliations_version_environment', ['environment'], unique=False) + batch_op.create_index('ix_affiliations_version_entity_id', ['entity_id'], unique=False) + batch_op.create_index('ix_affiliations_version_end_transaction_id', ['end_transaction_id'], unique=False) + + op.create_table('account_login_options_version', + sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('login_source', sa.VARCHAR(length=20), autoincrement=False, nullable=True), + sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), + sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', 'transaction_id', name='account_login_options_version_pkey') + ) + with op.batch_alter_table('account_login_options_version', schema=None) as batch_op: + batch_op.create_index('ix_account_login_options_version_transaction_id', ['transaction_id'], unique=False) + batch_op.create_index('ix_account_login_options_version_operation_type', ['operation_type'], unique=False) + batch_op.create_index('ix_account_login_options_version_end_transaction_id', ['end_transaction_id'], unique=False) + + op.create_table('users_version', + sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('username', sa.VARCHAR(length=100), autoincrement=False, nullable=True), + sa.Column('first_name', sa.VARCHAR(length=200), autoincrement=False, nullable=True), + sa.Column('last_name', sa.VARCHAR(length=200), autoincrement=False, nullable=True), + sa.Column('email', sa.VARCHAR(length=200), autoincrement=False, nullable=True), + sa.Column('keycloak_guid', sa.UUID(), autoincrement=False, nullable=True), + sa.Column('is_terms_of_use_accepted', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.Column('terms_of_use_accepted_version', sa.VARCHAR(length=10), autoincrement=False, nullable=True), + sa.Column('type', sa.VARCHAR(length=200), autoincrement=False, nullable=True), + sa.Column('status', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('idp_userid', sa.VARCHAR(length=256), autoincrement=False, nullable=True), + sa.Column('login_source', sa.VARCHAR(length=200), autoincrement=False, nullable=True), + sa.Column('login_time', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), + sa.Column('verified', sa.BOOLEAN(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', 'transaction_id', name='user_version_pkey') + ) + with op.batch_alter_table('users_version', schema=None) as batch_op: + batch_op.create_index('ix_users_version_username', ['username'], unique=False) + batch_op.create_index('ix_users_version_transaction_id', ['transaction_id'], unique=False) + batch_op.create_index('ix_users_version_operation_type', ['operation_type'], unique=False) + batch_op.create_index('ix_users_version_last_name', ['last_name'], unique=False) + batch_op.create_index('ix_users_version_idp_userid', ['idp_userid'], unique=False) + batch_op.create_index('ix_users_version_first_name', ['first_name'], unique=False) + batch_op.create_index('ix_users_version_end_transaction_id', ['end_transaction_id'], unique=False) + batch_op.create_index('ix_users_version_email', ['email'], unique=False) + + op.create_table('memberships_version', + sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('membership_type_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), + sa.Column('status', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), + sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), + sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', 'transaction_id', name='membership_version_pkey') + ) + with op.batch_alter_table('memberships_version', schema=None) as batch_op: + batch_op.create_index('ix_memberships_version_user_id', ['user_id'], unique=False) + batch_op.create_index('ix_memberships_version_transaction_id', ['transaction_id'], unique=False) + batch_op.create_index('ix_memberships_version_status', ['status'], unique=False) + batch_op.create_index('ix_memberships_version_org_id', ['org_id'], unique=False) + batch_op.create_index('ix_memberships_version_operation_type', ['operation_type'], unique=False) + batch_op.create_index('ix_memberships_version_end_transaction_id', ['end_transaction_id'], unique=False) + + op.create_table('activity', + sa.Column('id', sa.BIGINT(), autoincrement=True, nullable=False), + sa.Column('verb', sa.VARCHAR(length=255), autoincrement=False, nullable=True), + sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), + sa.Column('data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True), + sa.Column('object_type', sa.VARCHAR(length=255), autoincrement=False, nullable=True), + sa.Column('object_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('object_tx_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('target_type', sa.VARCHAR(length=255), autoincrement=False, nullable=True), + sa.Column('target_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.Column('target_tx_id', sa.BIGINT(), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('id', name='activity_pkey') + ) + with op.batch_alter_table('activity', schema=None) as batch_op: + batch_op.create_index('ix_activity_transaction_id', ['transaction_id'], unique=False) + + with op.batch_alter_table('contact_links_history', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_contact_links_history_user_id')) + batch_op.drop_index(batch_op.f('ix_contact_links_history_org_id')) + batch_op.drop_index(batch_op.f('ix_contact_links_history_entity_id')) + batch_op.drop_index(batch_op.f('ix_contact_links_history_contact_id')) + + op.drop_table('contact_links_history') + with op.batch_alter_table('product_subscriptions_history', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_product_subscriptions_history_org_id')) + + op.drop_table('product_subscriptions_history') + op.drop_table('org_settings_history') + with op.batch_alter_table('memberships_history', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_memberships_history_user_id')) + batch_op.drop_index(batch_op.f('ix_memberships_history_status')) + batch_op.drop_index(batch_op.f('ix_memberships_history_org_id')) + + op.drop_table('memberships_history') + with op.batch_alter_table('contacts_history', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_contacts_history_street')) + + op.drop_table('contacts_history') + with op.batch_alter_table('affiliations_history', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_affiliations_history_environment')) + batch_op.drop_index(batch_op.f('ix_affiliations_history_entity_id')) + + op.drop_table('affiliations_history') + op.drop_table('account_login_options_history') + with op.batch_alter_table('orgs_history', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_orgs_history_name')) + batch_op.drop_index(batch_op.f('ix_orgs_history_access_type')) + + op.drop_table('orgs_history') + with op.batch_alter_table('affidavits_history', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_affidavits_history_document_id')) + + op.drop_table('affidavits_history') + # ### end Alembic commands ### diff --git a/auth-api/poetry.lock b/auth-api/poetry.lock index 2974fa418f..86ad49aa44 100644 --- a/auth-api/poetry.lock +++ b/auth-api/poetry.lock @@ -225,13 +225,13 @@ files = [ [[package]] name = "astroid" -version = "3.2.4" +version = "3.3.3" description = "An abstract syntax tree for Python with inference support." optional = false -python-versions = ">=3.8.0" +python-versions = ">=3.9.0" files = [ - {file = "astroid-3.2.4-py3-none-any.whl", hash = "sha256:413658a61eeca6202a59231abb473f932038fbcbf1666587f66d482083413a25"}, - {file = "astroid-3.2.4.tar.gz", hash = "sha256:0e14202810b30da1b735827f78f5157be2bbd4a7a59b7707ca0bfc2fb4c0063a"}, + {file = "astroid-3.3.3-py3-none-any.whl", hash = "sha256:2d79acfd3c594b6a2d4141fea98a1d62ab4a52e54332b1f1ddcf07b652cc5c0f"}, + {file = "astroid-3.3.3.tar.gz", hash = "sha256:63f8c5370d9bad8294163c87b2d440a7fdf546be6c72bbeac0549c93244dbd72"}, ] [[package]] @@ -403,7 +403,7 @@ Werkzeug = "3.0.0" type = "git" url = "https://github.com/bcgov/sbc-auth.git" reference = "feature-gcp-migration" -resolved_reference = "88914cdadaaf1cc0e1f5fa6c463a7d4e1cdc0c38" +resolved_reference = "b387965a8e56cae6af86754f577c42d8515532e0" subdirectory = "build-deps" [[package]] @@ -1155,18 +1155,18 @@ simple-cloudevent = {git = "https://github.com/daxiom/simple-cloudevent.py.git"} type = "git" url = "https://github.com/bcgov/sbc-connect-common.git" reference = "main" -resolved_reference = "c898988d239dc261b2b186465a1887f15512c102" +resolved_reference = "9904676e019f514f2d9f0a3c66a71d0ceeca119a" subdirectory = "python/gcp-queue" [[package]] name = "google-api-core" -version = "2.19.2" +version = "2.20.0" description = "Google API client core library" optional = false python-versions = ">=3.7" files = [ - {file = "google_api_core-2.19.2-py3-none-any.whl", hash = "sha256:53ec0258f2837dd53bbd3d3df50f5359281b3cc13f800c941dd15a9b5a415af4"}, - {file = "google_api_core-2.19.2.tar.gz", hash = "sha256:ca07de7e8aa1c98a8bfca9321890ad2340ef7f2eb136e558cee68f24b94b0a8f"}, + {file = "google_api_core-2.20.0-py3-none-any.whl", hash = "sha256:ef0591ef03c30bb83f79b3d0575c3f31219001fc9c5cf37024d08310aeffed8a"}, + {file = "google_api_core-2.20.0.tar.gz", hash = "sha256:f74dff1889ba291a4b76c5079df0711810e2d9da81abfdc99957bc961c1eb28f"}, ] [package.dependencies] @@ -1185,13 +1185,13 @@ grpcio-gcp = ["grpcio-gcp (>=0.2.2,<1.0.dev0)"] [[package]] name = "google-auth" -version = "2.34.0" +version = "2.35.0" description = "Google Authentication Library" optional = false python-versions = ">=3.7" files = [ - {file = "google_auth-2.34.0-py2.py3-none-any.whl", hash = "sha256:72fd4733b80b6d777dcde515628a9eb4a577339437012874ea286bca7261ee65"}, - {file = "google_auth-2.34.0.tar.gz", hash = "sha256:8eb87396435c19b20d32abd2f984e31c191a15284af72eb922f10e5bde9c04cc"}, + {file = "google_auth-2.35.0-py2.py3-none-any.whl", hash = "sha256:25df55f327ef021de8be50bad0dfd4a916ad0de96da86cd05661c9297723ad3f"}, + {file = "google_auth-2.35.0.tar.gz", hash = "sha256:f4c64ed4e01e8e8b646ef34c018f8bf3338df0c8e37d8b3bba40e7f574a3278a"}, ] [package.dependencies] @@ -1249,77 +1249,83 @@ grpc = ["grpcio (>=1.44.0,<2.0.0.dev0)"] [[package]] name = "greenlet" -version = "3.1.0" +version = "3.1.1" description = "Lightweight in-process concurrent programming" optional = false python-versions = ">=3.7" files = [ - {file = "greenlet-3.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:a814dc3100e8a046ff48faeaa909e80cdb358411a3d6dd5293158425c684eda8"}, - {file = "greenlet-3.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a771dc64fa44ebe58d65768d869fcfb9060169d203446c1d446e844b62bdfdca"}, - {file = "greenlet-3.1.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:0e49a65d25d7350cca2da15aac31b6f67a43d867448babf997fe83c7505f57bc"}, - {file = "greenlet-3.1.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2cd8518eade968bc52262d8c46727cfc0826ff4d552cf0430b8d65aaf50bb91d"}, - {file = "greenlet-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76dc19e660baea5c38e949455c1181bc018893f25372d10ffe24b3ed7341fb25"}, - {file = "greenlet-3.1.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:c0a5b1c22c82831f56f2f7ad9bbe4948879762fe0d59833a4a71f16e5fa0f682"}, - {file = "greenlet-3.1.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:2651dfb006f391bcb240635079a68a261b227a10a08af6349cba834a2141efa1"}, - {file = "greenlet-3.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:3e7e6ef1737a819819b1163116ad4b48d06cfdd40352d813bb14436024fcda99"}, - {file = "greenlet-3.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:ffb08f2a1e59d38c7b8b9ac8083c9c8b9875f0955b1e9b9b9a965607a51f8e54"}, - {file = "greenlet-3.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9730929375021ec90f6447bff4f7f5508faef1c02f399a1953870cdb78e0c345"}, - {file = "greenlet-3.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:713d450cf8e61854de9420fb7eea8ad228df4e27e7d4ed465de98c955d2b3fa6"}, - {file = "greenlet-3.1.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4c3446937be153718250fe421da548f973124189f18fe4575a0510b5c928f0cc"}, - {file = "greenlet-3.1.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:1ddc7bcedeb47187be74208bc652d63d6b20cb24f4e596bd356092d8000da6d6"}, - {file = "greenlet-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:44151d7b81b9391ed759a2f2865bbe623ef00d648fed59363be2bbbd5154656f"}, - {file = "greenlet-3.1.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6cea1cca3be76c9483282dc7760ea1cc08a6ecec1f0b6ca0a94ea0d17432da19"}, - {file = "greenlet-3.1.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:619935a44f414274a2c08c9e74611965650b730eb4efe4b2270f91df5e4adf9a"}, - {file = "greenlet-3.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:221169d31cada333a0c7fd087b957c8f431c1dba202c3a58cf5a3583ed973e9b"}, - {file = "greenlet-3.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:01059afb9b178606b4b6e92c3e710ea1635597c3537e44da69f4531e111dd5e9"}, - {file = "greenlet-3.1.0-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:24fc216ec7c8be9becba8b64a98a78f9cd057fd2dc75ae952ca94ed8a893bf27"}, - {file = "greenlet-3.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3d07c28b85b350564bdff9f51c1c5007dfb2f389385d1bc23288de51134ca303"}, - {file = "greenlet-3.1.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:243a223c96a4246f8a30ea470c440fe9db1f5e444941ee3c3cd79df119b8eebf"}, - {file = "greenlet-3.1.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:26811df4dc81271033a7836bc20d12cd30938e6bd2e9437f56fa03da81b0f8fc"}, - {file = "greenlet-3.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c9d86401550b09a55410f32ceb5fe7efcd998bd2dad9e82521713cb148a4a15f"}, - {file = "greenlet-3.1.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:26d9c1c4f1748ccac0bae1dbb465fb1a795a75aba8af8ca871503019f4285e2a"}, - {file = "greenlet-3.1.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:cd468ec62257bb4544989402b19d795d2305eccb06cde5da0eb739b63dc04665"}, - {file = "greenlet-3.1.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a53dfe8f82b715319e9953330fa5c8708b610d48b5c59f1316337302af5c0811"}, - {file = "greenlet-3.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:28fe80a3eb673b2d5cc3b12eea468a5e5f4603c26aa34d88bf61bba82ceb2f9b"}, - {file = "greenlet-3.1.0-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:76b3e3976d2a452cba7aa9e453498ac72240d43030fdc6d538a72b87eaff52fd"}, - {file = "greenlet-3.1.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:655b21ffd37a96b1e78cc48bf254f5ea4b5b85efaf9e9e2a526b3c9309d660ca"}, - {file = "greenlet-3.1.0-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c6f4c2027689093775fd58ca2388d58789009116844432d920e9147f91acbe64"}, - {file = "greenlet-3.1.0-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:76e5064fd8e94c3f74d9fd69b02d99e3cdb8fc286ed49a1f10b256e59d0d3a0b"}, - {file = "greenlet-3.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6a4bf607f690f7987ab3291406e012cd8591a4f77aa54f29b890f9c331e84989"}, - {file = "greenlet-3.1.0-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:037d9ac99540ace9424cb9ea89f0accfaff4316f149520b4ae293eebc5bded17"}, - {file = "greenlet-3.1.0-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:90b5bbf05fe3d3ef697103850c2ce3374558f6fe40fd57c9fac1bf14903f50a5"}, - {file = "greenlet-3.1.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:726377bd60081172685c0ff46afbc600d064f01053190e4450857483c4d44484"}, - {file = "greenlet-3.1.0-cp313-cp313-win_amd64.whl", hash = "sha256:d46d5069e2eeda111d6f71970e341f4bd9aeeee92074e649ae263b834286ecc0"}, - {file = "greenlet-3.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:81eeec4403a7d7684b5812a8aaa626fa23b7d0848edb3a28d2eb3220daddcbd0"}, - {file = "greenlet-3.1.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4a3dae7492d16e85ea6045fd11cb8e782b63eac8c8d520c3a92c02ac4573b0a6"}, - {file = "greenlet-3.1.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4b5ea3664eed571779403858d7cd0a9b0ebf50d57d2cdeafc7748e09ef8cd81a"}, - {file = "greenlet-3.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a22f4e26400f7f48faef2d69c20dc055a1f3043d330923f9abe08ea0aecc44df"}, - {file = "greenlet-3.1.0-cp37-cp37m-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:13ff8c8e54a10472ce3b2a2da007f915175192f18e6495bad50486e87c7f6637"}, - {file = "greenlet-3.1.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:f9671e7282d8c6fcabc32c0fb8d7c0ea8894ae85cee89c9aadc2d7129e1a9954"}, - {file = "greenlet-3.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:184258372ae9e1e9bddce6f187967f2e08ecd16906557c4320e3ba88a93438c3"}, - {file = "greenlet-3.1.0-cp37-cp37m-win32.whl", hash = "sha256:a0409bc18a9f85321399c29baf93545152d74a49d92f2f55302f122007cfda00"}, - {file = "greenlet-3.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:9eb4a1d7399b9f3c7ac68ae6baa6be5f9195d1d08c9ddc45ad559aa6b556bce6"}, - {file = "greenlet-3.1.0-cp38-cp38-macosx_11_0_universal2.whl", hash = "sha256:a8870983af660798dc1b529e1fd6f1cefd94e45135a32e58bd70edd694540f33"}, - {file = "greenlet-3.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cfcfb73aed40f550a57ea904629bdaf2e562c68fa1164fa4588e752af6efdc3f"}, - {file = "greenlet-3.1.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f9482c2ed414781c0af0b35d9d575226da6b728bd1a720668fa05837184965b7"}, - {file = "greenlet-3.1.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d58ec349e0c2c0bc6669bf2cd4982d2f93bf067860d23a0ea1fe677b0f0b1e09"}, - {file = "greenlet-3.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dd65695a8df1233309b701dec2539cc4b11e97d4fcc0f4185b4a12ce54db0491"}, - {file = "greenlet-3.1.0-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:665b21e95bc0fce5cab03b2e1d90ba9c66c510f1bb5fdc864f3a377d0f553f6b"}, - {file = "greenlet-3.1.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:d3c59a06c2c28a81a026ff11fbf012081ea34fb9b7052f2ed0366e14896f0a1d"}, - {file = "greenlet-3.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:5415b9494ff6240b09af06b91a375731febe0090218e2898d2b85f9b92abcda0"}, - {file = "greenlet-3.1.0-cp38-cp38-win32.whl", hash = "sha256:1544b8dd090b494c55e60c4ff46e238be44fdc472d2589e943c241e0169bcea2"}, - {file = "greenlet-3.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:7f346d24d74c00b6730440f5eb8ec3fe5774ca8d1c9574e8e57c8671bb51b910"}, - {file = "greenlet-3.1.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:db1b3ccb93488328c74e97ff888604a8b95ae4f35f4f56677ca57a4fc3a4220b"}, - {file = "greenlet-3.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:44cd313629ded43bb3b98737bba2f3e2c2c8679b55ea29ed73daea6b755fe8e7"}, - {file = "greenlet-3.1.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:fad7a051e07f64e297e6e8399b4d6a3bdcad3d7297409e9a06ef8cbccff4f501"}, - {file = "greenlet-3.1.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c3967dcc1cd2ea61b08b0b276659242cbce5caca39e7cbc02408222fb9e6ff39"}, - {file = "greenlet-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d45b75b0f3fd8d99f62eb7908cfa6d727b7ed190737dec7fe46d993da550b81a"}, - {file = "greenlet-3.1.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:2d004db911ed7b6218ec5c5bfe4cf70ae8aa2223dffbb5b3c69e342bb253cb28"}, - {file = "greenlet-3.1.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:b9505a0c8579899057cbefd4ec34d865ab99852baf1ff33a9481eb3924e2da0b"}, - {file = "greenlet-3.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:5fd6e94593f6f9714dbad1aaba734b5ec04593374fa6638df61592055868f8b8"}, - {file = "greenlet-3.1.0-cp39-cp39-win32.whl", hash = "sha256:d0dd943282231480aad5f50f89bdf26690c995e8ff555f26d8a5b9887b559bcc"}, - {file = "greenlet-3.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:ac0adfdb3a21dc2a24ed728b61e72440d297d0fd3a577389df566651fcd08f97"}, - {file = "greenlet-3.1.0.tar.gz", hash = "sha256:b395121e9bbe8d02a750886f108d540abe66075e61e22f7353d9acb0b81be0f0"}, + {file = "greenlet-3.1.1-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:0bbae94a29c9e5c7e4a2b7f0aae5c17e8e90acbfd3bf6270eeba60c39fce3563"}, + {file = "greenlet-3.1.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:0fde093fb93f35ca72a556cf72c92ea3ebfda3d79fc35bb19fbe685853869a83"}, + {file = "greenlet-3.1.1-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:36b89d13c49216cadb828db8dfa6ce86bbbc476a82d3a6c397f0efae0525bdd0"}, + {file = "greenlet-3.1.1-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:94b6150a85e1b33b40b1464a3f9988dcc5251d6ed06842abff82e42632fac120"}, + {file = "greenlet-3.1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:93147c513fac16385d1036b7e5b102c7fbbdb163d556b791f0f11eada7ba65dc"}, + {file = "greenlet-3.1.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:da7a9bff22ce038e19bf62c4dd1ec8391062878710ded0a845bcf47cc0200617"}, + {file = "greenlet-3.1.1-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:b2795058c23988728eec1f36a4e5e4ebad22f8320c85f3587b539b9ac84128d7"}, + {file = "greenlet-3.1.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:ed10eac5830befbdd0c32f83e8aa6288361597550ba669b04c48f0f9a2c843c6"}, + {file = "greenlet-3.1.1-cp310-cp310-win_amd64.whl", hash = "sha256:77c386de38a60d1dfb8e55b8c1101d68c79dfdd25c7095d51fec2dd800892b80"}, + {file = "greenlet-3.1.1-cp311-cp311-macosx_11_0_universal2.whl", hash = "sha256:e4d333e558953648ca09d64f13e6d8f0523fa705f51cae3f03b5983489958c70"}, + {file = "greenlet-3.1.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:09fc016b73c94e98e29af67ab7b9a879c307c6731a2c9da0db5a7d9b7edd1159"}, + {file = "greenlet-3.1.1-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d5e975ca70269d66d17dd995dafc06f1b06e8cb1ec1e9ed54c1d1e4a7c4cf26e"}, + {file = "greenlet-3.1.1-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3b2813dc3de8c1ee3f924e4d4227999285fd335d1bcc0d2be6dc3f1f6a318ec1"}, + {file = "greenlet-3.1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e347b3bfcf985a05e8c0b7d462ba6f15b1ee1c909e2dcad795e49e91b152c383"}, + {file = "greenlet-3.1.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9e8f8c9cb53cdac7ba9793c276acd90168f416b9ce36799b9b885790f8ad6c0a"}, + {file = "greenlet-3.1.1-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:62ee94988d6b4722ce0028644418d93a52429e977d742ca2ccbe1c4f4a792511"}, + {file = "greenlet-3.1.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:1776fd7f989fc6b8d8c8cb8da1f6b82c5814957264d1f6cf818d475ec2bf6395"}, + {file = "greenlet-3.1.1-cp311-cp311-win_amd64.whl", hash = "sha256:48ca08c771c268a768087b408658e216133aecd835c0ded47ce955381105ba39"}, + {file = "greenlet-3.1.1-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:4afe7ea89de619adc868e087b4d2359282058479d7cfb94970adf4b55284574d"}, + {file = "greenlet-3.1.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f406b22b7c9a9b4f8aa9d2ab13d6ae0ac3e85c9a809bd590ad53fed2bf70dc79"}, + {file = "greenlet-3.1.1-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c3a701fe5a9695b238503ce5bbe8218e03c3bcccf7e204e455e7462d770268aa"}, + {file = "greenlet-3.1.1-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2846930c65b47d70b9d178e89c7e1a69c95c1f68ea5aa0a58646b7a96df12441"}, + {file = "greenlet-3.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:99cfaa2110534e2cf3ba31a7abcac9d328d1d9f1b95beede58294a60348fba36"}, + {file = "greenlet-3.1.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1443279c19fca463fc33e65ef2a935a5b09bb90f978beab37729e1c3c6c25fe9"}, + {file = "greenlet-3.1.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:b7cede291382a78f7bb5f04a529cb18e068dd29e0fb27376074b6d0317bf4dd0"}, + {file = "greenlet-3.1.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:23f20bb60ae298d7d8656c6ec6db134bca379ecefadb0b19ce6f19d1f232a942"}, + {file = "greenlet-3.1.1-cp312-cp312-win_amd64.whl", hash = "sha256:7124e16b4c55d417577c2077be379514321916d5790fa287c9ed6f23bd2ffd01"}, + {file = "greenlet-3.1.1-cp313-cp313-macosx_11_0_universal2.whl", hash = "sha256:05175c27cb459dcfc05d026c4232f9de8913ed006d42713cb8a5137bd49375f1"}, + {file = "greenlet-3.1.1-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:935e943ec47c4afab8965954bf49bfa639c05d4ccf9ef6e924188f762145c0ff"}, + {file = "greenlet-3.1.1-cp313-cp313-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:667a9706c970cb552ede35aee17339a18e8f2a87a51fba2ed39ceeeb1004798a"}, + {file = "greenlet-3.1.1-cp313-cp313-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b8a678974d1f3aa55f6cc34dc480169d58f2e6d8958895d68845fa4ab566509e"}, + {file = "greenlet-3.1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:efc0f674aa41b92da8c49e0346318c6075d734994c3c4e4430b1c3f853e498e4"}, + {file = "greenlet-3.1.1-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0153404a4bb921f0ff1abeb5ce8a5131da56b953eda6e14b88dc6bbc04d2049e"}, + {file = "greenlet-3.1.1-cp313-cp313-musllinux_1_1_aarch64.whl", hash = "sha256:275f72decf9932639c1c6dd1013a1bc266438eb32710016a1c742df5da6e60a1"}, + {file = "greenlet-3.1.1-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:c4aab7f6381f38a4b42f269057aee279ab0fc7bf2e929e3d4abfae97b682a12c"}, + {file = "greenlet-3.1.1-cp313-cp313-win_amd64.whl", hash = "sha256:b42703b1cf69f2aa1df7d1030b9d77d3e584a70755674d60e710f0af570f3761"}, + {file = "greenlet-3.1.1-cp313-cp313t-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f1695e76146579f8c06c1509c7ce4dfe0706f49c6831a817ac04eebb2fd02011"}, + {file = "greenlet-3.1.1-cp313-cp313t-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:7876452af029456b3f3549b696bb36a06db7c90747740c5302f74a9e9fa14b13"}, + {file = "greenlet-3.1.1-cp313-cp313t-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:4ead44c85f8ab905852d3de8d86f6f8baf77109f9da589cb4fa142bd3b57b475"}, + {file = "greenlet-3.1.1-cp313-cp313t-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8320f64b777d00dd7ccdade271eaf0cad6636343293a25074cc5566160e4de7b"}, + {file = "greenlet-3.1.1-cp313-cp313t-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:6510bf84a6b643dabba74d3049ead221257603a253d0a9873f55f6a59a65f822"}, + {file = "greenlet-3.1.1-cp313-cp313t-musllinux_1_1_aarch64.whl", hash = "sha256:04b013dc07c96f83134b1e99888e7a79979f1a247e2a9f59697fa14b5862ed01"}, + {file = "greenlet-3.1.1-cp313-cp313t-musllinux_1_1_x86_64.whl", hash = "sha256:411f015496fec93c1c8cd4e5238da364e1da7a124bcb293f085bf2860c32c6f6"}, + {file = "greenlet-3.1.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:47da355d8687fd65240c364c90a31569a133b7b60de111c255ef5b606f2ae291"}, + {file = "greenlet-3.1.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:98884ecf2ffb7d7fe6bd517e8eb99d31ff7855a840fa6d0d63cd07c037f6a981"}, + {file = "greenlet-3.1.1-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:f1d4aeb8891338e60d1ab6127af1fe45def5259def8094b9c7e34690c8858803"}, + {file = "greenlet-3.1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:db32b5348615a04b82240cc67983cb315309e88d444a288934ee6ceaebcad6cc"}, + {file = "greenlet-3.1.1-cp37-cp37m-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:dcc62f31eae24de7f8dce72134c8651c58000d3b1868e01392baea7c32c247de"}, + {file = "greenlet-3.1.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:1d3755bcb2e02de341c55b4fca7a745a24a9e7212ac953f6b3a48d117d7257aa"}, + {file = "greenlet-3.1.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:b8da394b34370874b4572676f36acabac172602abf054cbc4ac910219f3340af"}, + {file = "greenlet-3.1.1-cp37-cp37m-win32.whl", hash = "sha256:a0dfc6c143b519113354e780a50381508139b07d2177cb6ad6a08278ec655798"}, + {file = "greenlet-3.1.1-cp37-cp37m-win_amd64.whl", hash = "sha256:54558ea205654b50c438029505def3834e80f0869a70fb15b871c29b4575ddef"}, + {file = "greenlet-3.1.1-cp38-cp38-macosx_11_0_universal2.whl", hash = "sha256:346bed03fe47414091be4ad44786d1bd8bef0c3fcad6ed3dee074a032ab408a9"}, + {file = "greenlet-3.1.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:dfc59d69fc48664bc693842bd57acfdd490acafda1ab52c7836e3fc75c90a111"}, + {file = "greenlet-3.1.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:d21e10da6ec19b457b82636209cbe2331ff4306b54d06fa04b7c138ba18c8a81"}, + {file = "greenlet-3.1.1-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:37b9de5a96111fc15418819ab4c4432e4f3c2ede61e660b1e33971eba26ef9ba"}, + {file = "greenlet-3.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6ef9ea3f137e5711f0dbe5f9263e8c009b7069d8a1acea822bd5e9dae0ae49c8"}, + {file = "greenlet-3.1.1-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:85f3ff71e2e60bd4b4932a043fbbe0f499e263c628390b285cb599154a3b03b1"}, + {file = "greenlet-3.1.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:95ffcf719966dd7c453f908e208e14cde192e09fde6c7186c8f1896ef778d8cd"}, + {file = "greenlet-3.1.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:03a088b9de532cbfe2ba2034b2b85e82df37874681e8c470d6fb2f8c04d7e4b7"}, + {file = "greenlet-3.1.1-cp38-cp38-win32.whl", hash = "sha256:8b8b36671f10ba80e159378df9c4f15c14098c4fd73a36b9ad715f057272fbef"}, + {file = "greenlet-3.1.1-cp38-cp38-win_amd64.whl", hash = "sha256:7017b2be767b9d43cc31416aba48aab0d2309ee31b4dbf10a1d38fb7972bdf9d"}, + {file = "greenlet-3.1.1-cp39-cp39-macosx_11_0_universal2.whl", hash = "sha256:396979749bd95f018296af156201d6211240e7a23090f50a8d5d18c370084dc3"}, + {file = "greenlet-3.1.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ca9d0ff5ad43e785350894d97e13633a66e2b50000e8a183a50a88d834752d42"}, + {file = "greenlet-3.1.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f6ff3b14f2df4c41660a7dec01045a045653998784bf8cfcb5a525bdffffbc8f"}, + {file = "greenlet-3.1.1-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:94ebba31df2aa506d7b14866fed00ac141a867e63143fe5bca82a8e503b36437"}, + {file = "greenlet-3.1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:73aaad12ac0ff500f62cebed98d8789198ea0e6f233421059fa68a5aa7220145"}, + {file = "greenlet-3.1.1-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:63e4844797b975b9af3a3fb8f7866ff08775f5426925e1e0bbcfe7932059a12c"}, + {file = "greenlet-3.1.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:7939aa3ca7d2a1593596e7ac6d59391ff30281ef280d8632fa03d81f7c5f955e"}, + {file = "greenlet-3.1.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d0028e725ee18175c6e422797c407874da24381ce0690d6b9396c204c7f7276e"}, + {file = "greenlet-3.1.1-cp39-cp39-win32.whl", hash = "sha256:5e06afd14cbaf9e00899fae69b24a32f2196c19de08fcb9f4779dd4f004e5e7c"}, + {file = "greenlet-3.1.1-cp39-cp39-win_amd64.whl", hash = "sha256:3319aa75e0e0639bc15ff54ca327e8dc7a6fe404003496e3c6925cd3142e0e22"}, ] [package.extras] @@ -2128,22 +2134,22 @@ testing = ["google-api-core (>=1.31.5)"] [[package]] name = "protobuf" -version = "5.28.1" +version = "5.28.2" description = "" optional = false python-versions = ">=3.8" files = [ - {file = "protobuf-5.28.1-cp310-abi3-win32.whl", hash = "sha256:fc063acaf7a3d9ca13146fefb5b42ac94ab943ec6e978f543cd5637da2d57957"}, - {file = "protobuf-5.28.1-cp310-abi3-win_amd64.whl", hash = "sha256:4c7f5cb38c640919791c9f74ea80c5b82314c69a8409ea36f2599617d03989af"}, - {file = "protobuf-5.28.1-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:4304e4fceb823d91699e924a1fdf95cde0e066f3b1c28edb665bda762ecde10f"}, - {file = "protobuf-5.28.1-cp38-abi3-manylinux2014_aarch64.whl", hash = "sha256:0dfd86d2b5edf03d91ec2a7c15b4e950258150f14f9af5f51c17fa224ee1931f"}, - {file = "protobuf-5.28.1-cp38-abi3-manylinux2014_x86_64.whl", hash = "sha256:51f09caab818707ab91cf09cc5c156026599cf05a4520779ccbf53c1b352fb25"}, - {file = "protobuf-5.28.1-cp38-cp38-win32.whl", hash = "sha256:1b04bde117a10ff9d906841a89ec326686c48ececeb65690f15b8cabe7149495"}, - {file = "protobuf-5.28.1-cp38-cp38-win_amd64.whl", hash = "sha256:cabfe43044ee319ad6832b2fda332646f9ef1636b0130186a3ae0a52fc264bb4"}, - {file = "protobuf-5.28.1-cp39-cp39-win32.whl", hash = "sha256:4b4b9a0562a35773ff47a3df823177ab71a1f5eb1ff56d8f842b7432ecfd7fd2"}, - {file = "protobuf-5.28.1-cp39-cp39-win_amd64.whl", hash = "sha256:f24e5d70e6af8ee9672ff605d5503491635f63d5db2fffb6472be78ba62efd8f"}, - {file = "protobuf-5.28.1-py3-none-any.whl", hash = "sha256:c529535e5c0effcf417682563719e5d8ac8d2b93de07a56108b4c2d436d7a29a"}, - {file = "protobuf-5.28.1.tar.gz", hash = "sha256:42597e938f83bb7f3e4b35f03aa45208d49ae8d5bcb4bc10b9fc825e0ab5e423"}, + {file = "protobuf-5.28.2-cp310-abi3-win32.whl", hash = "sha256:eeea10f3dc0ac7e6b4933d32db20662902b4ab81bf28df12218aa389e9c2102d"}, + {file = "protobuf-5.28.2-cp310-abi3-win_amd64.whl", hash = "sha256:2c69461a7fcc8e24be697624c09a839976d82ae75062b11a0972e41fd2cd9132"}, + {file = "protobuf-5.28.2-cp38-abi3-macosx_10_9_universal2.whl", hash = "sha256:a8b9403fc70764b08d2f593ce44f1d2920c5077bf7d311fefec999f8c40f78b7"}, + {file = "protobuf-5.28.2-cp38-abi3-manylinux2014_aarch64.whl", hash = "sha256:35cfcb15f213449af7ff6198d6eb5f739c37d7e4f1c09b5d0641babf2cc0c68f"}, + {file = "protobuf-5.28.2-cp38-abi3-manylinux2014_x86_64.whl", hash = "sha256:5e8a95246d581eef20471b5d5ba010d55f66740942b95ba9b872d918c459452f"}, + {file = "protobuf-5.28.2-cp38-cp38-win32.whl", hash = "sha256:87317e9bcda04a32f2ee82089a204d3a2f0d3c8aeed16568c7daf4756e4f1fe0"}, + {file = "protobuf-5.28.2-cp38-cp38-win_amd64.whl", hash = "sha256:c0ea0123dac3399a2eeb1a1443d82b7afc9ff40241433296769f7da42d142ec3"}, + {file = "protobuf-5.28.2-cp39-cp39-win32.whl", hash = "sha256:ca53faf29896c526863366a52a8f4d88e69cd04ec9571ed6082fa117fac3ab36"}, + {file = "protobuf-5.28.2-cp39-cp39-win_amd64.whl", hash = "sha256:8ddc60bf374785fb7cb12510b267f59067fa10087325b8e1855b898a0d81d276"}, + {file = "protobuf-5.28.2-py3-none-any.whl", hash = "sha256:52235802093bd8a2811abbe8bf0ab9c5f54cca0a751fdd3f6ac2a21438bffece"}, + {file = "protobuf-5.28.2.tar.gz", hash = "sha256:59379674ff119717404f7454647913787034f03fe7049cbef1d74a97bb4593f0"}, ] [[package]] @@ -2294,17 +2300,17 @@ files = [ [[package]] name = "pylint" -version = "3.2.7" +version = "3.3.0" description = "python code static checker" optional = false -python-versions = ">=3.8.0" +python-versions = ">=3.9.0" files = [ - {file = "pylint-3.2.7-py3-none-any.whl", hash = "sha256:02f4aedeac91be69fb3b4bea997ce580a4ac68ce58b89eaefeaf06749df73f4b"}, - {file = "pylint-3.2.7.tar.gz", hash = "sha256:1b7a721b575eaeaa7d39db076b6e7743c993ea44f57979127c517c6c572c803e"}, + {file = "pylint-3.3.0-py3-none-any.whl", hash = "sha256:02dce1845f68974b9b03045894eb3bf05a8b3c7da9fd10af4de3c91e69eb92f1"}, + {file = "pylint-3.3.0.tar.gz", hash = "sha256:c685fe3c061ee5fb0ce7c29436174ab84a2f525fce2a268b1986e921e083fe22"}, ] [package.dependencies] -astroid = ">=3.2.4,<=3.3.0-dev0" +astroid = ">=3.3.3,<=3.4.0-dev0" colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} dill = {version = ">=0.3.7", markers = "python_version >= \"3.12\""} isort = ">=4.2.5,<5.13.0 || >5.13.0,<6" @@ -2726,7 +2732,7 @@ develop = false type = "git" url = "https://github.com/bcgov/sbc-connect-common.git" reference = "main" -resolved_reference = "c898988d239dc261b2b186465a1887f15512c102" +resolved_reference = "9904676e019f514f2d9f0a3c66a71d0ceeca119a" subdirectory = "python/sql-versioning" [[package]] @@ -2902,7 +2908,7 @@ structlog = "^24.1.0" type = "git" url = "https://github.com/bcgov/sbc-connect-common.git" reference = "main" -resolved_reference = "c898988d239dc261b2b186465a1887f15512c102" +resolved_reference = "9904676e019f514f2d9f0a3c66a71d0ceeca119a" subdirectory = "python/structured-logging" [[package]] diff --git a/auth-api/pyproject.toml b/auth-api/pyproject.toml index 18da062e52..466cbd5f13 100644 --- a/auth-api/pyproject.toml +++ b/auth-api/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "auth-api" -version = "3.0.1" +version = "3.0.2" description = "" authors = ["\"BC Registries and Online Services\""] readme = "README.md" diff --git a/auth-api/src/auth_api/exceptions/exception_handler.py b/auth-api/src/auth_api/exceptions/exception_handler.py index fec3aab7fc..05d21b9cbc 100644 --- a/auth-api/src/auth_api/exceptions/exception_handler.py +++ b/auth-api/src/auth_api/exceptions/exception_handler.py @@ -32,12 +32,12 @@ def __init__(self, app=None): if app: self.init_app(app) - def auth_handler(self, error): # pylint: disable=no-self-use + def auth_handler(self, error): # pylint: disable=useless-option-value """Handle AuthError.""" http_logger.error(error.error) return error.error, error.status_code, RESPONSE_HEADERS - def db_handler(self, error): # pylint: disable=no-self-use + def db_handler(self, error): # pylint: disable=useless-option-value """Handle Database error.""" logger.exception(error) error_text = error.__dict__["code"] if hasattr(error.__dict__, "code") else "" @@ -45,14 +45,16 @@ def db_handler(self, error): # pylint: disable=no-self-use status_code = error.status_code if hasattr(error, "status_code") else 500 return {"error": "{}".format(error_text), "message": "{}".format(message_text)}, status_code, RESPONSE_HEADERS - def std_handler(self, error): # pylint: disable=no-self-use + def std_handler(self, error): # pylint: disable=useless-option-value """Handle standard exception.""" if isinstance(error, HTTPException): http_logger.error(error) - message = dict(message=error.message if hasattr(error, "message") else error.description) + message = dict( # pylint: disable=use-dict-literal + message=error.message if hasattr(error, "message") else error.description + ) else: logger.exception(error) - message = dict(message="Internal server error") + message = dict(message="Internal server error") # pylint: disable=use-dict-literal return message, error.code if isinstance(error, HTTPException) else 500, RESPONSE_HEADERS def init_app(self, app): diff --git a/auth-api/src/auth_api/models/activity_log.py b/auth-api/src/auth_api/models/activity_log.py index 7a4f2440b0..df850bd379 100644 --- a/auth-api/src/auth_api/models/activity_log.py +++ b/auth-api/src/auth_api/models/activity_log.py @@ -34,7 +34,7 @@ class ActivityLog(BaseModel): # pylint: disable=too-few-public-methods,too-many org_id = Column(Integer, nullable=True, index=True) @classmethod - def fetch_activity_logs_for_account( # pylint: disable=too-many-arguments + def fetch_activity_logs_for_account( # pylint: disable=too-many-positional-arguments,too-many-arguments cls, org_id: int, item_name: str, diff --git a/auth-api/src/auth_api/models/entity.py b/auth-api/src/auth_api/models/entity.py index 856bb25a41..4db1784a80 100644 --- a/auth-api/src/auth_api/models/entity.py +++ b/auth-api/src/auth_api/models/entity.py @@ -15,8 +15,6 @@ The class and schema are both present in this module. """ - -from flask import current_app from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String from sqlalchemy.orm import relationship diff --git a/auth-api/src/auth_api/models/user.py b/auth-api/src/auth_api/models/user.py index a4464a1e01..77ed093294 100644 --- a/auth-api/src/auth_api/models/user.py +++ b/auth-api/src/auth_api/models/user.py @@ -146,7 +146,7 @@ def create_from_jwt_token(cls, first_name: str, last_name: str, **kwargs): @user_context def update_from_jwt_token( cls, - user, # pylint:disable=too-many-arguments + user, # pylint:disable=too-many-positional-arguments first_name: str, last_name: str, is_login: bool = False, diff --git a/auth-api/src/auth_api/models/user_settings.py b/auth-api/src/auth_api/models/user_settings.py index c739170117..a19de0d26e 100644 --- a/auth-api/src/auth_api/models/user_settings.py +++ b/auth-api/src/auth_api/models/user_settings.py @@ -26,7 +26,7 @@ class UserSettings: # pylint: disable=too-few-public-methods, too-many-instance Can extended to product which user has access to. """ - def __init__( # pylint: disable=too-many-arguments + def __init__( # pylint: disable=too-many-positional-arguments,too-many-arguments self, id_, label, diff --git a/auth-api/src/auth_api/services/invitation.py b/auth-api/src/auth_api/services/invitation.py index ad51e2ba81..87e76bd011 100644 --- a/auth-api/src/auth_api/services/invitation.py +++ b/auth-api/src/auth_api/services/invitation.py @@ -263,7 +263,7 @@ def send_admin_notification(user, url, recipient_email_list, org_name, org_id): raise BusinessException(Error.FAILED_NOTIFICATION, None) from e @staticmethod - def send_invitation( # pylint: disable=too-many-arguments + def send_invitation( # pylint: disable=too-many-positional-arguments,too-many-arguments invitation: InvitationModel, org_name, org_id, diff --git a/auth-api/src/auth_api/services/org.py b/auth-api/src/auth_api/services/org.py index 4041e0f23d..369b378a12 100644 --- a/auth-api/src/auth_api/services/org.py +++ b/auth-api/src/auth_api/services/org.py @@ -213,7 +213,7 @@ def create_membership(access_type, org, user_id, **kwargs): @user_context def _create_payment_settings( org_model: OrgModel, - payment_info: dict, # pylint: disable=too-many-arguments + payment_info: dict, # pylint: disable=too-many-positional-arguments payment_method: str, mailing_address=None, is_new_org: bool = True, diff --git a/auth-api/src/auth_api/services/rest_service.py b/auth-api/src/auth_api/services/rest_service.py index 64a7a043a1..3afbdb602e 100644 --- a/auth-api/src/auth_api/services/rest_service.py +++ b/auth-api/src/auth_api/services/rest_service.py @@ -40,7 +40,7 @@ class RestService: """Service to invoke Rest services which uses OAuth 2.0 implementation.""" @staticmethod - def _invoke( # pylint: disable=too-many-arguments + def _invoke( # pylint: disable=too-many-positional-arguments,too-many-arguments rest_method, endpoint, token=None, @@ -102,7 +102,7 @@ def __log_response(response): current_app.logger.info(f"response : {response.text if response else ''}") @staticmethod - def post( # pylint: disable=too-many-arguments + def post( # pylint: disable=too-many-positional-arguments,too-many-arguments endpoint, token=None, auth_header_type: AuthHeaderType = AuthHeaderType.BEARER, @@ -127,7 +127,7 @@ def post( # pylint: disable=too-many-arguments ) @staticmethod - def put( # pylint: disable=too-many-arguments + def put( # pylint: disable=too-many-positional-arguments,too-many-arguments endpoint, token=None, auth_header_type: AuthHeaderType = AuthHeaderType.BEARER, @@ -140,7 +140,7 @@ def put( # pylint: disable=too-many-arguments return RestService._invoke("put", endpoint, token, auth_header_type, content_type, data, raise_for_status) @staticmethod - def patch( # pylint: disable=too-many-arguments + def patch( # pylint: disable=too-many-positional-arguments,too-many-arguments endpoint, token=None, auth_header_type: AuthHeaderType = AuthHeaderType.BEARER, @@ -165,7 +165,7 @@ def patch( # pylint: disable=too-many-arguments ) @staticmethod - def delete( # pylint: disable=too-many-arguments + def delete( # pylint: disable=too-many-positional-arguments,too-many-arguments endpoint, token=None, auth_header_type: AuthHeaderType = AuthHeaderType.BEARER, @@ -190,7 +190,7 @@ def delete( # pylint: disable=too-many-arguments ) @staticmethod - def get( # pylint: disable=too-many-arguments + def get( # pylint: disable=too-many-positional-arguments,too-many-arguments endpoint, token=None, auth_header_type: AuthHeaderType = AuthHeaderType.BEARER, From aac583826b2216bb68971c82e05c02b0eea6530d Mon Sep 17 00:00:00 2001 From: pwei1018 Date: Fri, 20 Sep 2024 11:43:56 -0700 Subject: [PATCH 3/8] Remove version tables from script. --- .../versions/2024_09_20_aa74003de9d8_.py | 1103 +++++++---------- 1 file changed, 440 insertions(+), 663 deletions(-) diff --git a/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py b/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py index 4327a03289..8f0f7ae908 100644 --- a/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py +++ b/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py @@ -5,693 +5,470 @@ Create Date: 2024-09-20 11:19:42.551199 """ + from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision = 'aa74003de9d8' -down_revision = '69f7b110a98c' +revision = "aa74003de9d8" +down_revision = "69f7b110a98c" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.create_table('affidavits_history', - sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('document_id', sa.String(length=60), autoincrement=False, nullable=True), - sa.Column('issuer', sa.String(length=250), autoincrement=False, nullable=True), - sa.Column('status_code', sa.String(length=15), autoincrement=False, nullable=False), - sa.Column('decision_made_by', sa.String(length=250), autoincrement=False, nullable=True), - sa.Column('decision_made_on', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('user_id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('changed', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['status_code'], ['affidavit_statuses.code'], ), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), - sa.PrimaryKeyConstraint('id', 'version'), - sqlite_autoincrement=True + op.create_table( + "affidavits_history", + sa.Column("id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("document_id", sa.String(length=60), autoincrement=False, nullable=True), + sa.Column("issuer", sa.String(length=250), autoincrement=False, nullable=True), + sa.Column("status_code", sa.String(length=15), autoincrement=False, nullable=False), + sa.Column("decision_made_by", sa.String(length=250), autoincrement=False, nullable=True), + sa.Column("decision_made_on", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("user_id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("created", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("modified", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("created_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("version", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("changed", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint( + ["created_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["modified_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["status_code"], + ["affidavit_statuses.code"], + ), + sa.ForeignKeyConstraint( + ["user_id"], + ["users.id"], + ), + sa.PrimaryKeyConstraint("id", "version"), + sqlite_autoincrement=True, ) - with op.batch_alter_table('affidavits_history', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_affidavits_history_document_id'), ['document_id'], unique=False) - - op.create_table('orgs_history', - sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('uuid', sa.UUID(), autoincrement=False, nullable=False), - sa.Column('type_code', sa.String(length=15), autoincrement=False, nullable=False), - sa.Column('status_code', sa.String(length=30), autoincrement=False, nullable=False), - sa.Column('name', sa.String(length=250), autoincrement=False, nullable=True), - sa.Column('branch_name', sa.String(length=100), autoincrement=False, nullable=True), - sa.Column('access_type', sa.String(length=250), autoincrement=False, nullable=True), - sa.Column('decision_made_by', sa.String(length=250), autoincrement=False, nullable=True), - sa.Column('decision_made_on', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('bcol_user_id', sa.String(length=20), autoincrement=False, nullable=True), - sa.Column('bcol_account_id', sa.String(length=20), autoincrement=False, nullable=True), - sa.Column('bcol_account_name', sa.String(length=250), autoincrement=False, nullable=True), - sa.Column('suspended_on', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('suspension_reason_code', sa.String(length=15), autoincrement=False, nullable=True), - sa.Column('has_api_access', sa.Boolean(), autoincrement=False, nullable=True), - sa.Column('business_type', sa.String(length=15), autoincrement=False, nullable=True), - sa.Column('business_size', sa.String(length=15), autoincrement=False, nullable=True), - sa.Column('is_business_account', sa.Boolean(), autoincrement=False, nullable=True), - sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('changed', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['business_size'], ['business_size_codes.code'], name='orgs_business_size_fkey', ondelete='SET NULL'), - sa.ForeignKeyConstraint(['business_type'], ['business_type_codes.code'], name='orgs_business_type_fkey', ondelete='SET NULL'), - sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['status_code'], ['org_statuses.code'], ), - sa.ForeignKeyConstraint(['suspension_reason_code'], ['suspension_reason_codes.code'], name='orgs_suspension_reason_code_fkey', ondelete='SET NULL'), - sa.ForeignKeyConstraint(['type_code'], ['org_types.code'], ), - sa.PrimaryKeyConstraint('id', 'version'), - sqlite_autoincrement=True + with op.batch_alter_table("affidavits_history", schema=None) as batch_op: + batch_op.create_index(batch_op.f("ix_affidavits_history_document_id"), ["document_id"], unique=False) + + op.create_table( + "orgs_history", + sa.Column("id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("uuid", sa.UUID(), autoincrement=False, nullable=False), + sa.Column("type_code", sa.String(length=15), autoincrement=False, nullable=False), + sa.Column("status_code", sa.String(length=30), autoincrement=False, nullable=False), + sa.Column("name", sa.String(length=250), autoincrement=False, nullable=True), + sa.Column("branch_name", sa.String(length=100), autoincrement=False, nullable=True), + sa.Column("access_type", sa.String(length=250), autoincrement=False, nullable=True), + sa.Column("decision_made_by", sa.String(length=250), autoincrement=False, nullable=True), + sa.Column("decision_made_on", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("bcol_user_id", sa.String(length=20), autoincrement=False, nullable=True), + sa.Column("bcol_account_id", sa.String(length=20), autoincrement=False, nullable=True), + sa.Column("bcol_account_name", sa.String(length=250), autoincrement=False, nullable=True), + sa.Column("suspended_on", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("suspension_reason_code", sa.String(length=15), autoincrement=False, nullable=True), + sa.Column("has_api_access", sa.Boolean(), autoincrement=False, nullable=True), + sa.Column("business_type", sa.String(length=15), autoincrement=False, nullable=True), + sa.Column("business_size", sa.String(length=15), autoincrement=False, nullable=True), + sa.Column("is_business_account", sa.Boolean(), autoincrement=False, nullable=True), + sa.Column("created", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("modified", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("created_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("version", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("changed", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint( + ["business_size"], ["business_size_codes.code"], name="orgs_business_size_fkey", ondelete="SET NULL" + ), + sa.ForeignKeyConstraint( + ["business_type"], ["business_type_codes.code"], name="orgs_business_type_fkey", ondelete="SET NULL" + ), + sa.ForeignKeyConstraint( + ["created_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["modified_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["status_code"], + ["org_statuses.code"], + ), + sa.ForeignKeyConstraint( + ["suspension_reason_code"], + ["suspension_reason_codes.code"], + name="orgs_suspension_reason_code_fkey", + ondelete="SET NULL", + ), + sa.ForeignKeyConstraint( + ["type_code"], + ["org_types.code"], + ), + sa.PrimaryKeyConstraint("id", "version"), + sqlite_autoincrement=True, ) - with op.batch_alter_table('orgs_history', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_orgs_history_access_type'), ['access_type'], unique=False) - batch_op.create_index(batch_op.f('ix_orgs_history_name'), ['name'], unique=False) - - op.create_table('account_login_options_history', - sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('login_source', sa.String(length=20), autoincrement=False, nullable=False), - sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('is_active', sa.Boolean(), autoincrement=False, nullable=True), - sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('changed', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), - sa.PrimaryKeyConstraint('id', 'version'), - sqlite_autoincrement=True + with op.batch_alter_table("orgs_history", schema=None) as batch_op: + batch_op.create_index(batch_op.f("ix_orgs_history_access_type"), ["access_type"], unique=False) + batch_op.create_index(batch_op.f("ix_orgs_history_name"), ["name"], unique=False) + + op.create_table( + "account_login_options_history", + sa.Column("id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("login_source", sa.String(length=20), autoincrement=False, nullable=False), + sa.Column("org_id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("is_active", sa.Boolean(), autoincrement=False, nullable=True), + sa.Column("created", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("modified", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("created_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("version", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("changed", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint( + ["created_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["modified_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["org_id"], + ["orgs.id"], + ), + sa.PrimaryKeyConstraint("id", "version"), + sqlite_autoincrement=True, ) - op.create_table('affiliations_history', - sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('entity_id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('certified_by_name', sa.String(length=100), autoincrement=False, nullable=True), - sa.Column('environment', sa.String(length=20), autoincrement=False, nullable=True), - sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('changed', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['entity_id'], ['entities.id'], ), - sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), - sa.PrimaryKeyConstraint('id', 'version'), - sqlite_autoincrement=True + op.create_table( + "affiliations_history", + sa.Column("id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("entity_id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("org_id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("certified_by_name", sa.String(length=100), autoincrement=False, nullable=True), + sa.Column("environment", sa.String(length=20), autoincrement=False, nullable=True), + sa.Column("created", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("modified", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("created_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("version", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("changed", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint( + ["created_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["entity_id"], + ["entities.id"], + ), + sa.ForeignKeyConstraint( + ["modified_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["org_id"], + ["orgs.id"], + ), + sa.PrimaryKeyConstraint("id", "version"), + sqlite_autoincrement=True, ) - with op.batch_alter_table('affiliations_history', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_affiliations_history_entity_id'), ['entity_id'], unique=False) - batch_op.create_index(batch_op.f('ix_affiliations_history_environment'), ['environment'], unique=False) - - op.create_table('contacts_history', - sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('street', sa.String(length=250), autoincrement=False, nullable=True), - sa.Column('street_additional', sa.String(length=250), autoincrement=False, nullable=True), - sa.Column('city', sa.String(length=100), autoincrement=False, nullable=True), - sa.Column('region', sa.String(length=100), autoincrement=False, nullable=True), - sa.Column('country', sa.String(length=20), autoincrement=False, nullable=True), - sa.Column('postal_code', sa.String(length=15), autoincrement=False, nullable=True), - sa.Column('delivery_instructions', sa.String(length=4096), autoincrement=False, nullable=True), - sa.Column('phone', sa.String(length=15), autoincrement=False, nullable=True), - sa.Column('phone_extension', sa.String(length=10), autoincrement=False, nullable=True), - sa.Column('email', sa.String(length=100), autoincrement=False, nullable=True), - sa.Column('entity_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('changed', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['entity_id'], ['entities.id'], ), - sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), - sa.PrimaryKeyConstraint('id', 'version'), - sqlite_autoincrement=True + with op.batch_alter_table("affiliations_history", schema=None) as batch_op: + batch_op.create_index(batch_op.f("ix_affiliations_history_entity_id"), ["entity_id"], unique=False) + batch_op.create_index(batch_op.f("ix_affiliations_history_environment"), ["environment"], unique=False) + + op.create_table( + "contacts_history", + sa.Column("id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("street", sa.String(length=250), autoincrement=False, nullable=True), + sa.Column("street_additional", sa.String(length=250), autoincrement=False, nullable=True), + sa.Column("city", sa.String(length=100), autoincrement=False, nullable=True), + sa.Column("region", sa.String(length=100), autoincrement=False, nullable=True), + sa.Column("country", sa.String(length=20), autoincrement=False, nullable=True), + sa.Column("postal_code", sa.String(length=15), autoincrement=False, nullable=True), + sa.Column("delivery_instructions", sa.String(length=4096), autoincrement=False, nullable=True), + sa.Column("phone", sa.String(length=15), autoincrement=False, nullable=True), + sa.Column("phone_extension", sa.String(length=10), autoincrement=False, nullable=True), + sa.Column("email", sa.String(length=100), autoincrement=False, nullable=True), + sa.Column("entity_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("created", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("modified", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("created_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("version", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("changed", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint( + ["created_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["entity_id"], + ["entities.id"], + ), + sa.ForeignKeyConstraint( + ["modified_by_id"], + ["users.id"], + ), + sa.PrimaryKeyConstraint("id", "version"), + sqlite_autoincrement=True, ) - with op.batch_alter_table('contacts_history', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_contacts_history_street'), ['street'], unique=False) - - op.create_table('memberships_history', - sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('user_id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('membership_type_code', sa.String(length=15), autoincrement=False, nullable=False), - sa.Column('status', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('changed', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['membership_type_code'], ['membership_types.code'], ), - sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), - sa.ForeignKeyConstraint(['status'], ['membership_status_codes.id'], ), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), - sa.PrimaryKeyConstraint('id', 'version'), - sqlite_autoincrement=True + with op.batch_alter_table("contacts_history", schema=None) as batch_op: + batch_op.create_index(batch_op.f("ix_contacts_history_street"), ["street"], unique=False) + + op.create_table( + "memberships_history", + sa.Column("id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("user_id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("org_id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("membership_type_code", sa.String(length=15), autoincrement=False, nullable=False), + sa.Column("status", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("created", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("modified", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("created_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("version", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("changed", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint( + ["created_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["membership_type_code"], + ["membership_types.code"], + ), + sa.ForeignKeyConstraint( + ["modified_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["org_id"], + ["orgs.id"], + ), + sa.ForeignKeyConstraint( + ["status"], + ["membership_status_codes.id"], + ), + sa.ForeignKeyConstraint( + ["user_id"], + ["users.id"], + ), + sa.PrimaryKeyConstraint("id", "version"), + sqlite_autoincrement=True, ) - with op.batch_alter_table('memberships_history', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_memberships_history_org_id'), ['org_id'], unique=False) - batch_op.create_index(batch_op.f('ix_memberships_history_status'), ['status'], unique=False) - batch_op.create_index(batch_op.f('ix_memberships_history_user_id'), ['user_id'], unique=False) - - op.create_table('org_settings_history', - sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('setting', sa.String(length=100), autoincrement=False, nullable=True), - sa.Column('enabled', sa.Boolean(), autoincrement=False, nullable=False), - sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('changed', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), - sa.PrimaryKeyConstraint('id', 'version'), - sqlite_autoincrement=True + with op.batch_alter_table("memberships_history", schema=None) as batch_op: + batch_op.create_index(batch_op.f("ix_memberships_history_org_id"), ["org_id"], unique=False) + batch_op.create_index(batch_op.f("ix_memberships_history_status"), ["status"], unique=False) + batch_op.create_index(batch_op.f("ix_memberships_history_user_id"), ["user_id"], unique=False) + + op.create_table( + "org_settings_history", + sa.Column("id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("org_id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("setting", sa.String(length=100), autoincrement=False, nullable=True), + sa.Column("enabled", sa.Boolean(), autoincrement=False, nullable=False), + sa.Column("created", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("modified", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("created_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("version", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("changed", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint( + ["created_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["modified_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["org_id"], + ["orgs.id"], + ), + sa.PrimaryKeyConstraint("id", "version"), + sqlite_autoincrement=True, ) - op.create_table('product_subscriptions_history', - sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('product_code', sa.String(length=15), autoincrement=False, nullable=False), - sa.Column('status_code', sa.String(length=30), autoincrement=False, nullable=False), - sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('changed', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), - sa.ForeignKeyConstraint(['product_code'], ['product_codes.code'], ), - sa.ForeignKeyConstraint(['status_code'], ['product_subscriptions_statuses.code'], ), - sa.PrimaryKeyConstraint('id', 'version'), - sqlite_autoincrement=True + op.create_table( + "product_subscriptions_history", + sa.Column("id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("org_id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("product_code", sa.String(length=15), autoincrement=False, nullable=False), + sa.Column("status_code", sa.String(length=30), autoincrement=False, nullable=False), + sa.Column("created", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("modified", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("created_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("version", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("changed", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint( + ["created_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["modified_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["org_id"], + ["orgs.id"], + ), + sa.ForeignKeyConstraint( + ["product_code"], + ["product_codes.code"], + ), + sa.ForeignKeyConstraint( + ["status_code"], + ["product_subscriptions_statuses.code"], + ), + sa.PrimaryKeyConstraint("id", "version"), + sqlite_autoincrement=True, ) - with op.batch_alter_table('product_subscriptions_history', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_product_subscriptions_history_org_id'), ['org_id'], unique=False) - - op.create_table('contact_links_history', - sa.Column('id', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('contact_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('entity_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('user_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('org_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('affidavit_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('created', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('modified', sa.DateTime(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.Integer(), autoincrement=False, nullable=True), - sa.Column('version', sa.Integer(), autoincrement=False, nullable=False), - sa.Column('changed', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['affidavit_id'], ['affidavits.id'], ), - sa.ForeignKeyConstraint(['contact_id'], ['contacts.id'], ), - sa.ForeignKeyConstraint(['created_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['entity_id'], ['entities.id'], ), - sa.ForeignKeyConstraint(['modified_by_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['org_id'], ['orgs.id'], ), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), - sa.PrimaryKeyConstraint('id', 'version'), - sqlite_autoincrement=True + with op.batch_alter_table("product_subscriptions_history", schema=None) as batch_op: + batch_op.create_index(batch_op.f("ix_product_subscriptions_history_org_id"), ["org_id"], unique=False) + + op.create_table( + "contact_links_history", + sa.Column("id", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("contact_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("entity_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("user_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("org_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("affidavit_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("created", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("modified", sa.DateTime(), autoincrement=False, nullable=True), + sa.Column("created_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("modified_by_id", sa.Integer(), autoincrement=False, nullable=True), + sa.Column("version", sa.Integer(), autoincrement=False, nullable=False), + sa.Column("changed", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint( + ["affidavit_id"], + ["affidavits.id"], + ), + sa.ForeignKeyConstraint( + ["contact_id"], + ["contacts.id"], + ), + sa.ForeignKeyConstraint( + ["created_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["entity_id"], + ["entities.id"], + ), + sa.ForeignKeyConstraint( + ["modified_by_id"], + ["users.id"], + ), + sa.ForeignKeyConstraint( + ["org_id"], + ["orgs.id"], + ), + sa.ForeignKeyConstraint( + ["user_id"], + ["users.id"], + ), + sa.PrimaryKeyConstraint("id", "version"), + sqlite_autoincrement=True, ) - with op.batch_alter_table('contact_links_history', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_contact_links_history_contact_id'), ['contact_id'], unique=False) - batch_op.create_index(batch_op.f('ix_contact_links_history_entity_id'), ['entity_id'], unique=False) - batch_op.create_index(batch_op.f('ix_contact_links_history_org_id'), ['org_id'], unique=False) - batch_op.create_index(batch_op.f('ix_contact_links_history_user_id'), ['user_id'], unique=False) - - with op.batch_alter_table('activity', schema=None) as batch_op: - batch_op.drop_index('ix_activity_transaction_id') - - op.drop_table('activity') - with op.batch_alter_table('memberships_version', schema=None) as batch_op: - batch_op.drop_index('ix_memberships_version_end_transaction_id') - batch_op.drop_index('ix_memberships_version_operation_type') - batch_op.drop_index('ix_memberships_version_org_id') - batch_op.drop_index('ix_memberships_version_status') - batch_op.drop_index('ix_memberships_version_transaction_id') - batch_op.drop_index('ix_memberships_version_user_id') - - op.drop_table('memberships_version') - with op.batch_alter_table('users_version', schema=None) as batch_op: - batch_op.drop_index('ix_users_version_email') - batch_op.drop_index('ix_users_version_end_transaction_id') - batch_op.drop_index('ix_users_version_first_name') - batch_op.drop_index('ix_users_version_idp_userid') - batch_op.drop_index('ix_users_version_last_name') - batch_op.drop_index('ix_users_version_operation_type') - batch_op.drop_index('ix_users_version_transaction_id') - batch_op.drop_index('ix_users_version_username') - - op.drop_table('users_version') - with op.batch_alter_table('account_login_options_version', schema=None) as batch_op: - batch_op.drop_index('ix_account_login_options_version_end_transaction_id') - batch_op.drop_index('ix_account_login_options_version_operation_type') - batch_op.drop_index('ix_account_login_options_version_transaction_id') - - op.drop_table('account_login_options_version') - with op.batch_alter_table('affiliations_version', schema=None) as batch_op: - batch_op.drop_index('ix_affiliations_version_end_transaction_id') - batch_op.drop_index('ix_affiliations_version_entity_id') - batch_op.drop_index('ix_affiliations_version_environment') - batch_op.drop_index('ix_affiliations_version_operation_type') - batch_op.drop_index('ix_affiliations_version_transaction_id') - - op.drop_table('affiliations_version') - with op.batch_alter_table('contact_links_version', schema=None) as batch_op: - batch_op.drop_index('ix_contact_links_version_contact_id') - batch_op.drop_index('ix_contact_links_version_end_transaction_id') - batch_op.drop_index('ix_contact_links_version_entity_id') - batch_op.drop_index('ix_contact_links_version_operation_type') - batch_op.drop_index('ix_contact_links_version_org_id') - batch_op.drop_index('ix_contact_links_version_transaction_id') - batch_op.drop_index('ix_contact_links_version_user_id') - - op.drop_table('contact_links_version') - with op.batch_alter_table('affidavits_version', schema=None) as batch_op: - batch_op.drop_index('ix_affidavits_version_document_id') - batch_op.drop_index('ix_affidavits_version_end_transaction_id') - batch_op.drop_index('ix_affidavits_version_operation_type') - batch_op.drop_index('ix_affidavits_version_transaction_id') - - op.drop_table('affidavits_version') - with op.batch_alter_table('org_settings_version', schema=None) as batch_op: - batch_op.drop_index('ix_org_settings_version_end_transaction_id') - batch_op.drop_index('ix_org_settings_version_operation_type') - batch_op.drop_index('ix_org_settings_version_transaction_id') - - op.drop_table('org_settings_version') - with op.batch_alter_table('product_subscriptions_version', schema=None) as batch_op: - batch_op.drop_index('ix_product_subscriptions_version_end_transaction_id') - batch_op.drop_index('ix_product_subscriptions_version_operation_type') - batch_op.drop_index('ix_product_subscriptions_version_org_id') - batch_op.drop_index('ix_product_subscriptions_version_transaction_id') - - op.drop_table('product_subscriptions_version') - with op.batch_alter_table('orgs_version', schema=None) as batch_op: - batch_op.drop_index('ix_orgs_version_access_type') - batch_op.drop_index('ix_orgs_version_end_transaction_id') - batch_op.drop_index('ix_orgs_version_name') - batch_op.drop_index('ix_orgs_version_operation_type') - batch_op.drop_index('ix_orgs_version_transaction_id') - - op.drop_table('orgs_version') - op.drop_table('transaction') - with op.batch_alter_table('contacts_version', schema=None) as batch_op: - batch_op.drop_index('ix_contacts_version_end_transaction_id') - batch_op.drop_index('ix_contacts_version_operation_type') - batch_op.drop_index('ix_contacts_version_street') - batch_op.drop_index('ix_contacts_version_transaction_id') - - op.drop_table('contacts_version') - with op.batch_alter_table('affiliation_invitation_types', schema=None) as batch_op: - batch_op.alter_column('description', - existing_type=sa.VARCHAR(length=100), - nullable=True) - - with op.batch_alter_table('affiliation_invitations', schema=None) as batch_op: - batch_op.alter_column('token', - existing_type=sa.VARCHAR(length=150), - type_=sa.String(length=100), - existing_nullable=True) - batch_op.alter_column('is_deleted', - existing_type=sa.BOOLEAN(), - nullable=True, - existing_server_default=sa.text('false')) - batch_op.create_index(batch_op.f('ix_affiliation_invitations_affiliation_id'), ['affiliation_id'], unique=False) - batch_op.create_index(batch_op.f('ix_affiliation_invitations_entity_id'), ['entity_id'], unique=False) - batch_op.create_index(batch_op.f('ix_affiliation_invitations_from_org_id'), ['from_org_id'], unique=False) - batch_op.create_index(batch_op.f('ix_affiliation_invitations_to_org_id'), ['to_org_id'], unique=False) - batch_op.create_foreign_key(None, 'affiliations', ['affiliation_id'], ['id']) - - with op.batch_alter_table('product_codes', schema=None) as batch_op: - batch_op.alter_column('parent_code', - existing_type=sa.VARCHAR(length=15), - type_=sa.String(length=75), - existing_nullable=True) - - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.drop_column('version') + with op.batch_alter_table("contact_links_history", schema=None) as batch_op: + batch_op.create_index(batch_op.f("ix_contact_links_history_contact_id"), ["contact_id"], unique=False) + batch_op.create_index(batch_op.f("ix_contact_links_history_entity_id"), ["entity_id"], unique=False) + batch_op.create_index(batch_op.f("ix_contact_links_history_org_id"), ["org_id"], unique=False) + batch_op.create_index(batch_op.f("ix_contact_links_history_user_id"), ["user_id"], unique=False) + + with op.batch_alter_table("affiliation_invitation_types", schema=None) as batch_op: + batch_op.alter_column("description", existing_type=sa.VARCHAR(length=100), nullable=True) + + with op.batch_alter_table("affiliation_invitations", schema=None) as batch_op: + batch_op.alter_column( + "token", existing_type=sa.VARCHAR(length=150), type_=sa.String(length=100), existing_nullable=True + ) + batch_op.alter_column( + "is_deleted", existing_type=sa.BOOLEAN(), nullable=True, existing_server_default=sa.text("false") + ) + batch_op.create_index(batch_op.f("ix_affiliation_invitations_affiliation_id"), ["affiliation_id"], unique=False) + batch_op.create_index(batch_op.f("ix_affiliation_invitations_entity_id"), ["entity_id"], unique=False) + batch_op.create_index(batch_op.f("ix_affiliation_invitations_from_org_id"), ["from_org_id"], unique=False) + batch_op.create_index(batch_op.f("ix_affiliation_invitations_to_org_id"), ["to_org_id"], unique=False) + batch_op.create_foreign_key(None, "affiliations", ["affiliation_id"], ["id"]) + + with op.batch_alter_table("product_codes", schema=None) as batch_op: + batch_op.alter_column( + "parent_code", existing_type=sa.VARCHAR(length=15), type_=sa.String(length=75), existing_nullable=True + ) + + with op.batch_alter_table("users", schema=None) as batch_op: + batch_op.drop_column("version") # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.add_column(sa.Column('version', sa.INTEGER(), server_default=sa.text('1'), autoincrement=False, nullable=False)) - - with op.batch_alter_table('product_codes', schema=None) as batch_op: - batch_op.alter_column('parent_code', - existing_type=sa.String(length=75), - type_=sa.VARCHAR(length=15), - existing_nullable=True) - - with op.batch_alter_table('affiliation_invitations', schema=None) as batch_op: - batch_op.drop_constraint(None, type_='foreignkey') - batch_op.drop_index(batch_op.f('ix_affiliation_invitations_to_org_id')) - batch_op.drop_index(batch_op.f('ix_affiliation_invitations_from_org_id')) - batch_op.drop_index(batch_op.f('ix_affiliation_invitations_entity_id')) - batch_op.drop_index(batch_op.f('ix_affiliation_invitations_affiliation_id')) - batch_op.alter_column('is_deleted', - existing_type=sa.BOOLEAN(), - nullable=False, - existing_server_default=sa.text('false')) - batch_op.alter_column('token', - existing_type=sa.String(length=100), - type_=sa.VARCHAR(length=150), - existing_nullable=True) - - with op.batch_alter_table('affiliation_invitation_types', schema=None) as batch_op: - batch_op.alter_column('description', - existing_type=sa.VARCHAR(length=100), - nullable=False) - - op.create_table('contacts_version', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('street', sa.VARCHAR(length=250), autoincrement=False, nullable=True), - sa.Column('street_additional', sa.VARCHAR(length=250), autoincrement=False, nullable=True), - sa.Column('city', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('region', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('country', sa.VARCHAR(length=20), autoincrement=False, nullable=True), - sa.Column('postal_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('delivery_instructions', sa.VARCHAR(length=4096), autoincrement=False, nullable=True), - sa.Column('phone', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('phone_extension', sa.VARCHAR(length=10), autoincrement=False, nullable=True), - sa.Column('email', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('entity_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', 'transaction_id', name='contact_version_pkey') - ) - with op.batch_alter_table('contacts_version', schema=None) as batch_op: - batch_op.create_index('ix_contacts_version_transaction_id', ['transaction_id'], unique=False) - batch_op.create_index('ix_contacts_version_street', ['street'], unique=False) - batch_op.create_index('ix_contacts_version_operation_type', ['operation_type'], unique=False) - batch_op.create_index('ix_contacts_version_end_transaction_id', ['end_transaction_id'], unique=False) - - op.create_table('transaction', - sa.Column('issued_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('id', sa.BIGINT(), autoincrement=True, nullable=False), - sa.Column('remote_addr', sa.VARCHAR(length=50), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', name='transaction_pkey') - ) - op.create_table('orgs_version', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('type_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('status_code', sa.VARCHAR(length=30), autoincrement=False, nullable=True), - sa.Column('name', sa.VARCHAR(length=250), autoincrement=False, nullable=True), - sa.Column('access_type', sa.VARCHAR(length=250), autoincrement=False, nullable=True), - sa.Column('decision_made_by', sa.VARCHAR(length=250), autoincrement=False, nullable=True), - sa.Column('decision_made_on', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('bcol_account_id', sa.VARCHAR(length=20), autoincrement=False, nullable=True), - sa.Column('bcol_user_id', sa.VARCHAR(length=20), autoincrement=False, nullable=True), - sa.Column('suspended_on', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('bcol_account_name', sa.VARCHAR(length=250), autoincrement=False, nullable=True), - sa.Column('suspension_reason_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('branch_name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('has_api_access', sa.BOOLEAN(), autoincrement=False, nullable=True), - sa.Column('is_business_account', sa.BOOLEAN(), autoincrement=False, nullable=True), - sa.Column('business_size', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('business_type', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('uuid', sa.UUID(), server_default=sa.text('uuid_generate_v4()'), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', 'transaction_id', name='org_version_pkey') - ) - with op.batch_alter_table('orgs_version', schema=None) as batch_op: - batch_op.create_index('ix_orgs_version_transaction_id', ['transaction_id'], unique=False) - batch_op.create_index('ix_orgs_version_operation_type', ['operation_type'], unique=False) - batch_op.create_index('ix_orgs_version_name', ['name'], unique=False) - batch_op.create_index('ix_orgs_version_end_transaction_id', ['end_transaction_id'], unique=False) - batch_op.create_index('ix_orgs_version_access_type', ['access_type'], unique=False) - - op.create_table('product_subscriptions_version', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('product_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('status_code', sa.VARCHAR(length=30), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', 'transaction_id', name='product_subscription_version_pkey') - ) - with op.batch_alter_table('product_subscriptions_version', schema=None) as batch_op: - batch_op.create_index('ix_product_subscriptions_version_transaction_id', ['transaction_id'], unique=False) - batch_op.create_index('ix_product_subscriptions_version_org_id', ['org_id'], unique=False) - batch_op.create_index('ix_product_subscriptions_version_operation_type', ['operation_type'], unique=False) - batch_op.create_index('ix_product_subscriptions_version_end_transaction_id', ['end_transaction_id'], unique=False) - - op.create_table('org_settings_version', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('setting', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('enabled', sa.BOOLEAN(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', 'transaction_id', name='org_settings_version_pkey') - ) - with op.batch_alter_table('org_settings_version', schema=None) as batch_op: - batch_op.create_index('ix_org_settings_version_transaction_id', ['transaction_id'], unique=False) - batch_op.create_index('ix_org_settings_version_operation_type', ['operation_type'], unique=False) - batch_op.create_index('ix_org_settings_version_end_transaction_id', ['end_transaction_id'], unique=False) - - op.create_table('affidavits_version', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('document_id', sa.VARCHAR(length=60), autoincrement=False, nullable=True), - sa.Column('issuer', sa.VARCHAR(length=250), autoincrement=False, nullable=True), - sa.Column('status_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('decision_made_by', sa.VARCHAR(length=250), autoincrement=False, nullable=True), - sa.Column('decision_made_on', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', 'transaction_id', name='affidavit_version_pkey') - ) - with op.batch_alter_table('affidavits_version', schema=None) as batch_op: - batch_op.create_index('ix_affidavits_version_transaction_id', ['transaction_id'], unique=False) - batch_op.create_index('ix_affidavits_version_operation_type', ['operation_type'], unique=False) - batch_op.create_index('ix_affidavits_version_end_transaction_id', ['end_transaction_id'], unique=False) - batch_op.create_index('ix_affidavits_version_document_id', ['document_id'], unique=False) - - op.create_table('contact_links_version', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('contact_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('entity_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('affidavit_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', 'transaction_id', name='contact_link_version_pkey') - ) - with op.batch_alter_table('contact_links_version', schema=None) as batch_op: - batch_op.create_index('ix_contact_links_version_user_id', ['user_id'], unique=False) - batch_op.create_index('ix_contact_links_version_transaction_id', ['transaction_id'], unique=False) - batch_op.create_index('ix_contact_links_version_org_id', ['org_id'], unique=False) - batch_op.create_index('ix_contact_links_version_operation_type', ['operation_type'], unique=False) - batch_op.create_index('ix_contact_links_version_entity_id', ['entity_id'], unique=False) - batch_op.create_index('ix_contact_links_version_end_transaction_id', ['end_transaction_id'], unique=False) - batch_op.create_index('ix_contact_links_version_contact_id', ['contact_id'], unique=False) - - op.create_table('affiliations_version', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('entity_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('certified_by_name', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('environment', sa.VARCHAR(length=20), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', 'transaction_id', name='affiliation_version_pkey') - ) - with op.batch_alter_table('affiliations_version', schema=None) as batch_op: - batch_op.create_index('ix_affiliations_version_transaction_id', ['transaction_id'], unique=False) - batch_op.create_index('ix_affiliations_version_operation_type', ['operation_type'], unique=False) - batch_op.create_index('ix_affiliations_version_environment', ['environment'], unique=False) - batch_op.create_index('ix_affiliations_version_entity_id', ['entity_id'], unique=False) - batch_op.create_index('ix_affiliations_version_end_transaction_id', ['end_transaction_id'], unique=False) - - op.create_table('account_login_options_version', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('login_source', sa.VARCHAR(length=20), autoincrement=False, nullable=True), - sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('is_active', sa.BOOLEAN(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', 'transaction_id', name='account_login_options_version_pkey') - ) - with op.batch_alter_table('account_login_options_version', schema=None) as batch_op: - batch_op.create_index('ix_account_login_options_version_transaction_id', ['transaction_id'], unique=False) - batch_op.create_index('ix_account_login_options_version_operation_type', ['operation_type'], unique=False) - batch_op.create_index('ix_account_login_options_version_end_transaction_id', ['end_transaction_id'], unique=False) - - op.create_table('users_version', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('username', sa.VARCHAR(length=100), autoincrement=False, nullable=True), - sa.Column('first_name', sa.VARCHAR(length=200), autoincrement=False, nullable=True), - sa.Column('last_name', sa.VARCHAR(length=200), autoincrement=False, nullable=True), - sa.Column('email', sa.VARCHAR(length=200), autoincrement=False, nullable=True), - sa.Column('keycloak_guid', sa.UUID(), autoincrement=False, nullable=True), - sa.Column('is_terms_of_use_accepted', sa.BOOLEAN(), autoincrement=False, nullable=True), - sa.Column('terms_of_use_accepted_version', sa.VARCHAR(length=10), autoincrement=False, nullable=True), - sa.Column('type', sa.VARCHAR(length=200), autoincrement=False, nullable=True), - sa.Column('status', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('idp_userid', sa.VARCHAR(length=256), autoincrement=False, nullable=True), - sa.Column('login_source', sa.VARCHAR(length=200), autoincrement=False, nullable=True), - sa.Column('login_time', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column('verified', sa.BOOLEAN(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', 'transaction_id', name='user_version_pkey') - ) - with op.batch_alter_table('users_version', schema=None) as batch_op: - batch_op.create_index('ix_users_version_username', ['username'], unique=False) - batch_op.create_index('ix_users_version_transaction_id', ['transaction_id'], unique=False) - batch_op.create_index('ix_users_version_operation_type', ['operation_type'], unique=False) - batch_op.create_index('ix_users_version_last_name', ['last_name'], unique=False) - batch_op.create_index('ix_users_version_idp_userid', ['idp_userid'], unique=False) - batch_op.create_index('ix_users_version_first_name', ['first_name'], unique=False) - batch_op.create_index('ix_users_version_end_transaction_id', ['end_transaction_id'], unique=False) - batch_op.create_index('ix_users_version_email', ['email'], unique=False) - - op.create_table('memberships_version', - sa.Column('id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('membership_type_code', sa.VARCHAR(length=15), autoincrement=False, nullable=True), - sa.Column('status', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('created_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('end_transaction_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('operation_type', sa.SMALLINT(), autoincrement=False, nullable=False), - sa.Column('created', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('modified_by_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', 'transaction_id', name='membership_version_pkey') - ) - with op.batch_alter_table('memberships_version', schema=None) as batch_op: - batch_op.create_index('ix_memberships_version_user_id', ['user_id'], unique=False) - batch_op.create_index('ix_memberships_version_transaction_id', ['transaction_id'], unique=False) - batch_op.create_index('ix_memberships_version_status', ['status'], unique=False) - batch_op.create_index('ix_memberships_version_org_id', ['org_id'], unique=False) - batch_op.create_index('ix_memberships_version_operation_type', ['operation_type'], unique=False) - batch_op.create_index('ix_memberships_version_end_transaction_id', ['end_transaction_id'], unique=False) - - op.create_table('activity', - sa.Column('id', sa.BIGINT(), autoincrement=True, nullable=False), - sa.Column('verb', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('transaction_id', sa.BIGINT(), autoincrement=False, nullable=False), - sa.Column('data', postgresql.JSON(astext_type=sa.Text()), autoincrement=False, nullable=True), - sa.Column('object_type', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('object_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('object_tx_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('target_type', sa.VARCHAR(length=255), autoincrement=False, nullable=True), - sa.Column('target_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.Column('target_tx_id', sa.BIGINT(), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('id', name='activity_pkey') - ) - with op.batch_alter_table('activity', schema=None) as batch_op: - batch_op.create_index('ix_activity_transaction_id', ['transaction_id'], unique=False) - - with op.batch_alter_table('contact_links_history', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_contact_links_history_user_id')) - batch_op.drop_index(batch_op.f('ix_contact_links_history_org_id')) - batch_op.drop_index(batch_op.f('ix_contact_links_history_entity_id')) - batch_op.drop_index(batch_op.f('ix_contact_links_history_contact_id')) - - op.drop_table('contact_links_history') - with op.batch_alter_table('product_subscriptions_history', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_product_subscriptions_history_org_id')) - - op.drop_table('product_subscriptions_history') - op.drop_table('org_settings_history') - with op.batch_alter_table('memberships_history', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_memberships_history_user_id')) - batch_op.drop_index(batch_op.f('ix_memberships_history_status')) - batch_op.drop_index(batch_op.f('ix_memberships_history_org_id')) - - op.drop_table('memberships_history') - with op.batch_alter_table('contacts_history', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_contacts_history_street')) - - op.drop_table('contacts_history') - with op.batch_alter_table('affiliations_history', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_affiliations_history_environment')) - batch_op.drop_index(batch_op.f('ix_affiliations_history_entity_id')) - - op.drop_table('affiliations_history') - op.drop_table('account_login_options_history') - with op.batch_alter_table('orgs_history', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_orgs_history_name')) - batch_op.drop_index(batch_op.f('ix_orgs_history_access_type')) - - op.drop_table('orgs_history') - with op.batch_alter_table('affidavits_history', schema=None) as batch_op: - batch_op.drop_index(batch_op.f('ix_affidavits_history_document_id')) - - op.drop_table('affidavits_history') + with op.batch_alter_table("users", schema=None) as batch_op: + batch_op.add_column( + sa.Column("version", sa.INTEGER(), server_default=sa.text("1"), autoincrement=False, nullable=False) + ) + + with op.batch_alter_table("product_codes", schema=None) as batch_op: + batch_op.alter_column( + "parent_code", existing_type=sa.String(length=75), type_=sa.VARCHAR(length=15), existing_nullable=True + ) + + with op.batch_alter_table("affiliation_invitations", schema=None) as batch_op: + batch_op.drop_constraint(None, type_="foreignkey") + batch_op.drop_index(batch_op.f("ix_affiliation_invitations_to_org_id")) + batch_op.drop_index(batch_op.f("ix_affiliation_invitations_from_org_id")) + batch_op.drop_index(batch_op.f("ix_affiliation_invitations_entity_id")) + batch_op.drop_index(batch_op.f("ix_affiliation_invitations_affiliation_id")) + batch_op.alter_column( + "is_deleted", existing_type=sa.BOOLEAN(), nullable=False, existing_server_default=sa.text("false") + ) + batch_op.alter_column( + "token", existing_type=sa.String(length=100), type_=sa.VARCHAR(length=150), existing_nullable=True + ) + + with op.batch_alter_table("affiliation_invitation_types", schema=None) as batch_op: + batch_op.alter_column("description", existing_type=sa.VARCHAR(length=100), nullable=False) + + with op.batch_alter_table("contact_links_history", schema=None) as batch_op: + batch_op.drop_index(batch_op.f("ix_contact_links_history_user_id")) + batch_op.drop_index(batch_op.f("ix_contact_links_history_org_id")) + batch_op.drop_index(batch_op.f("ix_contact_links_history_entity_id")) + batch_op.drop_index(batch_op.f("ix_contact_links_history_contact_id")) + + op.drop_table("contact_links_history") + with op.batch_alter_table("product_subscriptions_history", schema=None) as batch_op: + batch_op.drop_index(batch_op.f("ix_product_subscriptions_history_org_id")) + + op.drop_table("product_subscriptions_history") + op.drop_table("org_settings_history") + with op.batch_alter_table("memberships_history", schema=None) as batch_op: + batch_op.drop_index(batch_op.f("ix_memberships_history_user_id")) + batch_op.drop_index(batch_op.f("ix_memberships_history_status")) + batch_op.drop_index(batch_op.f("ix_memberships_history_org_id")) + + op.drop_table("memberships_history") + with op.batch_alter_table("contacts_history", schema=None) as batch_op: + batch_op.drop_index(batch_op.f("ix_contacts_history_street")) + + op.drop_table("contacts_history") + with op.batch_alter_table("affiliations_history", schema=None) as batch_op: + batch_op.drop_index(batch_op.f("ix_affiliations_history_environment")) + batch_op.drop_index(batch_op.f("ix_affiliations_history_entity_id")) + + op.drop_table("affiliations_history") + op.drop_table("account_login_options_history") + with op.batch_alter_table("orgs_history", schema=None) as batch_op: + batch_op.drop_index(batch_op.f("ix_orgs_history_name")) + batch_op.drop_index(batch_op.f("ix_orgs_history_access_type")) + + op.drop_table("orgs_history") + with op.batch_alter_table("affidavits_history", schema=None) as batch_op: + batch_op.drop_index(batch_op.f("ix_affidavits_history_document_id")) + + op.drop_table("affidavits_history") # ### end Alembic commands ### From 9692c5c2bdb165d25389739c43d202c25ac8562a Mon Sep 17 00:00:00 2001 From: pwei1018 Date: Fri, 20 Sep 2024 11:59:31 -0700 Subject: [PATCH 4/8] Remove table alteration from script. --- .../versions/2024_09_20_aa74003de9d8_.py | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py b/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py index 8f0f7ae908..fc92244fd9 100644 --- a/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py +++ b/auth-api/migrations/versions/2024_09_20_aa74003de9d8_.py @@ -379,61 +379,11 @@ def upgrade(): batch_op.create_index(batch_op.f("ix_contact_links_history_org_id"), ["org_id"], unique=False) batch_op.create_index(batch_op.f("ix_contact_links_history_user_id"), ["user_id"], unique=False) - with op.batch_alter_table("affiliation_invitation_types", schema=None) as batch_op: - batch_op.alter_column("description", existing_type=sa.VARCHAR(length=100), nullable=True) - - with op.batch_alter_table("affiliation_invitations", schema=None) as batch_op: - batch_op.alter_column( - "token", existing_type=sa.VARCHAR(length=150), type_=sa.String(length=100), existing_nullable=True - ) - batch_op.alter_column( - "is_deleted", existing_type=sa.BOOLEAN(), nullable=True, existing_server_default=sa.text("false") - ) - batch_op.create_index(batch_op.f("ix_affiliation_invitations_affiliation_id"), ["affiliation_id"], unique=False) - batch_op.create_index(batch_op.f("ix_affiliation_invitations_entity_id"), ["entity_id"], unique=False) - batch_op.create_index(batch_op.f("ix_affiliation_invitations_from_org_id"), ["from_org_id"], unique=False) - batch_op.create_index(batch_op.f("ix_affiliation_invitations_to_org_id"), ["to_org_id"], unique=False) - batch_op.create_foreign_key(None, "affiliations", ["affiliation_id"], ["id"]) - - with op.batch_alter_table("product_codes", schema=None) as batch_op: - batch_op.alter_column( - "parent_code", existing_type=sa.VARCHAR(length=15), type_=sa.String(length=75), existing_nullable=True - ) - - with op.batch_alter_table("users", schema=None) as batch_op: - batch_op.drop_column("version") - # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table("users", schema=None) as batch_op: - batch_op.add_column( - sa.Column("version", sa.INTEGER(), server_default=sa.text("1"), autoincrement=False, nullable=False) - ) - - with op.batch_alter_table("product_codes", schema=None) as batch_op: - batch_op.alter_column( - "parent_code", existing_type=sa.String(length=75), type_=sa.VARCHAR(length=15), existing_nullable=True - ) - - with op.batch_alter_table("affiliation_invitations", schema=None) as batch_op: - batch_op.drop_constraint(None, type_="foreignkey") - batch_op.drop_index(batch_op.f("ix_affiliation_invitations_to_org_id")) - batch_op.drop_index(batch_op.f("ix_affiliation_invitations_from_org_id")) - batch_op.drop_index(batch_op.f("ix_affiliation_invitations_entity_id")) - batch_op.drop_index(batch_op.f("ix_affiliation_invitations_affiliation_id")) - batch_op.alter_column( - "is_deleted", existing_type=sa.BOOLEAN(), nullable=False, existing_server_default=sa.text("false") - ) - batch_op.alter_column( - "token", existing_type=sa.String(length=100), type_=sa.VARCHAR(length=150), existing_nullable=True - ) - - with op.batch_alter_table("affiliation_invitation_types", schema=None) as batch_op: - batch_op.alter_column("description", existing_type=sa.VARCHAR(length=100), nullable=False) - with op.batch_alter_table("contact_links_history", schema=None) as batch_op: batch_op.drop_index(batch_op.f("ix_contact_links_history_user_id")) batch_op.drop_index(batch_op.f("ix_contact_links_history_org_id")) From cd449d2c5a133b18f7e1996633100fa0f5977a56 Mon Sep 17 00:00:00 2001 From: pwei1018 Date: Fri, 20 Sep 2024 13:31:46 -0700 Subject: [PATCH 5/8] Switch back to psycopg2 from pg8000. --- auth-api/poetry.lock | 2 +- auth-api/pyproject.toml | 2 +- auth-api/src/auth_api/config.py | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/auth-api/poetry.lock b/auth-api/poetry.lock index 86ad49aa44..2d89b70400 100644 --- a/auth-api/poetry.lock +++ b/auth-api/poetry.lock @@ -403,7 +403,7 @@ Werkzeug = "3.0.0" type = "git" url = "https://github.com/bcgov/sbc-auth.git" reference = "feature-gcp-migration" -resolved_reference = "b387965a8e56cae6af86754f577c42d8515532e0" +resolved_reference = "458939f62d4b7818abfb03c263b2802d13ae5fea" subdirectory = "build-deps" [[package]] diff --git a/auth-api/pyproject.toml b/auth-api/pyproject.toml index 466cbd5f13..e3bd4f6fc3 100644 --- a/auth-api/pyproject.toml +++ b/auth-api/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "auth-api" -version = "3.0.2" +version = "3.0.3" description = "" authors = ["\"BC Registries and Online Services\""] readme = "README.md" diff --git a/auth-api/src/auth_api/config.py b/auth-api/src/auth_api/config.py index 9b52d9d671..f8356c7df6 100644 --- a/auth-api/src/auth_api/config.py +++ b/auth-api/src/auth_api/config.py @@ -76,9 +76,7 @@ class _Config: # pylint: disable=too-few-public-methods DB_HOST = os.getenv("DATABASE_HOST", "") DB_PORT = os.getenv("DATABASE_PORT", "5432") if DB_UNIX_SOCKET := os.getenv("DATABASE_UNIX_SOCKET", None): - SQLALCHEMY_DATABASE_URI = ( - f"postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@/{DB_NAME}?unix_sock={DB_UNIX_SOCKET}/.s.PGSQL.5432" - ) + SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_UNIX_SOCKET}" else: SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}" From 3664218b55bd6ae80d01cab4125de604889315e5 Mon Sep 17 00:00:00 2001 From: Patrick Wei <44277752+pwei1018@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:16:24 -0700 Subject: [PATCH 6/8] Force conver string to int. --- .github/workflows/account-mailer-cd.yml | 1 + .github/workflows/auth-api-cd.yml | 1 + .github/workflows/auth-queue-cd.yml | 1 + .github/workflows/auth-web-cd.yml | 2 + auth-api/poetry.lock | 4 +- auth-api/pyproject.toml | 3 +- auth-api/src/auth_api/config.py | 10 +-- .../auth_api/models/account_login_options.py | 4 +- auth-api/src/auth_api/models/affidavit.py | 4 +- auth-api/src/auth_api/models/affiliation.py | 14 ++--- .../auth_api/models/affiliation_invitation.py | 35 ++++++----- auth-api/src/auth_api/models/contact_link.py | 16 ++--- auth-api/src/auth_api/models/entity.py | 4 +- auth-api/src/auth_api/models/invitation.py | 20 +++--- auth-api/src/auth_api/models/membership.py | 62 ++++++++++--------- auth-api/src/auth_api/models/org.py | 8 +-- auth-api/src/auth_api/models/org_settings.py | 8 +-- .../auth_api/models/product_subscription.py | 2 +- .../models/pubsub_message_processing.py | 4 +- auth-api/src/auth_api/models/task.py | 12 ++-- auth-api/src/auth_api/models/user.py | 2 +- .../auth_api/models/views/authorization.py | 12 ++-- .../services/affiliation_invitation.py | 2 +- auth-api/src/auth_api/services/invitation.py | 15 +++-- 24 files changed, 131 insertions(+), 115 deletions(-) diff --git a/.github/workflows/account-mailer-cd.yml b/.github/workflows/account-mailer-cd.yml index 36c78a62be..a284f4e04a 100644 --- a/.github/workflows/account-mailer-cd.yml +++ b/.github/workflows/account-mailer-cd.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - feature* paths: - "queue_services/account-mailer/**" - "auth-api/src/auth_api/models/**" diff --git a/.github/workflows/auth-api-cd.yml b/.github/workflows/auth-api-cd.yml index ef91c47c03..19348eba01 100644 --- a/.github/workflows/auth-api-cd.yml +++ b/.github/workflows/auth-api-cd.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - feature* paths: - "auth-api/**" workflow_dispatch: diff --git a/.github/workflows/auth-queue-cd.yml b/.github/workflows/auth-queue-cd.yml index 4b29b8728d..a228cdd936 100644 --- a/.github/workflows/auth-queue-cd.yml +++ b/.github/workflows/auth-queue-cd.yml @@ -4,6 +4,7 @@ on: push: branches: - main + - feature* paths: - "queue_services/auth-queue/**" - "auth-api/src/auth_api/models/**" diff --git a/.github/workflows/auth-web-cd.yml b/.github/workflows/auth-web-cd.yml index e5bf9c7b9f..88962760d8 100644 --- a/.github/workflows/auth-web-cd.yml +++ b/.github/workflows/auth-web-cd.yml @@ -5,6 +5,8 @@ on: branches: - main - feature* + paths: + - "auth-web/**" workflow_dispatch: inputs: target: diff --git a/auth-api/poetry.lock b/auth-api/poetry.lock index 2d89b70400..9d954158c7 100644 --- a/auth-api/poetry.lock +++ b/auth-api/poetry.lock @@ -403,7 +403,7 @@ Werkzeug = "3.0.0" type = "git" url = "https://github.com/bcgov/sbc-auth.git" reference = "feature-gcp-migration" -resolved_reference = "458939f62d4b7818abfb03c263b2802d13ae5fea" +resolved_reference = "901c64adab5b3496ae55489f975cc8601dc153ed" subdirectory = "build-deps" [[package]] @@ -3127,4 +3127,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = "^3.12" -content-hash = "ae8f1ccd43b3c8bac963e42b3065d596788881a7e201a82f2174b923673f4a7d" +content-hash = "825b0312c3e9765cc9fd00497d83cb481981a01fef671928ecdf00dd34c66a1a" diff --git a/auth-api/pyproject.toml b/auth-api/pyproject.toml index e3bd4f6fc3..cd78e990a3 100644 --- a/auth-api/pyproject.toml +++ b/auth-api/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "auth-api" -version = "3.0.3" +version = "3.0.4" description = "" authors = ["\"BC Registries and Online Services\""] readme = "README.md" @@ -25,6 +25,7 @@ aiohttp = "^3.10.2" cattrs = "^23.2.3" orjson = "^3.10.7" sqlalchemy-utils = "^0.41.2" +psycopg2 = "^2.9.9" # VCS dependencies sql-versioning = { git = "https://github.com/bcgov/sbc-connect-common.git", subdirectory = "python/sql-versioning", branch = "main" } diff --git a/auth-api/src/auth_api/config.py b/auth-api/src/auth_api/config.py index f8356c7df6..09bfd91689 100644 --- a/auth-api/src/auth_api/config.py +++ b/auth-api/src/auth_api/config.py @@ -74,11 +74,13 @@ class _Config: # pylint: disable=too-few-public-methods DB_PASSWORD = os.getenv("DATABASE_PASSWORD", "") DB_NAME = os.getenv("DATABASE_NAME", "") DB_HOST = os.getenv("DATABASE_HOST", "") - DB_PORT = os.getenv("DATABASE_PORT", "5432") + DB_PORT = int(os.getenv("DATABASE_PORT", "5432")) # POSTGRESQL if DB_UNIX_SOCKET := os.getenv("DATABASE_UNIX_SOCKET", None): - SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_UNIX_SOCKET}" + SQLALCHEMY_DATABASE_URI = ( + f"postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@/{DB_NAME}?unix_sock={DB_UNIX_SOCKET}/.s.PGSQL.5432" + ) else: - SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}" + SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}" # JWT_OIDC Settings JWT_OIDC_WELL_KNOWN_CONFIG = os.getenv("JWT_OIDC_WELL_KNOWN_CONFIG") @@ -220,7 +222,7 @@ class TestConfig(_Config): # pylint: disable=too-few-public-methods DB_HOST = os.getenv("DATABASE_TEST_HOST", "localhost") DB_PORT = os.getenv("DATABASE_TEST_PORT", "5432") SQLALCHEMY_DATABASE_URI = os.getenv( - "DATABASE_TEST_URL", f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}" + "DATABASE_TEST_URL", f"postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{int(DB_PORT)}/{DB_NAME}" ) # JWT OIDC settings diff --git a/auth-api/src/auth_api/models/account_login_options.py b/auth-api/src/auth_api/models/account_login_options.py index ceccd06570..d748c78935 100644 --- a/auth-api/src/auth_api/models/account_login_options.py +++ b/auth-api/src/auth_api/models/account_login_options.py @@ -33,6 +33,6 @@ class AccountLoginOptions(Versioned, BaseModel): # pylint: disable=too-few-publ org = relationship("Org", foreign_keys=[org_id], lazy="select") @classmethod - def find_active_by_org_id(cls, account_id): + def find_active_by_org_id(cls, account_id: int): """Find an account setting instance that matches the provided org_id.""" - return cls.query.filter_by(org_id=account_id).filter_by(is_active=True).first() + return cls.query.filter_by(org_id=int(account_id or -1)).filter_by(is_active=True).first() diff --git a/auth-api/src/auth_api/models/affidavit.py b/auth-api/src/auth_api/models/affidavit.py index 4d18b5bacb..999231e687 100644 --- a/auth-api/src/auth_api/models/affidavit.py +++ b/auth-api/src/auth_api/models/affidavit.py @@ -61,12 +61,12 @@ def find_by_org_id(cls, org_id: int, filtered_affidavit_statuses=None): @classmethod def find_pending_by_user_id(cls, user_id: int): """Find pending affidavit by user id.""" - return cls.query.filter_by(user_id=user_id, status_code=AffidavitStatus.PENDING.value).one_or_none() + return cls.query.filter_by(user_id=int(user_id or -1), status_code=AffidavitStatus.PENDING.value).one_or_none() @classmethod def find_approved_by_user_id(cls, user_id: int): """Find pending affidavit by user id.""" - return cls.query.filter_by(user_id=user_id, status_code=AffidavitStatus.APPROVED.value).one_or_none() + return cls.query.filter_by(user_id=int(user_id or -1), status_code=AffidavitStatus.APPROVED.value).one_or_none() @classmethod def find_effective_by_user_guid(cls, user_guid: str, status: str = None): diff --git a/auth-api/src/auth_api/models/affiliation.py b/auth-api/src/auth_api/models/affiliation.py index 1632836c63..8e9d0f7334 100644 --- a/auth-api/src/auth_api/models/affiliation.py +++ b/auth-api/src/auth_api/models/affiliation.py @@ -55,20 +55,20 @@ def filter_environment(cls, environment: str): return query @classmethod - def find_affiliation_by_org_and_entity_ids(cls, org_id, entity_id, environment) -> Affiliation: + def find_affiliation_by_org_and_entity_ids(cls, org_id: int, entity_id: int, environment) -> Affiliation: """Return an affiliation for the provided org and entity ids.""" - query = cls.filter_environment(environment).filter_by(org_id=org_id, entity_id=entity_id) + query = cls.filter_environment(environment).filter_by(org_id=int(org_id or -1), entity_id=int(entity_id or -1)) return query.one_or_none() @classmethod - def find_affiliations_by_entity_id(cls, entity_id, environment) -> List[Affiliation]: + def find_affiliations_by_entity_id(cls, entity_id: int, environment) -> List[Affiliation]: """Return affiliations for the provided entity id.""" - return cls.filter_environment(environment).filter_by(entity_id=entity_id).all() + return cls.filter_environment(environment).filter_by(entity_id=int(entity_id or -1)).all() @classmethod def find_affiliation_by_ids(cls, org_id: int, affiliation_id: int) -> Affiliation: """Return the first Affiliation with the provided ids.""" - return cls.query.filter_by(org_id=org_id).filter_by(id=affiliation_id).one_or_none() + return cls.query.filter_by(org_id=int(org_id or -1)).filter_by(id=int(affiliation_id or -1)).one_or_none() @classmethod def find_affiliations_by_org_id(cls, org_id: int, environment: str) -> List[Affiliation]: @@ -81,7 +81,7 @@ def find_affiliations_by_org_id(cls, org_id: int, environment: str) -> List[Affi EntityModel.business_identifier, EntityModel.corp_type_code ) ) - .filter(Affiliation.org_id == org_id) + .filter(Affiliation.org_id == int(org_id or -1)) ) if environment: query = query.filter(Affiliation.environment == environment) @@ -112,7 +112,7 @@ def find_affiliation_by_org_id_and_business_identifier( EntityModel.business_identifier, EntityModel.corp_type_code ) ) - .filter(Affiliation.org_id == org_id) + .filter(Affiliation.org_id == int(org_id or -1)) .filter(EntityModel.business_identifier == business_identifier) ) if environment: diff --git a/auth-api/src/auth_api/models/affiliation_invitation.py b/auth-api/src/auth_api/models/affiliation_invitation.py index f0c9d72b7f..93de0c583f 100644 --- a/auth-api/src/auth_api/models/affiliation_invitation.py +++ b/auth-api/src/auth_api/models/affiliation_invitation.py @@ -118,27 +118,27 @@ def filter_by(cls, search_filter: AffiliationInvitationSearch, query=None) -> li results = db.session.query(AffiliationInvitation) if search_filter.from_org_id: - results = results.filter(AffiliationInvitation.from_org_id == search_filter.from_org_id) + results = results.filter(AffiliationInvitation.from_org_id == int(search_filter.from_org_id)) filter_set = True if search_filter.to_org_id: - results = results.filter(AffiliationInvitation.to_org_id == search_filter.to_org_id) + results = results.filter(AffiliationInvitation.to_org_id == int(search_filter.to_org_id)) filter_set = True if search_filter.sender_id: - results = results.filter(AffiliationInvitation.sender_id == search_filter.sender_id) + results = results.filter(AffiliationInvitation.sender_id == int(search_filter.sender_id)) filter_set = True if search_filter.approver_id: - results = results.filter(AffiliationInvitation.approver_id == search_filter.approver_id) + results = results.filter(AffiliationInvitation.approver_id == int(search_filter.approver_id)) filter_set = True if search_filter.entity_id: - results = results.filter(AffiliationInvitation.entity_id == search_filter.entity_id) + results = results.filter(AffiliationInvitation.entity_id == int(search_filter.entity_id)) filter_set = True if search_filter.affiliation_id: - results = results.filter(AffiliationInvitation.affiliation_id == search_filter.affiliation_id) + results = results.filter(AffiliationInvitation.affiliation_id == int(search_filter.affiliation_id)) filter_set = True if search_filter.status_codes: @@ -159,32 +159,32 @@ def filter_by(cls, search_filter: AffiliationInvitationSearch, query=None) -> li return results.all() @classmethod - def find_invitation_by_id(cls, invitation_id): + def find_invitation_by_id(cls, invitation_id: int): """Find an affiliation invitation record that matches the id.""" - return cls.query.filter_by(id=invitation_id).first() + return cls.query.filter_by(id=int(invitation_id or -1)).first() @classmethod - def find_invitations_from_org(cls, org_id, status=None): + def find_invitations_from_org(cls, org_id: int, status=None): """Find all affiliation invitations sent from a specific org filtered by status.""" results = db.session.query(AffiliationInvitation).filter(AffiliationInvitation.from_org_id == org_id) return results.filter(AffiliationInvitation.status == status.value).all() if status else results.all() @classmethod - def find_invitations_to_org(cls, org_id, status=None): + def find_invitations_to_org(cls, org_id: int, status=None): """Find all affiliation invitations sent to a specific org filtered by status.""" results = db.session.query(AffiliationInvitation).filter(AffiliationInvitation.to_org_id == org_id) return results.filter(AffiliationInvitation.status == status.value).all() if status else results.all() @classmethod - def find_invitations_by_entity(cls, entity_id, status=None): + def find_invitations_by_entity(cls, entity_id: int, status=None): """Find all affiliation invitations sent for specific entity filtered by status.""" results = db.session.query(AffiliationInvitation).filter(AffiliationInvitation.entity_id == entity_id) return results.filter(AffiliationInvitation.status == status.value).all() if status else results.all() @classmethod - def find_invitations_by_affiliation(cls, affiliation_id): + def find_invitations_by_affiliation(cls, affiliation_id: int): """Find all affiliation invitations associated to an affiliation.""" - return cls.query.filter_by(affiliation_id=affiliation_id).all() + return cls.query.filter_by(affiliation_id=int(affiliation_id or -1)).all() @staticmethod def find_invitations_by_org_entity_ids(from_org_id: int, entity_id: int): @@ -202,7 +202,7 @@ def find_invitations_by_org_entity_ids(from_org_id: int, entity_id: int): .all() ) - def update_invitation_as_retried(self, sender_id): + def update_invitation_as_retried(self, sender_id: int): """Update this affiliation invitation with the new data.""" self.sender_id = sender_id self.sent_date = datetime.now() @@ -217,10 +217,13 @@ def set_status(self, new_status_code: str): return self @classmethod - def find_all_related_to_org(cls, org_id, search_filter=AffiliationInvitationSearch()): + def find_all_related_to_org(cls, org_id: int, search_filter=AffiliationInvitationSearch()): """Return all affiliation invitations that are related to the org (from org or to org) filtered by statuses.""" query = db.session.query(AffiliationInvitation).filter( - or_(AffiliationInvitation.to_org_id == org_id, AffiliationInvitation.from_org_id == org_id) + or_( + AffiliationInvitation.to_org_id == int(org_id or -1), + AffiliationInvitation.from_org_id == int(org_id or -1), + ) ) return cls.filter_by(search_filter=search_filter, query=query) diff --git a/auth-api/src/auth_api/models/contact_link.py b/auth-api/src/auth_api/models/contact_link.py index 60ca720c59..7f90409c61 100644 --- a/auth-api/src/auth_api/models/contact_link.py +++ b/auth-api/src/auth_api/models/contact_link.py @@ -44,24 +44,24 @@ class ContactLink(Versioned, BaseModel): # pylint: disable=too-few-public-metho affidavit = relationship("Affidavit", foreign_keys=[affidavit_id], lazy="select") @classmethod - def find_by_entity_id(cls, entity_id): + def find_by_entity_id(cls, entity_id: int): """Return the first contact link with the provided entity id.""" - return cls.query.filter_by(entity_id=entity_id).first() + return cls.query.filter_by(entity_id=int(entity_id or -1)).first() @classmethod - def find_by_user_id(cls, user_id): + def find_by_user_id(cls, user_id: int): """Return the first contact link with the provided user id.""" - return cls.query.filter_by(user_id=user_id).first() + return cls.query.filter_by(user_id=int(user_id or -1)).first() @classmethod - def find_by_org_id(cls, org_id): + def find_by_org_id(cls, org_id: int): """Return the first contact link with the provided org id.""" - return cls.query.filter_by(org_id=org_id).first() + return cls.query.filter_by(org_id=int(org_id or -1)).first() @classmethod - def find_by_affidavit_id(cls, affidavit_id): + def find_by_affidavit_id(cls, affidavit_id: int): """Return the first contact link with the provided affidavit id.""" - return cls.query.filter_by(affidavit_id=affidavit_id).one_or_none() + return cls.query.filter_by(affidavit_id=int(affidavit_id or -1)).one_or_none() def has_links(self): """Check whether there are any remaining links for this contact.""" diff --git a/auth-api/src/auth_api/models/entity.py b/auth-api/src/auth_api/models/entity.py index 4db1784a80..8b56550317 100644 --- a/auth-api/src/auth_api/models/entity.py +++ b/auth-api/src/auth_api/models/entity.py @@ -66,9 +66,9 @@ def create_from_dict(cls, entity_info: dict): return None @classmethod - def find_by_entity_id(cls, entity_id): + def find_by_entity_id(cls, entity_id: int): """Find an Entity instance that matches the provided id.""" - return cls.query.filter_by(id=entity_id).first() + return cls.query.filter_by(id=int(entity_id or -1)).first() def reset(self): """Reset an Entity back to init state.""" diff --git a/auth-api/src/auth_api/models/invitation.py b/auth-api/src/auth_api/models/invitation.py index d3b8b55b5f..6e2929ceb4 100644 --- a/auth-api/src/auth_api/models/invitation.py +++ b/auth-api/src/auth_api/models/invitation.py @@ -64,7 +64,7 @@ def status(self): return self.invitation_status_code @classmethod - def create_from_dict(cls, invitation_info: dict, user_id, invitation_type): + def create_from_dict(cls, invitation_info: dict, user_id: int, invitation_type): """Create a new Invitation from the provided dictionary.""" if invitation_info: invitation = Invitation() @@ -85,23 +85,23 @@ def create_from_dict(cls, invitation_info: dict, user_id, invitation_type): return None @classmethod - def find_invitations_by_user(cls, user_id): + def find_invitations_by_user(cls, user_id: int): """Find all invitation sent by the given user.""" - return cls.query.filter_by(sender_id=user_id).all() + return cls.query.filter_by(sender_id=int(user_id or -1)).all() @classmethod - def find_invitation_by_id(cls, invitation_id): + def find_invitation_by_id(cls, invitation_id: int): """Find an invitation record that matches the id.""" - return cls.query.filter_by(id=invitation_id).first() + return cls.query.filter_by(id=int(invitation_id or -1)).first() @classmethod - def find_invitations_by_org(cls, org_id, status=None): + def find_invitations_by_org(cls, org_id: int, status=None): """Find all invitations sent for specific org filtered by status.""" - results = cls.query.filter(Invitation.membership.any(InvitationMembership.org_id == org_id)) + results = cls.query.filter(Invitation.membership.any(InvitationMembership.org_id == int(org_id or -1))) return results.filter(Invitation.status == status.value).all() if status else results.all() @staticmethod - def find_pending_invitations_by_user(user_id): + def find_pending_invitations_by_user(user_id: int): """Find all invitations that are not in accepted state.""" return ( db.session.query(Invitation) @@ -111,7 +111,7 @@ def find_pending_invitations_by_user(user_id): ) @staticmethod - def find_pending_invitations_by_org(org_id): + def find_pending_invitations_by_org(org_id: int): """Find all invitations that are not in accepted state.""" return ( db.session.query(Invitation) @@ -121,7 +121,7 @@ def find_pending_invitations_by_org(org_id): ) @staticmethod - def find_invitations_by_status(user_id, status): + def find_invitations_by_status(user_id: int, status): """Find all invitations that are not in accepted state.""" return ( db.session.query(Invitation) diff --git a/auth-api/src/auth_api/models/membership.py b/auth-api/src/auth_api/models/membership.py index e7ae33807c..8ee7d12eef 100644 --- a/auth-api/src/auth_api/models/membership.py +++ b/auth-api/src/auth_api/models/membership.py @@ -68,23 +68,23 @@ def __init__(self, **kwargs): # pylint: disable=super-init-not-called self.status = kwargs.get("membership_type_status") @classmethod - def find_membership_by_id(cls, membership_id) -> Membership: + def find_membership_by_id(cls, membership_id: int) -> Membership: """Find the first membership with the given id and return it.""" - return cls.query.filter_by(id=membership_id).first() + return cls.query.filter_by(id=int(membership_id or -1)).first() @classmethod - def find_members_by_org_id(cls, org_id) -> List[Membership]: + def find_members_by_org_id(cls, org_id: int) -> List[Membership]: """Return all members of the org with a status.""" - return cls.query.filter_by(org_id=org_id).all() + return cls.query.filter_by(org_id=int(org_id or -1)).all() @classmethod - def get_pending_members_count_by_org_id(cls, org_id) -> int: + def get_pending_members_count_by_org_id(cls, org_id: int) -> int: """Return the count of pending members.""" query = ( db.session.query(Membership) .filter(and_(Membership.status == Status.PENDING_APPROVAL.value)) .join(OrgModel) - .filter(OrgModel.id == org_id) + .filter(OrgModel.id == int(org_id or -1)) ) # pylint:disable=not-callable count_q = query.statement.with_only_columns(func.count(), maintain_column_froms=True).order_by(None) @@ -92,22 +92,24 @@ def get_pending_members_count_by_org_id(cls, org_id) -> int: return count @classmethod - def find_members_by_org_id_by_status_by_roles(cls, org_id, roles, status=Status.ACTIVE.value) -> List[Membership]: + def find_members_by_org_id_by_status_by_roles( + cls, org_id: int, roles, status=Status.ACTIVE.value + ) -> List[Membership]: """Return all members of the org with a status.""" return ( db.session.query(Membership) .filter(and_(Membership.status == status, Membership.membership_type_code.in_(roles))) .join(OrgModel) - .filter(OrgModel.id == org_id) + .filter(OrgModel.id == int(org_id or -1)) .all() ) @classmethod - def find_orgs_for_user(cls, user_id, valid_statuses=VALID_STATUSES) -> List[OrgModel]: + def find_orgs_for_user(cls, user_id: int, valid_statuses=VALID_STATUSES) -> List[OrgModel]: """Find the orgs for a user.""" records = ( cls.query.join(OrgModel) - .filter(cls.user_id == user_id) + .filter(cls.user_id == int(user_id or -1)) .filter(cls.status.in_(valid_statuses)) .filter(OrgModel.status_code.in_(VALID_ORG_STATUSES)) .all() @@ -116,11 +118,11 @@ def find_orgs_for_user(cls, user_id, valid_statuses=VALID_STATUSES) -> List[OrgM return list(map(lambda x: x.org, records)) @classmethod - def find_active_staff_org_memberships_for_user(cls, user_id) -> List[Membership]: + def find_active_staff_org_memberships_for_user(cls, user_id: int) -> List[Membership]: """Find staff orgs memberships for a user.""" return ( cls.query.join(OrgModel) - .filter(cls.user_id == user_id) + .filter(cls.user_id == int(user_id or -1)) .filter(cls.status == Status.ACTIVE.value) .filter(OrgModel.status_code.in_(VALID_ORG_STATUSES)) .filter(OrgModel.type_code == OrgType.STAFF.value) @@ -128,7 +130,7 @@ def find_active_staff_org_memberships_for_user(cls, user_id) -> List[Membership] ) @classmethod - def add_membership_for_staff(cls, user_id): + def add_membership_for_staff(cls, user_id: int): """Add staff membership.""" if staff_orgs := OrgModel.find_by_org_type(OrgType.STAFF.value): membership = cls.find_membership_by_user_and_org(user_id, staff_orgs[0].id) @@ -138,7 +140,7 @@ def add_membership_for_staff(cls, user_id): membership.save() @classmethod - def remove_membership_for_staff(cls, user_id): + def remove_membership_for_staff(cls, user_id: int): """Remove staff membership.""" staff_memberships = cls.find_active_staff_org_memberships_for_user(user_id) for staff_membership in staff_memberships: @@ -146,7 +148,7 @@ def remove_membership_for_staff(cls, user_id): staff_membership.save() @classmethod - def find_membership_by_user_and_org(cls, user_id, org_id) -> Membership: + def find_membership_by_user_and_org(cls, user_id: int, org_id: int) -> Membership: """Get the membership for the specified user and org.""" records = ( cls.query.filter(cls.user_id == user_id) @@ -159,25 +161,25 @@ def find_membership_by_user_and_org(cls, user_id, org_id) -> Membership: return records @classmethod - def find_membership_by_userid(cls, user_id) -> Membership: + def find_membership_by_userid(cls, user_id: int) -> Membership: """Get the membership for the specified user.""" - records = cls.query.filter(cls.user_id == user_id).order_by(desc(Membership.created)).first() + records = cls.query.filter(cls.user_id == int(user_id or -1)).order_by(desc(Membership.created)).first() return records @classmethod - def find_memberships_by_user_ids(cls, user_id) -> List[Membership]: + def find_memberships_by_user_ids(cls, user_id: int) -> List[Membership]: """Get the memberships for the specified user ids.""" - records = cls.query.filter(cls.user_id == user_id).order_by(desc(Membership.created)).all() + records = cls.query.filter(cls.user_id == int(user_id or -1)).order_by(desc(Membership.created)).all() return records @classmethod - def find_membership_by_user_and_org_all_status(cls, user_id, org_id) -> Membership: + def find_membership_by_user_and_org_all_status(cls, user_id: int, org_id: int) -> Membership: """Get the membership for the specified user and org with all membership statuses.""" records = ( - cls.query.filter(cls.user_id == user_id) - .filter(cls.org_id == org_id) + cls.query.filter(cls.user_id == int(user_id or -1)) + .filter(cls.org_id == int(org_id or -1)) .order_by(desc(Membership.created)) .first() ) @@ -185,19 +187,19 @@ def find_membership_by_user_and_org_all_status(cls, user_id, org_id) -> Membersh return records @classmethod - def get_count_active_owner_org_id(cls, org_id) -> int: + def get_count_active_owner_org_id(cls, org_id: int) -> int: """Return the count of pending members.""" query = ( db.session.query(Membership) .filter( and_( - Membership.org_id == org_id, + Membership.org_id == int(org_id or -1), Membership.status == Status.ACTIVE.value, Membership.membership_type_code == ADMIN, ) ) .join(OrgModel) - .filter(OrgModel.id == org_id) + .filter(OrgModel.id == int(org_id or -1)) ) # pylint:disable=not-callable @@ -206,20 +208,20 @@ def get_count_active_owner_org_id(cls, org_id) -> int: return count @classmethod - def check_if_active_admin_or_owner_org_id(cls, org_id, user_id) -> int: + def check_if_active_admin_or_owner_org_id(cls, org_id: int, user_id: int) -> int: """Return the count of pending members.""" query = ( db.session.query(Membership) .filter( and_( - Membership.user_id == user_id, - Membership.org_id == org_id, + Membership.user_id == int(user_id or -1), + Membership.org_id == int(org_id or -1), Membership.status == Status.ACTIVE.value, Membership.membership_type_code.in_((ADMIN, COORDINATOR)), ) ) .join(OrgModel) - .filter(OrgModel.id == org_id) + .filter(OrgModel.id == int(org_id or -1)) ) # pylint:disable=not-callable count_q = query.statement.with_only_columns(func.count(), maintain_column_froms=True).order_by(None) @@ -233,7 +235,7 @@ def check_if_sbc_staff(cls, user_id: int) -> bool: db.session.query(Membership) .filter( and_( - Membership.user_id == user_id, + Membership.user_id == int(user_id or -1), Membership.status == Status.ACTIVE.value, Membership.org.has(OrgModel.type_code == OrgType.SBC_STAFF.value), ) diff --git a/auth-api/src/auth_api/models/org.py b/auth-api/src/auth_api/models/org.py index 3329609e41..0b26e8eb5b 100644 --- a/auth-api/src/auth_api/models/org.py +++ b/auth-api/src/auth_api/models/org.py @@ -118,9 +118,9 @@ def find_by_org_uuid(cls, org_uuid): return cls.query.filter_by(uuid=org_uuid).first() @classmethod - def find_by_org_id(cls, org_id): + def find_by_org_id(cls, org_id: int): """Find an Org instance that matches the provided id.""" - return cls.query.filter_by(id=org_id).first() + return cls.query.filter_by(id=int(org_id or -1)).first() @classmethod def find_by_bcol_id(cls, bcol_account_id): @@ -238,7 +238,7 @@ def _search_for_statuses(cls, query, statuses): return query @classmethod - def search_pending_activation_orgs(cls, name): + def search_pending_activation_orgs(cls, name: str): """Find all orgs with the given type.""" query = ( db.session.query(Org) @@ -271,7 +271,7 @@ def find_by_org_access_type(cls, org_type): return cls.query.filter_by(access_type=org_type).all() @classmethod - def find_similar_org_by_name(cls, name, org_id=None, branch_name=None): + def find_similar_org_by_name(cls, name, org_id: int = None, branch_name=None): """Find an Org instance that matches the provided name.""" query = cls.query.filter( and_( diff --git a/auth-api/src/auth_api/models/org_settings.py b/auth-api/src/auth_api/models/org_settings.py index 019e8c6291..da244ec8e2 100644 --- a/auth-api/src/auth_api/models/org_settings.py +++ b/auth-api/src/auth_api/models/org_settings.py @@ -37,14 +37,14 @@ class OrgSettings( org = relationship("Org") @classmethod - def get_org_settings(cls, org_id): + def get_org_settings(cls, org_id: int): """Return the default status code for an Org.""" - return cls.query.filter_by(org_id=org_id).all() + return cls.query.filter_by(org_id=int(org_id or -1)).all() @classmethod - def is_admin_auto_approved_invitees(cls, org_id): + def is_admin_auto_approved_invitees(cls, org_id: int): """Return the default status code for an Org.""" - org_model = cls.query.filter_by(org_id=org_id, setting="ADMIN_AUTO_APPROVAL_FOR_MEMBER_ACCEPTANCE").first() + org_model = cls.query.filter_by(org_id=int(org_id or -1), setting="ADMIN_AUTO_APPROVAL_FOR_MEMBER_ACCEPTANCE").first() if org_model is not None: return org_model.enabled return False diff --git a/auth-api/src/auth_api/models/product_subscription.py b/auth-api/src/auth_api/models/product_subscription.py index 21ef193223..9f512a904a 100644 --- a/auth-api/src/auth_api/models/product_subscription.py +++ b/auth-api/src/auth_api/models/product_subscription.py @@ -45,7 +45,7 @@ def find_by_org_ids(cls, org_ids, valid_statuses=VALID_SUBSCRIPTION_STATUSES): ).all() @classmethod - def find_by_org_id_product_code(cls, org_id, product_code, valid_statuses=VALID_SUBSCRIPTION_STATUSES): + def find_by_org_id_product_code(cls, org_id: int, product_code, valid_statuses=VALID_SUBSCRIPTION_STATUSES): """Find an product subscription instance that matches the provided id.""" return cls.query.filter( and_( diff --git a/auth-api/src/auth_api/models/pubsub_message_processing.py b/auth-api/src/auth_api/models/pubsub_message_processing.py index 6b9c4907c5..5f6f58a4dc 100644 --- a/auth-api/src/auth_api/models/pubsub_message_processing.py +++ b/auth-api/src/auth_api/models/pubsub_message_processing.py @@ -24,9 +24,9 @@ class PubSubMessageProcessing(db.Model): processed = Column(DateTime, nullable=True) @classmethod - def find_by_id(cls, identifier): + def find_by_id(cls, identifier: int): """Find a pubsub message processing by id.""" - return cls.query.filter_by(id=identifier).one_or_none() + return cls.query.filter_by(id=int(identifier)).one_or_none() @classmethod def find_by_cloud_event_id_and_type(cls, cloud_event_id, message_type): diff --git a/auth-api/src/auth_api/models/task.py b/auth-api/src/auth_api/models/task.py index bf5eb8ba4e..aea9caf5b2 100644 --- a/auth-api/src/auth_api/models/task.py +++ b/auth-api/src/auth_api/models/task.py @@ -93,9 +93,9 @@ def fetch_tasks(cls, task_search: TaskSearch): return pagination.items, pagination.total @classmethod - def find_by_task_id(cls, task_id): + def find_by_task_id(cls, task_id: int): """Find a task instance that matches the provided id.""" - return db.session.query(Task).filter_by(id=task_id).first() + return db.session.query(Task).filter_by(id=int(task_id or -1)).first() @classmethod def find_by_task_relationship_id( @@ -113,20 +113,20 @@ def find_by_task_relationship_id( ) @classmethod - def find_by_task_for_account(cls, org_id, status): + def find_by_task_for_account(cls, org_id: int, status): """Find a task instance that matches the provided id.""" return ( db.session.query(Task) - .filter_by(relationship_id=org_id, relationship_type=TaskRelationshipType.ORG.value, status=status) + .filter_by(relationship_id=int(org_id or -1), relationship_type=TaskRelationshipType.ORG.value, status=status) .first() ) @classmethod - def find_by_user_and_status(cls, org_id, status): + def find_by_user_and_status(cls, org_id: int, status): """Find a task instance that matches the provided id.""" return ( db.session.query(Task) - .filter_by(account_id=org_id, relationship_type=TaskRelationshipType.USER.value, status=status) + .filter_by(account_id=int(org_id or -1), relationship_type=TaskRelationshipType.USER.value, status=status) .first() ) diff --git a/auth-api/src/auth_api/models/user.py b/auth-api/src/auth_api/models/user.py index 77ed093294..a7928c98ba 100644 --- a/auth-api/src/auth_api/models/user.py +++ b/auth-api/src/auth_api/models/user.py @@ -227,7 +227,7 @@ def update_terms_of_use(cls, is_terms_accepted, terms_of_use_version, **kwargs): return None @classmethod - def find_users_by_org_id_by_status_by_roles(cls, org_id, roles, status=Status.ACTIVE.value): + def find_users_by_org_id_by_status_by_roles(cls, org_id: int, roles, status=Status.ACTIVE.value): """Find all members of the org with a status.""" return ( db.session.query(User) diff --git a/auth-api/src/auth_api/models/views/authorization.py b/auth-api/src/auth_api/models/views/authorization.py index d76d37d358..47e75dcf95 100644 --- a/auth-api/src/auth_api/models/views/authorization.py +++ b/auth-api/src/auth_api/models/views/authorization.py @@ -54,10 +54,10 @@ def find_user_authorization_by_business_number( auth = None if keycloak_guid and business_identifier and org_id: auth = cls.query.filter_by( - keycloak_guid=keycloak_guid, business_identifier=business_identifier, org_id=org_id + keycloak_guid=keycloak_guid, business_identifier=business_identifier, org_id=int(org_id or -1) ).one_or_none() elif business_identifier and org_id: - auth = cls.query.filter_by(business_identifier=business_identifier, org_id=org_id).first() + auth = cls.query.filter_by(business_identifier=business_identifier, org_id=int(org_id or -1)).first() elif keycloak_guid and business_identifier: auth = cls.query.filter_by(keycloak_guid=keycloak_guid, business_identifier=business_identifier).first() elif is_staff and business_identifier: @@ -86,23 +86,23 @@ def find_user_authorization_by_business_number_and_product(cls, business_identif @classmethod def find_user_authorization_by_org_id(cls, keycloak_guid: uuid, org_id: int): """Return authorization view object.""" - return cls.query.filter_by(keycloak_guid=keycloak_guid, org_id=org_id).one_or_none() + return cls.query.filter_by(keycloak_guid=keycloak_guid, org_id=int(org_id or -1)).one_or_none() @classmethod def find_authorization_for_admin_by_org_id(cls, org_id: int): """Return authorization view object for staff.""" # staff gets ADMIN level access - return cls.query.filter_by(org_id=org_id, org_membership=ADMIN).first() + return cls.query.filter_by(org_id=int(org_id or -1), org_membership=ADMIN).first() @classmethod def find_account_authorization_by_org_id_and_product_for_user(cls, keycloak_guid: uuid, org_id: int, product: str): """Return authorization view object.""" - return cls.query.filter_by(keycloak_guid=keycloak_guid, org_id=org_id, product_code=product).one_or_none() + return cls.query.filter_by(keycloak_guid=keycloak_guid, org_id=int(org_id or -1), product_code=product).one_or_none() @classmethod def find_account_authorization_by_org_id_and_product(cls, org_id: int, product: str): """Return authorization view object.""" - return cls.query.filter_by(org_id=org_id, product_code=product, org_membership=ADMIN).first() + return cls.query.filter_by(org_id=int(org_id or -1), product_code=product, org_membership=ADMIN).first() @classmethod def find_all_authorizations_for_user(cls, keycloak_guid): diff --git a/auth-api/src/auth_api/services/affiliation_invitation.py b/auth-api/src/auth_api/services/affiliation_invitation.py index cd20a5d86d..fb74b4ad78 100644 --- a/auth-api/src/auth_api/services/affiliation_invitation.py +++ b/auth-api/src/auth_api/services/affiliation_invitation.py @@ -446,7 +446,7 @@ def get_invitations_for_to_org(org_id, status=None, **kwargs): # If staff return full list if user_from_context.is_staff(): return AffiliationInvitationModel.filter_by( - AffiliationInvitationSearch(to_org_id=org_id, status_codes=["PENDING"]) + AffiliationInvitationSearch(to_org_id=int(org_id), status_codes=["PENDING"]) ) current_user: UserService = UserService.find_by_jwt_token() diff --git a/auth-api/src/auth_api/services/invitation.py b/auth-api/src/auth_api/services/invitation.py index 87e76bd011..acb9fd8b9a 100644 --- a/auth-api/src/auth_api/services/invitation.py +++ b/auth-api/src/auth_api/services/invitation.py @@ -187,13 +187,16 @@ def update_invitation(self, user, invitation_origin): def delete_invitation(invitation_id): """Delete the specified invitation.""" # Ensure that the current user is ADMIN or COORDINATOR for each org in the invitation - invitation = InvitationModel.find_invitation_by_id(invitation_id) - if invitation is None: + if invitation_id: + invitation = InvitationModel.find_invitation_by_id(invitation_id) + if invitation is None: + raise BusinessException(Error.DATA_NOT_FOUND, None) + for membership in invitation.membership: + org_id = membership.org_id + check_auth(org_id=org_id, one_of_roles=(ADMIN, COORDINATOR, STAFF)) + invitation.delete() + else: raise BusinessException(Error.DATA_NOT_FOUND, None) - for membership in invitation.membership: - org_id = membership.org_id - check_auth(org_id=org_id, one_of_roles=(ADMIN, COORDINATOR, STAFF)) - invitation.delete() @staticmethod @user_context From 879f024d2bb25e8b9b5e92b824a9f4c714aff54a Mon Sep 17 00:00:00 2001 From: pwei1018 Date: Fri, 20 Sep 2024 23:32:41 -0700 Subject: [PATCH 7/8] Fixed CD. --- .github/workflows/auth-web-cd.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/auth-web-cd.yml b/.github/workflows/auth-web-cd.yml index 88962760d8..c7ac4270b7 100644 --- a/.github/workflows/auth-web-cd.yml +++ b/.github/workflows/auth-web-cd.yml @@ -5,8 +5,8 @@ on: branches: - main - feature* - paths: - - "auth-web/**" + paths: + - "auth-web/**" workflow_dispatch: inputs: target: From 80f8a4a0cda1202e4cd828e4e03c43710099489c Mon Sep 17 00:00:00 2001 From: pwei1018 Date: Fri, 20 Sep 2024 23:34:18 -0700 Subject: [PATCH 8/8] Fixed linting. --- auth-api/src/auth_api/models/org_settings.py | 4 +++- auth-api/src/auth_api/models/task.py | 4 +++- auth-api/src/auth_api/models/views/authorization.py | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/auth-api/src/auth_api/models/org_settings.py b/auth-api/src/auth_api/models/org_settings.py index da244ec8e2..e3e6dac58d 100644 --- a/auth-api/src/auth_api/models/org_settings.py +++ b/auth-api/src/auth_api/models/org_settings.py @@ -44,7 +44,9 @@ def get_org_settings(cls, org_id: int): @classmethod def is_admin_auto_approved_invitees(cls, org_id: int): """Return the default status code for an Org.""" - org_model = cls.query.filter_by(org_id=int(org_id or -1), setting="ADMIN_AUTO_APPROVAL_FOR_MEMBER_ACCEPTANCE").first() + org_model = cls.query.filter_by( + org_id=int(org_id or -1), setting="ADMIN_AUTO_APPROVAL_FOR_MEMBER_ACCEPTANCE" + ).first() if org_model is not None: return org_model.enabled return False diff --git a/auth-api/src/auth_api/models/task.py b/auth-api/src/auth_api/models/task.py index aea9caf5b2..288cc6cc3e 100644 --- a/auth-api/src/auth_api/models/task.py +++ b/auth-api/src/auth_api/models/task.py @@ -117,7 +117,9 @@ def find_by_task_for_account(cls, org_id: int, status): """Find a task instance that matches the provided id.""" return ( db.session.query(Task) - .filter_by(relationship_id=int(org_id or -1), relationship_type=TaskRelationshipType.ORG.value, status=status) + .filter_by( + relationship_id=int(org_id or -1), relationship_type=TaskRelationshipType.ORG.value, status=status + ) .first() ) diff --git a/auth-api/src/auth_api/models/views/authorization.py b/auth-api/src/auth_api/models/views/authorization.py index 47e75dcf95..5575c39a6a 100644 --- a/auth-api/src/auth_api/models/views/authorization.py +++ b/auth-api/src/auth_api/models/views/authorization.py @@ -97,7 +97,9 @@ def find_authorization_for_admin_by_org_id(cls, org_id: int): @classmethod def find_account_authorization_by_org_id_and_product_for_user(cls, keycloak_guid: uuid, org_id: int, product: str): """Return authorization view object.""" - return cls.query.filter_by(keycloak_guid=keycloak_guid, org_id=int(org_id or -1), product_code=product).one_or_none() + return cls.query.filter_by( + keycloak_guid=keycloak_guid, org_id=int(org_id or -1), product_code=product + ).one_or_none() @classmethod def find_account_authorization_by_org_id_and_product(cls, org_id: int, product: str):