From 1bac2460707a5746e8ed2bac7302c1cd772d854b Mon Sep 17 00:00:00 2001 From: Ratheesh kumar R <108045773+ratheesh-aot@users.noreply.github.com> Date: Mon, 12 Feb 2024 12:46:44 -0800 Subject: [PATCH] DESENG-452 - Refactoring migrations (#2381) * DESENG-452: Delete old migration files * DESENG-452: Group migrations together * Updated Changelog * Unit test fix comment component length is max 10 * DESENG-452: Inserted initial data for Staff user table --- CHANGELOG.MD | 6 + ...added_url_path_column_to_feedback_table.py | 27 - .../versions/0329d7d10a5f_settings.py | 36 - met-api/migrations/versions/03ee1815f6a6_.py | 28 - met-api/migrations/versions/04e6c48187da_.py | 41 - met-api/migrations/versions/05d014ff7410_.py | 40 - .../08f69642b7ae_adding_widget_poll.py | 83 -- .../versions/0d863f773838_survey_block.py | 41 - .../0e043f976e2e_add_notes_to_submission.py | 38 - .../1113e0ad66c3_create_submission_table.py | 40 - met-api/migrations/versions/13985af9eca0_.py | 34 - .../versions/155c64768a99_create_cac_form.py | 44 -- ...ae2d586fb_add_generated_document_tables.py | 64 -- .../196b0abc23b6_tenant_id_in_user.py | 37 - met-api/migrations/versions/1c5883959156_.py | 35 - ...92c7b4_alter_engagement_add_is_internal.py | 28 - .../224b70277ac4_alter_commenttype.py | 28 - met-api/migrations/versions/2253a00e73bf_.py | 166 ---- met-api/migrations/versions/242c9f0364df_.py | 32 - ..._alter_engagement_add_created_by_upd_by.py | 37 - ...6609cb4db_update_report_settings_column.py | 46 -- .../2aa7554dde59_contact_adress_size.py | 34 - .../2b12a6cd987a_add_phases_widget_type.py | 33 - .../2b75eb893e6b_tenant_id_in_contact.py | 30 - .../31041fb90d53_membership_versioning.py | 37 - met-api/migrations/versions/326419c08f59_.py | 34 - .../36c315ec5801_add_encrypted_email.py | 92 --- met-api/migrations/versions/37176ea4708d_.py | 91 --- .../37176ea4708d_data_until_feb_09_2024.py | 536 +++++++++++++ ..._add_rich_description_to_subscribe_item.py | 37 - .../3e4dc76a96ab_added_the_timeline_widget.py | 44 -- .../versions/3f11e9145a08_events_table.py | 78 -- ...c_add_widget_id_to_widget_timeline_and_.py | 27 - .../45f89f245e3d_engagement_metadata.py | 37 - ...dc02be5_added_new_columns_to_user_table.py | 75 -- .../versions/47fc88fe0477_video_widget.py | 52 -- .../4c72047de4d3_add_staff_note_table.py | 41 - .../versions/4f5f91937f5c_merge_heads.py | 24 - .../5110026db916_create_feedback_table.py | 31 - .../versions/5423fd515e04_added_shapefile.py | 29 - .../versions/587badc69491_email_queue.py | 39 - .../5880bead8f03_email_verification_type.py | 30 - .../5a1258a76598_add_subscribe_to_project.py | 31 - .../642925969c53_added_documents_table.py | 43 -- met-api/migrations/versions/6764af39864e_.py | 27 - ...1704cb_create_widget_and_contact_tables.py | 79 -- .../6d3c33a79c5e_add_email_verification.py | 41 - .../779d9125c8cb_add_reviewer_type.py | 32 - .../7bf7394a517c_feedback_ratingtype.py | 36 - met-api/migrations/versions/7cb3da03c2a2_.py | 28 - .../versions/7d8897c412de_tenant_model.py | 78 -- met-api/migrations/versions/7ebd9ecfccdd_.py | 55 -- ...759_alter_submission_add_comment_status.py | 60 -- .../versions/8595172f9d96_add_map_type.py | 36 - .../88aba309bc23_add_engagement_slug.py | 70 -- ...f6e60d_alter_user_table_add_external_id.py | 32 - .../8ca063aafc01_create_comment_table.py | 56 -- .../8def759e43d9_add_participant_table.py | 93 --- .../versions/904c1ebca3e3_merge_heads.py | 24 - met-api/migrations/versions/9536f547cdd5_.py | 30 - .../versions/9714d7f8d7cc_size_increase.py | 30 - .../9f86fdcfb248_add_widget_type_document.py | 33 - met-api/migrations/versions/a1237c8a3df9_.py | 43 -- met-api/migrations/versions/a2d20b31e275_.py | 78 -- .../ac4a505ed1e3_add_feedback_source.py | 30 - .../b1196306955f_tracking_id_for_metadata.py | 28 - .../versions/b3b5c66cea4b_report_setting.py | 45 -- .../ba02399c821c_add_closed_status.py | 41 - ...25caf_adding_engagement_consent_message.py | 28 - .../versions/be3880132244_merge_heads.py | 24 - ...08_added_enum_value_for_timeline_widget.py | 61 -- ...c1af9f2b_alter_engagement_add_scheduled.py | 38 - .../cad222167ce7_memberships_added.py | 58 -- .../cb965cb4a3ad_update_comment_status.py | 27 - ...9ba77_alter_engagement_alter_banner_url.py | 30 - .../d152f85734f9_subscription_models.py | 40 - .../d2e7baa531ce_edit_subscription_models.py | 32 - .../versions/d5a6d9bb804b_merge_heads.py | 24 - ...f35c9_add_engagement_unpublished_status.py | 34 - .../versions/d86a682d7096_merge_heads.py | 24 - .../d9777850eb98_add_proponent_template.py | 56 -- met-api/migrations/versions/db3ffa0dd6ad_.py | 29 - met-api/migrations/versions/db737a0db061_.py | 43 -- .../versions/df73727dc6d9b7_add_sub_tabl.py | 55 -- met-api/migrations/versions/df842dc6d0b7_.py | 27 - .../e2d5d38220d9_add_revoked_membership.py | 46 -- .../e37d79be3a05_added_sort_for_widgets.py | 28 - .../e5d3bbb8d2f0_add_survey_hidden_column.py | 30 - .../versions/e69d7ac92afb_alter_submission.py | 47 -- ...ec0128056a33_rework_engagement_metadata.py | 164 ---- .../ec0128056a33_table_until_feb_09_2024.py | 709 ++++++++++++++++++ .../ec504565fab3_update_status_and_user.py | 53 -- met-api/migrations/versions/eef9cc71cca7_.py | 28 - .../f037908194df_kc_attribute_script.py | 39 - ...08c8d60_alter_comment_add_submission_id.py | 51 -- .../f40da1b8f3e0_initialize_user_status.py | 28 - ...f6f480b5b664_add_survey_template_column.py | 30 - met-api/migrations/versions/f99eb7f53041_.py | 34 - .../versions/fc570c0faace_survey_migration.py | 41 - .../fda10461892d_basemodel_column_change.py | 52 -- .../ffac8f5b4288_add_reject_reason.py | 30 - met-api/tests/utilities/factory_scenarios.py | 2 +- 102 files changed, 1252 insertions(+), 4331 deletions(-) delete mode 100644 met-api/migrations/versions/02ff8ecc6b91_added_url_path_column_to_feedback_table.py delete mode 100644 met-api/migrations/versions/0329d7d10a5f_settings.py delete mode 100644 met-api/migrations/versions/03ee1815f6a6_.py delete mode 100644 met-api/migrations/versions/04e6c48187da_.py delete mode 100644 met-api/migrations/versions/05d014ff7410_.py delete mode 100644 met-api/migrations/versions/08f69642b7ae_adding_widget_poll.py delete mode 100644 met-api/migrations/versions/0d863f773838_survey_block.py delete mode 100644 met-api/migrations/versions/0e043f976e2e_add_notes_to_submission.py delete mode 100644 met-api/migrations/versions/1113e0ad66c3_create_submission_table.py delete mode 100644 met-api/migrations/versions/13985af9eca0_.py delete mode 100644 met-api/migrations/versions/155c64768a99_create_cac_form.py delete mode 100644 met-api/migrations/versions/17bae2d586fb_add_generated_document_tables.py delete mode 100644 met-api/migrations/versions/196b0abc23b6_tenant_id_in_user.py delete mode 100644 met-api/migrations/versions/1c5883959156_.py delete mode 100644 met-api/migrations/versions/21e24b92c7b4_alter_engagement_add_is_internal.py delete mode 100644 met-api/migrations/versions/224b70277ac4_alter_commenttype.py delete mode 100644 met-api/migrations/versions/2253a00e73bf_.py delete mode 100644 met-api/migrations/versions/242c9f0364df_.py delete mode 100644 met-api/migrations/versions/2545d45bb29c_alter_engagement_add_created_by_upd_by.py delete mode 100644 met-api/migrations/versions/25e6609cb4db_update_report_settings_column.py delete mode 100644 met-api/migrations/versions/2aa7554dde59_contact_adress_size.py delete mode 100644 met-api/migrations/versions/2b12a6cd987a_add_phases_widget_type.py delete mode 100644 met-api/migrations/versions/2b75eb893e6b_tenant_id_in_contact.py delete mode 100644 met-api/migrations/versions/31041fb90d53_membership_versioning.py delete mode 100644 met-api/migrations/versions/326419c08f59_.py delete mode 100644 met-api/migrations/versions/36c315ec5801_add_encrypted_email.py delete mode 100644 met-api/migrations/versions/37176ea4708d_.py create mode 100644 met-api/migrations/versions/37176ea4708d_data_until_feb_09_2024.py delete mode 100644 met-api/migrations/versions/3a88de1e3e7f_add_rich_description_to_subscribe_item.py delete mode 100644 met-api/migrations/versions/3e4dc76a96ab_added_the_timeline_widget.py delete mode 100644 met-api/migrations/versions/3f11e9145a08_events_table.py delete mode 100644 met-api/migrations/versions/4114001e1a4c_add_widget_id_to_widget_timeline_and_.py delete mode 100644 met-api/migrations/versions/45f89f245e3d_engagement_metadata.py delete mode 100644 met-api/migrations/versions/46490dc02be5_added_new_columns_to_user_table.py delete mode 100644 met-api/migrations/versions/47fc88fe0477_video_widget.py delete mode 100644 met-api/migrations/versions/4c72047de4d3_add_staff_note_table.py delete mode 100644 met-api/migrations/versions/4f5f91937f5c_merge_heads.py delete mode 100644 met-api/migrations/versions/5110026db916_create_feedback_table.py delete mode 100644 met-api/migrations/versions/5423fd515e04_added_shapefile.py delete mode 100644 met-api/migrations/versions/587badc69491_email_queue.py delete mode 100644 met-api/migrations/versions/5880bead8f03_email_verification_type.py delete mode 100644 met-api/migrations/versions/5a1258a76598_add_subscribe_to_project.py delete mode 100644 met-api/migrations/versions/642925969c53_added_documents_table.py delete mode 100644 met-api/migrations/versions/6764af39864e_.py delete mode 100644 met-api/migrations/versions/6ce7831704cb_create_widget_and_contact_tables.py delete mode 100644 met-api/migrations/versions/6d3c33a79c5e_add_email_verification.py delete mode 100644 met-api/migrations/versions/779d9125c8cb_add_reviewer_type.py delete mode 100644 met-api/migrations/versions/7bf7394a517c_feedback_ratingtype.py delete mode 100644 met-api/migrations/versions/7cb3da03c2a2_.py delete mode 100644 met-api/migrations/versions/7d8897c412de_tenant_model.py delete mode 100644 met-api/migrations/versions/7ebd9ecfccdd_.py delete mode 100644 met-api/migrations/versions/7faee53e6759_alter_submission_add_comment_status.py delete mode 100644 met-api/migrations/versions/8595172f9d96_add_map_type.py delete mode 100644 met-api/migrations/versions/88aba309bc23_add_engagement_slug.py delete mode 100644 met-api/migrations/versions/8ab640f6e60d_alter_user_table_add_external_id.py delete mode 100644 met-api/migrations/versions/8ca063aafc01_create_comment_table.py delete mode 100644 met-api/migrations/versions/8def759e43d9_add_participant_table.py delete mode 100644 met-api/migrations/versions/904c1ebca3e3_merge_heads.py delete mode 100644 met-api/migrations/versions/9536f547cdd5_.py delete mode 100644 met-api/migrations/versions/9714d7f8d7cc_size_increase.py delete mode 100644 met-api/migrations/versions/9f86fdcfb248_add_widget_type_document.py delete mode 100644 met-api/migrations/versions/a1237c8a3df9_.py delete mode 100644 met-api/migrations/versions/a2d20b31e275_.py delete mode 100644 met-api/migrations/versions/ac4a505ed1e3_add_feedback_source.py delete mode 100644 met-api/migrations/versions/b1196306955f_tracking_id_for_metadata.py delete mode 100644 met-api/migrations/versions/b3b5c66cea4b_report_setting.py delete mode 100644 met-api/migrations/versions/ba02399c821c_add_closed_status.py delete mode 100644 met-api/migrations/versions/bd0eb0d25caf_adding_engagement_consent_message.py delete mode 100644 met-api/migrations/versions/be3880132244_merge_heads.py delete mode 100644 met-api/migrations/versions/c09e77fde608_added_enum_value_for_timeline_widget.py delete mode 100644 met-api/migrations/versions/c19bc1af9f2b_alter_engagement_add_scheduled.py delete mode 100644 met-api/migrations/versions/cad222167ce7_memberships_added.py delete mode 100644 met-api/migrations/versions/cb965cb4a3ad_update_comment_status.py delete mode 100644 met-api/migrations/versions/d0f92ae9ba77_alter_engagement_alter_banner_url.py delete mode 100644 met-api/migrations/versions/d152f85734f9_subscription_models.py delete mode 100644 met-api/migrations/versions/d2e7baa531ce_edit_subscription_models.py delete mode 100644 met-api/migrations/versions/d5a6d9bb804b_merge_heads.py delete mode 100644 met-api/migrations/versions/d822eacf35c9_add_engagement_unpublished_status.py delete mode 100644 met-api/migrations/versions/d86a682d7096_merge_heads.py delete mode 100644 met-api/migrations/versions/d9777850eb98_add_proponent_template.py delete mode 100644 met-api/migrations/versions/db3ffa0dd6ad_.py delete mode 100644 met-api/migrations/versions/db737a0db061_.py delete mode 100644 met-api/migrations/versions/df73727dc6d9b7_add_sub_tabl.py delete mode 100644 met-api/migrations/versions/df842dc6d0b7_.py delete mode 100644 met-api/migrations/versions/e2d5d38220d9_add_revoked_membership.py delete mode 100644 met-api/migrations/versions/e37d79be3a05_added_sort_for_widgets.py delete mode 100644 met-api/migrations/versions/e5d3bbb8d2f0_add_survey_hidden_column.py delete mode 100644 met-api/migrations/versions/e69d7ac92afb_alter_submission.py delete mode 100644 met-api/migrations/versions/ec0128056a33_rework_engagement_metadata.py create mode 100644 met-api/migrations/versions/ec0128056a33_table_until_feb_09_2024.py delete mode 100644 met-api/migrations/versions/ec504565fab3_update_status_and_user.py delete mode 100644 met-api/migrations/versions/eef9cc71cca7_.py delete mode 100644 met-api/migrations/versions/f037908194df_kc_attribute_script.py delete mode 100644 met-api/migrations/versions/f2b3f08c8d60_alter_comment_add_submission_id.py delete mode 100644 met-api/migrations/versions/f40da1b8f3e0_initialize_user_status.py delete mode 100644 met-api/migrations/versions/f6f480b5b664_add_survey_template_column.py delete mode 100644 met-api/migrations/versions/f99eb7f53041_.py delete mode 100644 met-api/migrations/versions/fc570c0faace_survey_migration.py delete mode 100644 met-api/migrations/versions/fda10461892d_basemodel_column_change.py delete mode 100644 met-api/migrations/versions/ffac8f5b4288_add_reject_reason.py diff --git a/CHANGELOG.MD b/CHANGELOG.MD index 493ab6359..7aefb3db2 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -1,3 +1,9 @@ +## February 09, 2024 +- **Task**Consolidate and re-write old migration files [DESENG-452](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-452) + - Deleted old migration files + - Created [ec0128056a33_table_until_feb_09_2024.py](met-api/migrations/versions/ec0128056a33_table_until_feb_09_2024.py) with all tables until feb 09 2024 + - Created [37176ea4708d_data_until_feb_09_2024.py](met-api/migrations/versions/37176ea4708d_data_until_feb_09_2024.py) with all initial data until feb 09 2024 + ## February 08, 2024 - **Task**Cache CORS preflight responses with the browser for a given period of time [DESENG-484](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-484) - Introduces a new configuration variable to specify the maximum age for Cross-Origin Resource Sharing (CORS) diff --git a/met-api/migrations/versions/02ff8ecc6b91_added_url_path_column_to_feedback_table.py b/met-api/migrations/versions/02ff8ecc6b91_added_url_path_column_to_feedback_table.py deleted file mode 100644 index 138f01cf5..000000000 --- a/met-api/migrations/versions/02ff8ecc6b91_added_url_path_column_to_feedback_table.py +++ /dev/null @@ -1,27 +0,0 @@ -"""Added URL path column to feedback table. - -Revision ID: 02ff8ecc6b91 -Revises: 25e6609cb4db -Create Date: 2023-11-10 10:33:06.780841 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '02ff8ecc6b91' -down_revision = '25e6609cb4db' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('feedback', sa.Column('submission_path', sa.String())) - # ### end Alembic commands ### - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('feedback', 'submission_path') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/0329d7d10a5f_settings.py b/met-api/migrations/versions/0329d7d10a5f_settings.py deleted file mode 100644 index eed7b9cb2..000000000 --- a/met-api/migrations/versions/0329d7d10a5f_settings.py +++ /dev/null @@ -1,36 +0,0 @@ -""" Add engagement settings table - -Revision ID: 0329d7d10a5f -Revises: df842dc6d0b7 -Create Date: 2023-07-21 13:51:38.752604 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = '0329d7d10a5f' -down_revision = 'df842dc6d0b7' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('engagement_settings', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('engagement_id', sa.Integer(), nullable=False), - sa.Column('send_report', sa.Boolean(), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('engagement_id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('engagement_settings') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/03ee1815f6a6_.py b/met-api/migrations/versions/03ee1815f6a6_.py deleted file mode 100644 index 085b3b392..000000000 --- a/met-api/migrations/versions/03ee1815f6a6_.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Add avatar_filename to contact - -Revision ID: 03ee1815f6a6 -Revises: 9536f547cdd5 -Create Date: 2022-11-10 14:21:02.844093 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '03ee1815f6a6' -down_revision = '9536f547cdd5' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('contact', sa.Column('avatar_filename', sa.String(), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('contact', 'avatar_filename') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/04e6c48187da_.py b/met-api/migrations/versions/04e6c48187da_.py deleted file mode 100644 index bd77fb09b..000000000 --- a/met-api/migrations/versions/04e6c48187da_.py +++ /dev/null @@ -1,41 +0,0 @@ -""" - -Revision ID: 04e6c48187da -Revises: f40da1b8f3e0 -Create Date: 2023-08-18 12:45:30.620941 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '04e6c48187da' -down_revision = 'f40da1b8f3e0' -branch_labels = None -depends_on = None - -# Define the Enum type for feedback status -feedback_status_enum = sa.Enum( - 'Unreviewed', 'Archived', name='feedbackstatustype') - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - - # Create the Enum type in the database - feedback_status_enum.create(op.get_bind()) - - op.add_column('feedback', sa.Column('status', sa.Enum( - 'Unreviewed', 'Archived', name='feedbackstatustype'), nullable=True)) - op.execute('UPDATE "feedback" SET status = \'Unreviewed\'') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('feedback', 'status') - - # Drop the Enum type from the database - feedback_status_enum.drop(op.get_bind()) - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/05d014ff7410_.py b/met-api/migrations/versions/05d014ff7410_.py deleted file mode 100644 index cd43a62f8..000000000 --- a/met-api/migrations/versions/05d014ff7410_.py +++ /dev/null @@ -1,40 +0,0 @@ -"""empty message - -Revision ID: 05d014ff7410 -Revises: 8ab640f6e60d -Create Date: 2022-06-20 11:21:12.300505 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '05d014ff7410' -down_revision = '8ab640f6e60d' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('engagement', sa.Column('content', sa.Text(), nullable=False, server_default="")) - op.add_column('engagement', sa.Column('rich_content', postgresql.JSON(astext_type=sa.Text()), nullable=False, server_default="{}")) - op.add_column('engagement', sa.Column('banner_url', sa.String(), nullable=True)) - op.alter_column('engagement', 'description', - existing_type=sa.VARCHAR(), - nullable=False, - server_default="" - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('engagement', 'description', - existing_type=sa.VARCHAR(), - nullable=True) - op.drop_column('engagement', 'banner_url') - op.drop_column('engagement', 'rich_content') - op.drop_column('engagement', 'content') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/08f69642b7ae_adding_widget_poll.py b/met-api/migrations/versions/08f69642b7ae_adding_widget_poll.py deleted file mode 100644 index 4f87cbe95..000000000 --- a/met-api/migrations/versions/08f69642b7ae_adding_widget_poll.py +++ /dev/null @@ -1,83 +0,0 @@ -"""adding_widget_poll - -Revision ID: 08f69642b7ae -Revises: bd0eb0d25caf -Create Date: 2024-01-16 14:25:07.611485 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '08f69642b7ae' -down_revision = 'bd0eb0d25caf' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('widget_polls', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('title', sa.String(length=255), nullable=False), - sa.Column('description', sa.String(length=2048), nullable=True), - sa.Column('status', sa.Enum('active', 'inactive', name='poll_status'), nullable=True), - sa.Column('widget_id', sa.Integer(), nullable=False), - sa.Column('engagement_id', sa.Integer(), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('poll_answers', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('answer_text', sa.String(length=255), nullable=False), - sa.Column('poll_id', sa.Integer(), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['poll_id'], ['widget_polls.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('poll_responses', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('participant_id', sa.String(length=255), nullable=False), - sa.Column('selected_answer_id', sa.Integer(), nullable=False), - sa.Column('poll_id', sa.Integer(), nullable=False), - sa.Column('widget_id', sa.Integer(), nullable=False), - sa.Column('is_deleted', sa.Boolean(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['poll_id'], ['widget_polls.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['selected_answer_id'], ['poll_answers.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - widget_type_table = sa.table('widget_type', - sa.Column('id', sa.Integer), - sa.Column('name', sa.String), - sa.Column('description', sa.String)) - - op.bulk_insert(widget_type_table, [ - {'id': 10, 'name': 'Poll', 'description': 'The Poll Widget enables real-time polling and feedback collection from public.'} - ]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('poll_responses') - op.drop_table('poll_answers') - op.drop_table('widget_polls') - - conn = op.get_bind() - - conn.execute('DELETE FROM widget_type WHERE id=10') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/0d863f773838_survey_block.py b/met-api/migrations/versions/0d863f773838_survey_block.py deleted file mode 100644 index eb264dbff..000000000 --- a/met-api/migrations/versions/0d863f773838_survey_block.py +++ /dev/null @@ -1,41 +0,0 @@ -"""survey_block - -Revision ID: 0d863f773838 -Revises: 6764af39864e -Create Date: 2022-12-21 20:23:24.907724 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '0d863f773838' -down_revision = '6764af39864e' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('engagement_status_block', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('engagement_id', sa.Integer(), nullable=True), - sa.Column('survey_status', sa.Enum('Upcoming', 'Open', 'Closed', name='submissionstatus'), nullable=False), - sa.Column('block_text', postgresql.JSON(astext_type=sa.Text()), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('engagement_id', 'survey_status', name='unique_engagement_status_block') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('engagement_status_block') - op.execute('DROP TYPE submissionstatus;') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/0e043f976e2e_add_notes_to_submission.py b/met-api/migrations/versions/0e043f976e2e_add_notes_to_submission.py deleted file mode 100644 index ecfd727ce..000000000 --- a/met-api/migrations/versions/0e043f976e2e_add_notes_to_submission.py +++ /dev/null @@ -1,38 +0,0 @@ -"""add_notes_to_submission - -Revision ID: 0e043f976e2e -Revises: 17bae2d586fb -Create Date: 2023-01-10 12:18:43.395103 - -""" -from alembic import op -import sqlalchemy as sa -from datetime import datetime - - -# revision identifiers, used by Alembic. -revision = '0e043f976e2e' -down_revision = '17bae2d586fb' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('submission', sa.Column('notify_email', sa.Boolean(), nullable=True)) - comment_status_table = sa.table('comment_status', - sa.Column('id', sa.Integer()), - sa.Column('status_name', sa.String(length=50)), - sa.Column('description', sa.String(length=50)), - sa.Column('created_date', sa.DateTime()), - sa.Column('updated_date', sa.DateTime())) - op.bulk_insert(comment_status_table, [ - {'id': 4, 'status_name': 'Needs further review', 'description': 'Comment needs further review', 'created_date': datetime.utcnow(), 'updated_date': datetime.utcnow()}, - ]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('submission', 'notify_email') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/1113e0ad66c3_create_submission_table.py b/met-api/migrations/versions/1113e0ad66c3_create_submission_table.py deleted file mode 100644 index c34abbc86..000000000 --- a/met-api/migrations/versions/1113e0ad66c3_create_submission_table.py +++ /dev/null @@ -1,40 +0,0 @@ -"""Create submission table - -Revision ID: 1113e0ad66c3 -Revises: fc570c0faace -Create Date: 2022-07-06 15:33:00.098038 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '1113e0ad66c3' -down_revision = 'fc570c0faace' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('submission', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('submission_json', postgresql.JSONB(astext_type=sa.Text()), server_default='{}', nullable=False), - sa.Column('survey_id', sa.Integer(), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=True), - sa.Column('created_date', sa.DateTime(), nullable=True), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['survey_id'], ['survey.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['user_id'], ['user.id']), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('submission') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/13985af9eca0_.py b/met-api/migrations/versions/13985af9eca0_.py deleted file mode 100644 index b9b6dbada..000000000 --- a/met-api/migrations/versions/13985af9eca0_.py +++ /dev/null @@ -1,34 +0,0 @@ -""" - -Revision ID: 13985af9eca0 -Revises: 21e24b92c7b4 -Create Date: 2023-05-17 09:51:00.350393 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '13985af9eca0' -down_revision = '21e24b92c7b4' -branch_labels = None -depends_on = None - - -def upgrade(): - op.add_column('tenant', sa.Column('title', sa.String(length=30), nullable=True)) - op.add_column('tenant', sa.Column('logo_url', sa.String(length=300), nullable=True)) - op.alter_column('tenant', 'description', - existing_type=sa.String(100), - type_=sa.String(300)) - op.execute('UPDATE tenant SET title = \'Modern Engagement\';') - op.execute('UPDATE tenant SET description = \'British Columbia\'\'s environmental assessment process provides opportunities for Indigenous Nations, government agencies and the public to influence the outcome of environmental assessments in British Columbia.\' WHERE short_name = \'EAO\';') - op.alter_column('tenant', 'title', - existing_type=sa.String(), - nullable=False) - - -def downgrade(): - op.drop_column('tenant', 'logo_url') - op.drop_column('tenant', 'title') diff --git a/met-api/migrations/versions/155c64768a99_create_cac_form.py b/met-api/migrations/versions/155c64768a99_create_cac_form.py deleted file mode 100644 index 33ae0141d..000000000 --- a/met-api/migrations/versions/155c64768a99_create_cac_form.py +++ /dev/null @@ -1,44 +0,0 @@ -""" create cac form table - -Revision ID: 155c64768a99 -Revises: 9714d7f8d7cc -Create Date: 2023-09-05 16:23:11.567528 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = '155c64768a99' -down_revision = '9714d7f8d7cc' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('cac_form', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('engagement_id', sa.Integer(), nullable=False), - sa.Column('tenant_id', sa.Integer(), nullable=True), - sa.Column('understand', sa.Boolean(), nullable=False), - sa.Column('terms_of_reference', sa.Boolean(), nullable=False), - sa.Column('first_name', sa.String(length=50), nullable=False), - sa.Column('last_name', sa.String(length=50), nullable=False), - sa.Column('city', sa.String(length=50), nullable=False), - sa.Column('email', sa.String(length=50), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('cac_form') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/17bae2d586fb_add_generated_document_tables.py b/met-api/migrations/versions/17bae2d586fb_add_generated_document_tables.py deleted file mode 100644 index 1a16fc3e4..000000000 --- a/met-api/migrations/versions/17bae2d586fb_add_generated_document_tables.py +++ /dev/null @@ -1,64 +0,0 @@ -"""Add generated document models - -Revision ID: 17bae2d586fb -Revises: 904c1ebca3e3 -Create Date: 2022-12-27 16:16:50.850377 - -""" -from alembic import op -import sqlalchemy as sa -from datetime import datetime - - -# revision identifiers, used by Alembic. -revision = '17bae2d586fb' -down_revision = '904c1ebca3e3' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - document_type = op.create_table('generated_document_type', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('name', sa.String(length=30), nullable=False), - sa.Column('description', sa.String(length=100), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - document_template = op.create_table('generated_document_template', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('type_id', sa.Integer(), nullable=False), - sa.Column('hash_code', sa.String(length=64), nullable=True), - sa.Column('extension', sa.String(length=10), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['type_id'], ['generated_document_type.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('hash_code') - ) - op.drop_index('ix_user_username', table_name='met_users') - op.create_index(op.f('ix_met_users_username'), 'met_users', ['username'], unique=False) - - op.bulk_insert(document_type, [ - {'id': 1, 'name': 'comment_sheet', 'description': 'Comments export for staff', "created_date": datetime.utcnow()} - ]) - - op.bulk_insert(document_template, [ - {'id': 1, 'type_id': 1, 'hash_code': None, "extension": "xlsx", "created_date": datetime.utcnow()} - ]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_met_users_username'), table_name='met_users') - op.create_index('ix_user_username', 'met_users', ['username'], unique=False) - op.drop_table('generated_document_template') - op.drop_table('generated_document_type') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/196b0abc23b6_tenant_id_in_user.py b/met-api/migrations/versions/196b0abc23b6_tenant_id_in_user.py deleted file mode 100644 index 260f8f3fb..000000000 --- a/met-api/migrations/versions/196b0abc23b6_tenant_id_in_user.py +++ /dev/null @@ -1,37 +0,0 @@ -"""tenant id in user - -Revision ID: 196b0abc23b6 -Revises: 13985af9eca0 -Create Date: 2023-05-23 05:09:51.963357 - -""" -import sqlalchemy as sa -from alembic import op -from flask import current_app - -from met_api.models import Tenant as TenantModel - -# revision identifiers, used by Alembic. -revision = '196b0abc23b6' -down_revision = '13985af9eca0' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('met_users', sa.Column('tenant_id', sa.Integer(), nullable=True)) - op.create_foreign_key('met_users_tenant_fk', 'met_users', 'tenant', ['tenant_id'], ['id']) - op.execute("commit") - - default_short_name = current_app.config.get('DEFAULT_TENANT_SHORT_NAME') - update_stmt = sa.text('UPDATE met_users SET tenant_id = (SELECT tenant.id FROM tenant WHERE short_name = :default_short_name)') - op.execute(update_stmt.params(default_short_name=default_short_name)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('met_users_tenant_fk', 'met_users', type_='foreignkey') - op.drop_column('met_users', 'tenant_id') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/1c5883959156_.py b/met-api/migrations/versions/1c5883959156_.py deleted file mode 100644 index dfbafa148..000000000 --- a/met-api/migrations/versions/1c5883959156_.py +++ /dev/null @@ -1,35 +0,0 @@ -""" - -Revision ID: 1c5883959156 -Revises: f037908194df -Create Date: 2023-08-29 20:37:58.652800 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '1c5883959156' -down_revision = 'f037908194df' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('feedback', 'status', - existing_type=postgresql.ENUM( - 'Unreviewed', 'Archived', name='feedbackstatustype'), - nullable=False) - op.execute('UPDATE "feedback" SET status = \'Unreviewed\'') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('feedback', 'status', - existing_type=postgresql.ENUM( - 'Unreviewed', 'Archived', name='feedbackstatustype'), - nullable=True) - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/21e24b92c7b4_alter_engagement_add_is_internal.py b/met-api/migrations/versions/21e24b92c7b4_alter_engagement_add_is_internal.py deleted file mode 100644 index e38347439..000000000 --- a/met-api/migrations/versions/21e24b92c7b4_alter_engagement_add_is_internal.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Alter engagement Add is_internal - -Revision ID: 21e24b92c7b4 -Revises: 2b75eb893e6b -Create Date: 2023-05-12 13:26:05.950118 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '21e24b92c7b4' -down_revision = '2b75eb893e6b' -branch_labels = None -depends_on = None - - -def upgrade(): - op.add_column('engagement', sa.Column('is_internal', sa.Boolean(), nullable=True)) - op.execute('UPDATE engagement SET is_internal = false') - op.alter_column('engagement', 'is_internal', - existing_type=sa.Boolean(), - nullable=False) - - -def downgrade(): - op.drop_column('engagement', 'is_internal') diff --git a/met-api/migrations/versions/224b70277ac4_alter_commenttype.py b/met-api/migrations/versions/224b70277ac4_alter_commenttype.py deleted file mode 100644 index 9ad62451f..000000000 --- a/met-api/migrations/versions/224b70277ac4_alter_commenttype.py +++ /dev/null @@ -1,28 +0,0 @@ -"""alter commenttype - -Revision ID: 224b70277ac4 -Revises: 5110026db916 -Create Date: 2022-10-05 11:00:13.349968 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '224b70277ac4' -down_revision = '5110026db916' -branch_labels = None -depends_on = None - - -def upgrade(): - op.alter_column('feedback', 'comment_type', type_=sa.Text()) - op.execute('DROP TYPE commenttype;') - op.execute('CREATE TYPE commenttype AS ENUM (\'Issue\', \'Idea\', \'Else\', \'NONE\');') - op.alter_column('feedback', 'comment_type', type_=sa.Enum('Issue', 'Idea', 'Else', 'NONE', name='commenttype'), postgresql_using='comment_type::commenttype') - - -def downgrade(): - # alter type will not be reverted since it does not impact the structure. - pass diff --git a/met-api/migrations/versions/2253a00e73bf_.py b/met-api/migrations/versions/2253a00e73bf_.py deleted file mode 100644 index 363874994..000000000 --- a/met-api/migrations/versions/2253a00e73bf_.py +++ /dev/null @@ -1,166 +0,0 @@ -""" - -Revision ID: 2253a00e73bf -Revises: cad222167ce7 -Create Date: 2023-02-06 10:57:24.811178 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '2253a00e73bf' -down_revision = 'cad222167ce7' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.execute('UPDATE comment SET created_date = CURRENT_TIMESTAMP WHERE created_date IS NULL;') - op.alter_column('comment', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.add_column('comment_status', sa.Column('created_by', sa.String(length=50), nullable=True)) - op.add_column('comment_status', sa.Column('updated_by', sa.String(length=50), nullable=True)) - op.alter_column('comment_status', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.alter_column('contact', 'updated_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.alter_column('contact', 'created_by', - existing_type=sa.VARCHAR(length=50), - nullable=True) - op.alter_column('contact', 'updated_by', - existing_type=sa.VARCHAR(length=50), - nullable=True) - op.alter_column('email_verification', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.add_column('engagement_status', sa.Column('created_by', sa.String(length=50), nullable=True)) - op.add_column('engagement_status', sa.Column('updated_by', sa.String(length=50), nullable=True)) - op.alter_column('engagement_status', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.add_column('feedback', sa.Column('updated_date', sa.DateTime(), nullable=True)) - op.add_column('feedback', sa.Column('created_by', sa.String(length=50), nullable=True)) - op.add_column('feedback', sa.Column('updated_by', sa.String(length=50), nullable=True)) - op.alter_column('feedback', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.add_column('membership_status_codes', sa.Column('created_date', sa.DateTime(), nullable=True)) - op.add_column('membership_status_codes', sa.Column('updated_date', sa.DateTime(), nullable=True)) - op.add_column('membership_status_codes', sa.Column('created_by', sa.String(length=50), nullable=True)) - op.add_column('membership_status_codes', sa.Column('updated_by', sa.String(length=50), nullable=True)) - op.add_column('met_users', sa.Column('created_by', sa.String(length=50), nullable=True)) - op.add_column('met_users', sa.Column('updated_by', sa.String(length=50), nullable=True)) - op.alter_column('met_users', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.alter_column('submission', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.alter_column('survey', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.alter_column('widget', 'updated_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.alter_column('widget', 'created_by', - existing_type=sa.VARCHAR(length=50), - nullable=True) - op.alter_column('widget', 'updated_by', - existing_type=sa.VARCHAR(length=50), - nullable=True) - op.alter_column('widget_item', 'updated_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.alter_column('widget_item', 'created_by', - existing_type=sa.VARCHAR(length=50), - nullable=True) - op.alter_column('widget_item', 'updated_by', - existing_type=sa.VARCHAR(length=50), - nullable=True) - op.add_column('widget_type', sa.Column('created_date', sa.DateTime(), nullable=True)) - op.add_column('widget_type', sa.Column('updated_date', sa.DateTime(), nullable=True)) - op.add_column('widget_type', sa.Column('created_by', sa.String(length=50), nullable=True)) - op.add_column('widget_type', sa.Column('updated_by', sa.String(length=50), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('widget_type', 'updated_by') - op.drop_column('widget_type', 'created_by') - op.drop_column('widget_type', 'updated_date') - op.drop_column('widget_type', 'created_date') - op.alter_column('widget_item', 'updated_by', - existing_type=sa.VARCHAR(length=50), - nullable=False) - op.alter_column('widget_item', 'created_by', - existing_type=sa.VARCHAR(length=50), - nullable=False) - op.alter_column('widget_item', 'updated_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.alter_column('widget', 'updated_by', - existing_type=sa.VARCHAR(length=50), - nullable=False) - op.alter_column('widget', 'created_by', - existing_type=sa.VARCHAR(length=50), - nullable=False) - op.alter_column('widget', 'updated_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.alter_column('survey', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.alter_column('submission', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.alter_column('met_users', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.drop_column('met_users', 'updated_by') - op.drop_column('met_users', 'created_by') - op.drop_column('membership_status_codes', 'updated_by') - op.drop_column('membership_status_codes', 'created_by') - op.drop_column('membership_status_codes', 'updated_date') - op.drop_column('membership_status_codes', 'created_date') - op.alter_column('feedback', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.drop_column('feedback', 'updated_by') - op.drop_column('feedback', 'created_by') - op.drop_column('feedback', 'updated_date') - op.alter_column('engagement_status', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.drop_column('engagement_status', 'updated_by') - op.drop_column('engagement_status', 'created_by') - op.alter_column('email_verification', 'type', - existing_type=postgresql.ENUM('Survey', 'RejectedComment', 'Subscribe', name='emailverificationtype'), - nullable=True) - op.alter_column('email_verification', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.alter_column('contact', 'updated_by', - existing_type=sa.VARCHAR(length=50), - nullable=False) - op.alter_column('contact', 'created_by', - existing_type=sa.VARCHAR(length=50), - nullable=False) - op.alter_column('contact', 'updated_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.alter_column('comment_status', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.drop_column('comment_status', 'updated_by') - op.drop_column('comment_status', 'created_by') - op.alter_column('comment', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/242c9f0364df_.py b/met-api/migrations/versions/242c9f0364df_.py deleted file mode 100644 index 64becace5..000000000 --- a/met-api/migrations/versions/242c9f0364df_.py +++ /dev/null @@ -1,32 +0,0 @@ -"""add subscribe widget type - -Revision ID: 242c9f0364df -Revises: 17bae2d586fb -Create Date: 2023-01-12 12:17:27.360418 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '242c9f0364df' -down_revision = '17bae2d586fb' -branch_labels = None -depends_on = None - - -def upgrade(): - widget_type_table = sa.table('widget_type', - sa.Column('id', sa.Integer), - sa.Column('name', sa.String), - sa.Column('description', sa.String)) - - op.bulk_insert(widget_type_table, [ - {'id': 4, 'name': 'Subscribe', 'description': 'Allows users to subscribe to an engagement'} - ]) - - -def downgrade(): - conn = op.get_bind() - conn.execute('DELETE FROM widget_type WHERE id=4') diff --git a/met-api/migrations/versions/2545d45bb29c_alter_engagement_add_created_by_upd_by.py b/met-api/migrations/versions/2545d45bb29c_alter_engagement_add_created_by_upd_by.py deleted file mode 100644 index d282379b3..000000000 --- a/met-api/migrations/versions/2545d45bb29c_alter_engagement_add_created_by_upd_by.py +++ /dev/null @@ -1,37 +0,0 @@ -"""Alter engagement add created_by upd_by - -Revision ID: 2545d45bb29c -Revises: 05d014ff7410 -Create Date: 2022-06-24 09:28:59.551336 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '2545d45bb29c' -down_revision = '05d014ff7410' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('engagement', sa.Column('created_by', sa.String(length=50), nullable=True)) - op.add_column('engagement', sa.Column('updated_by', sa.String(length=50), nullable=True)) - op.execute('UPDATE engagement SET created_by = user_id, updated_by = user_id WHERE created_by IS NULL') - op.drop_constraint('engagement_user_id_fkey', 'engagement', type_='foreignkey') - op.alter_column('engagement', 'created_by', nullable=False) - op.alter_column('engagement', 'updated_by', nullable=False) - op.drop_column('engagement', 'user_id') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('engagement', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True)) - op.create_foreign_key('engagement_user_id_fkey', 'engagement', 'user', ['user_id'], ['id'], ondelete='CASCADE') - op.drop_column('engagement', 'updated_by') - op.drop_column('engagement', 'created_by') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/25e6609cb4db_update_report_settings_column.py b/met-api/migrations/versions/25e6609cb4db_update_report_settings_column.py deleted file mode 100644 index 1553b0993..000000000 --- a/met-api/migrations/versions/25e6609cb4db_update_report_settings_column.py +++ /dev/null @@ -1,46 +0,0 @@ -"""update_report_settings_column - -Revision ID: 25e6609cb4db -Revises: d5a6d9bb804b -Create Date: 2023-10-04 15:58:26.818989 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '25e6609cb4db' -down_revision = 'd5a6d9bb804b' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('report_setting', 'question_id', - existing_type=sa.String(250), - type_=sa.Text()) - op.alter_column('report_setting', 'question_key', - existing_type=sa.String(250), - type_=sa.Text()) - op.alter_column('report_setting', 'question_type', - existing_type=sa.String(250), - type_=sa.Text()) - op.alter_column('report_setting', 'question', - existing_type=sa.String(250), - type_=sa.Text()) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('report_setting', 'question_id', - type_=sa.String(250)) - op.alter_column('report_setting', 'question_key', - type_=sa.String(250)) - op.alter_column('report_setting', 'question_type', - type_=sa.String(250)) - op.alter_column('report_setting', 'question', - type_=sa.String(250)) - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/2aa7554dde59_contact_adress_size.py b/met-api/migrations/versions/2aa7554dde59_contact_adress_size.py deleted file mode 100644 index fbd7ff63f..000000000 --- a/met-api/migrations/versions/2aa7554dde59_contact_adress_size.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Increase text size for contact address - -Revision ID: 2aa7554dde59 -Revises: 6ce7831704cb -Create Date: 2022-10-24 08:22:19.064120 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '2aa7554dde59' -down_revision = '6ce7831704cb' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('contact', 'address', - existing_type=sa.VARCHAR(length=50), - type_=sa.String(length=150), - existing_nullable=True) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('contact', 'address', - existing_type=sa.String(length=150), - type_=sa.VARCHAR(length=50), - existing_nullable=True) - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/2b12a6cd987a_add_phases_widget_type.py b/met-api/migrations/versions/2b12a6cd987a_add_phases_widget_type.py deleted file mode 100644 index b84fb46b7..000000000 --- a/met-api/migrations/versions/2b12a6cd987a_add_phases_widget_type.py +++ /dev/null @@ -1,33 +0,0 @@ -"""add phases widget type - -Revision ID: 2b12a6cd987a -Revises: 642925969c53 -Create Date: 2022-11-23 15:34:53.240556 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '2b12a6cd987a' -down_revision = '642925969c53' -branch_labels = None -depends_on = None - - -def upgrade(): - widget_type_table = sa.table('widget_type', - sa.Column('id', sa.Integer), - sa.Column('name', sa.String), - sa.Column('description', sa.String)) - - op.bulk_insert(widget_type_table, [ - {'id': 3, 'name': 'Phases', 'description': 'Displays information about the engagement phase'} - ]) - - -def downgrade(): - conn = op.get_bind() - - conn.execute('DELETE FROM widget_type WHERE id=3') \ No newline at end of file diff --git a/met-api/migrations/versions/2b75eb893e6b_tenant_id_in_contact.py b/met-api/migrations/versions/2b75eb893e6b_tenant_id_in_contact.py deleted file mode 100644 index a16dddc6c..000000000 --- a/met-api/migrations/versions/2b75eb893e6b_tenant_id_in_contact.py +++ /dev/null @@ -1,30 +0,0 @@ -"""tenant id in contact - -Revision ID: 2b75eb893e6b -Revises: f6f480b5b664 -Create Date: 2023-05-07 21:24:21.296063 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '2b75eb893e6b' -down_revision = 'f6f480b5b664' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('contact', sa.Column('tenant_id', sa.Integer(), nullable=True)) - op.create_foreign_key('contact_tenant_fk', 'contact', 'tenant', ['tenant_id'], ['id']) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('contact_tenant_fk', 'contact', type_='foreignkey') - op.drop_column('contact', 'tenant_id') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/31041fb90d53_membership_versioning.py b/met-api/migrations/versions/31041fb90d53_membership_versioning.py deleted file mode 100644 index c2e206ec8..000000000 --- a/met-api/migrations/versions/31041fb90d53_membership_versioning.py +++ /dev/null @@ -1,37 +0,0 @@ -""" add versioning to membership table - -Revision ID: 31041fb90d53 -Revises: e2d5d38220d9 -Create Date: 2023-08-09 14:18:45.335397 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = '31041fb90d53' -down_revision = 'e2d5d38220d9' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('membership', sa.Column('version', sa.Integer(), nullable=True)) - op.add_column('membership', sa.Column('is_latest', sa.Boolean(), nullable=True)) - - # Update existing rows with default values - op.execute("UPDATE membership SET version = 1") - op.execute("UPDATE membership SET is_latest = TRUE") - - # Change columns to non-nullable - op.alter_column('membership', 'version', nullable=False) - op.alter_column('membership', 'is_latest', nullable=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('membership', 'is_latest') - op.drop_column('membership', 'version') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/326419c08f59_.py b/met-api/migrations/versions/326419c08f59_.py deleted file mode 100644 index 64ba7840c..000000000 --- a/met-api/migrations/versions/326419c08f59_.py +++ /dev/null @@ -1,34 +0,0 @@ -"""empty message - -Revision ID: 326419c08f59 -Revises: a2d20b31e275 -Create Date: 2022-05-10 16:04:31.565892 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '326419c08f59' -down_revision = 'a2d20b31e275' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('engagement', sa.Column('user_id', sa.Integer(), nullable=True)) - op.create_foreign_key(None, 'engagement', 'user', ['user_id'], ['id'], ondelete='CASCADE') - op.create_foreign_key(None, 'engagement', 'engagement_status', ['status_id'], ['id'], ondelete='CASCADE') - op.drop_column('engagement', 'created_by') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('engagement', sa.Column('created_by', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) - op.drop_constraint(None, 'engagement', type_='foreignkey') - op.drop_constraint(None, 'engagement', type_='foreignkey') - op.drop_column('engagement', 'user_id') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/36c315ec5801_add_encrypted_email.py b/met-api/migrations/versions/36c315ec5801_add_encrypted_email.py deleted file mode 100644 index ee83c0c57..000000000 --- a/met-api/migrations/versions/36c315ec5801_add_encrypted_email.py +++ /dev/null @@ -1,92 +0,0 @@ -"""add encrypted_email - -Revision ID: 36c315ec5801 -Revises: 587badc69491 -Create Date: 2023-05-30 16:21:19.298002 - -""" -from alembic import op -import sqlalchemy as sa -import sqlalchemy_utils - -# revision identifiers, used by Alembic. -revision = '36c315ec5801' -down_revision = '587badc69491' -branch_labels = None -depends_on = None - - -def upgrade(): - op.drop_constraint('membership_user_id_fkey', 'membership', type_='foreignkey') - op.drop_index('ix_met_users_username', table_name='met_users') - op.drop_constraint('user_external_id_key', 'met_users', type_='unique') - op.drop_constraint('user_status_fk', 'met_users', type_='foreignkey') - - op.create_table('staff_users', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('first_name', sa.String(length=50), nullable=True), - sa.Column('middle_name', sa.String(length=50), nullable=True), - sa.Column('last_name', sa.String(length=50), nullable=True), - sa.Column('username', sa.String(length=100), nullable=True), - sa.Column('email_address', sa.String(length=100), nullable=True), - sa.Column('contact_number', sa.String(length=50), nullable=True), - sa.Column('external_id', sa.String(length=50), nullable=False), - sa.Column('status_id', sa.Integer(), nullable=True), - sa.Column('tenant_id', sa.Integer(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['status_id'], ['user_status.id'], ), - sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('external_id') - ) - op.execute('INSERT INTO staff_users \ - (id, created_date, updated_date, first_name, middle_name, last_name, username, contact_number, \ - external_id, status_id, tenant_id, created_by, updated_by) SELECT id, \ - created_date, updated_date, first_name, middle_name, last_name, username, contact_number,\ - external_id, status_id, tenant_id, created_by, updated_by FROM met_users WHERE username IS NOT NULL OR id = 1;') - op.execute('DELETE FROM met_users WHERE id = 1;') - op.execute('DELETE FROM met_users WHERE username is not null;') - op.execute('SELECT setval(\'staff_users_id_seq\', (SELECT MAX(id) + 1 FROM staff_users), true);') - op.create_index(op.f('ix_staff_users_username'), 'staff_users', ['username'], unique=True) - op.create_foreign_key('membership_user_id_fkey', 'membership', 'staff_users', ['user_id'], ['id']) - - op.drop_column('met_users', 'last_name') - op.drop_column('met_users', 'access_type') - op.drop_column('met_users', 'username') - op.drop_column('met_users', 'middle_name') - op.drop_column('met_users', 'first_name') - op.drop_column('met_users', 'contact_number') - op.drop_column('met_users', 'status_id') - op.drop_column('met_users', 'external_id') - op.drop_column('met_users', 'email_id') - op.add_column('met_users', sa.Column('email_address', sa.VARCHAR(length=500), nullable=True)) - - -def downgrade(): - op.drop_column('met_users', 'email_address') - op.add_column('met_users', sa.Column('email_id', sa.VARCHAR(length=200), autoincrement=False, nullable=True)) - op.add_column('met_users', sa.Column('external_id', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) - op.add_column('met_users', sa.Column('status_id', sa.INTEGER(), autoincrement=False, nullable=True)) - op.add_column('met_users', sa.Column('contact_number', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) - op.add_column('met_users', sa.Column('first_name', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) - op.add_column('met_users', sa.Column('middle_name', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) - op.add_column('met_users', sa.Column('username', sa.VARCHAR(length=100), autoincrement=False, nullable=True)) - op.add_column('met_users', sa.Column('access_type', sa.VARCHAR(length=200), autoincrement=False, nullable=True)) - op.add_column('met_users', sa.Column('last_name', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) - - op.execute('INSERT INTO met_users \ - (id, created_date, updated_date, first_name, middle_name, last_name, username, contact_number, \ - external_id, status_id, tenant_id, created_by, updated_by) SELECT id, \ - created_date, updated_date, first_name, middle_name, last_name, username, contact_number,\ - external_id, status_id, tenant_id, created_by, updated_by FROM staff_users;') - - op.create_foreign_key('user_status_fk', 'met_users', 'user_status', ['status_id'], ['id']) - op.create_unique_constraint('user_external_id_key', 'met_users', ['external_id']) - op.create_index('ix_met_users_username', 'met_users', ['username'], unique=False) - op.drop_constraint('membership_user_id_fkey', 'membership', type_='foreignkey') - op.create_foreign_key('membership_user_id_fkey', 'membership', 'met_users', ['user_id'], ['id']) - op.drop_index(op.f('ix_staff_users_username'), table_name='staff_users') - op.drop_table('staff_users') diff --git a/met-api/migrations/versions/37176ea4708d_.py b/met-api/migrations/versions/37176ea4708d_.py deleted file mode 100644 index 3ae7a8545..000000000 --- a/met-api/migrations/versions/37176ea4708d_.py +++ /dev/null @@ -1,91 +0,0 @@ -"""empty message - -Revision ID: 37176ea4708d -Revises: ec0128056a33 -Create Date: 2024-02-08 12:40:09.456210 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '37176ea4708d' -down_revision = 'ec0128056a33' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('email_verification', 'type', - existing_type=postgresql.ENUM('Survey', 'RejectedComment', 'Subscribe', name='emailverificationtype'), - nullable=False) - op.create_index(op.f('ix_engagement_metadata_engagement_id'), 'engagement_metadata', ['engagement_id'], unique=False) - op.create_index(op.f('ix_engagement_metadata_taxon_id'), 'engagement_metadata', ['taxon_id'], unique=False) - op.create_index(op.f('ix_engagement_metadata_value'), 'engagement_metadata', ['value'], unique=False) - op.create_index(op.f('ix_engagement_metadata_taxa_tenant_id'), 'engagement_metadata_taxa', ['tenant_id'], unique=False) - op.create_unique_constraint(None, 'engagement_metadata_taxa', ['id']) - op.execute('UPDATE membership_status_codes SET created_date = CURRENT_TIMESTAMP WHERE created_date IS NULL;') - op.alter_column('membership_status_codes', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.drop_index('ix_participant_email_address', table_name='participant') - op.alter_column('timeline_event', 'widget_id', - existing_type=sa.INTEGER(), - nullable=False) - op.alter_column('timeline_event', 'status', - existing_type=postgresql.ENUM('Pending', 'InProgress', 'Completed', name='timelineeventstatus'), - nullable=False) - op.alter_column('timeline_event', 'position', - existing_type=sa.INTEGER(), - nullable=False) - op.alter_column('widget_documents', 'is_uploaded', - existing_type=sa.BOOLEAN(), - nullable=True, - existing_server_default=sa.text('false')) - op.alter_column('widget_timeline', 'widget_id', - existing_type=sa.INTEGER(), - nullable=False) - op.execute('UPDATE widget_type SET created_date = CURRENT_TIMESTAMP WHERE created_date IS NULL;') - op.alter_column('widget_type', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('widget_type', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.alter_column('widget_timeline', 'widget_id', - existing_type=sa.INTEGER(), - nullable=True) - op.alter_column('widget_documents', 'is_uploaded', - existing_type=sa.BOOLEAN(), - nullable=False, - existing_server_default=sa.text('false')) - op.alter_column('timeline_event', 'position', - existing_type=sa.INTEGER(), - nullable=True) - op.alter_column('timeline_event', 'status', - existing_type=postgresql.ENUM('Pending', 'InProgress', 'Completed', name='timelineeventstatus'), - nullable=True) - op.alter_column('timeline_event', 'widget_id', - existing_type=sa.INTEGER(), - nullable=True) - op.create_index('ix_participant_email_address', 'participant', ['email_address'], unique=False) - - op.alter_column('membership_status_codes', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - op.drop_constraint(None, 'engagement_metadata_taxa', type_='unique') - op.drop_index(op.f('ix_engagement_metadata_taxa_tenant_id'), table_name='engagement_metadata_taxa') - op.drop_index(op.f('ix_engagement_metadata_value'), table_name='engagement_metadata') - op.drop_index(op.f('ix_engagement_metadata_taxon_id'), table_name='engagement_metadata') - op.drop_index(op.f('ix_engagement_metadata_engagement_id'), table_name='engagement_metadata') - op.alter_column('email_verification', 'type', - existing_type=postgresql.ENUM('Survey', 'RejectedComment', 'Subscribe', name='emailverificationtype'), - nullable=True) - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/37176ea4708d_data_until_feb_09_2024.py b/met-api/migrations/versions/37176ea4708d_data_until_feb_09_2024.py new file mode 100644 index 000000000..e4385acd8 --- /dev/null +++ b/met-api/migrations/versions/37176ea4708d_data_until_feb_09_2024.py @@ -0,0 +1,536 @@ +"""Data until Feb 09 2024 + +Revision ID: 37176ea4708d +Revises: ec0128056a33 +Create Date: 2024-02-08 12:40:09.456210 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.sql import table, column +from sqlalchemy import String, Integer, DateTime, Boolean, Text +from datetime import datetime +from flask import current_app + +# revision identifiers, used by Alembic. +revision = '37176ea4708d' +down_revision = 'ec0128056a33' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + + # Set tenant id as 1 + tenant_id = 1 # ID of the default Tenant + + # Create an ad-hoc table for 'tenant' + tenant_table = table( + 'tenant', + column('id', Integer), + column('created_date', DateTime), + column('updated_date', DateTime), + column('short_name', String(10)), + column('name', String(50)), + column('description', String(300)), + column('title', String(30)), + column('logo_url', String(300)), + column('created_by', String(50)), + column('updated_by', String(50)), + ) + + # Assume current_app.config is available and properly configured + tenant_data = [ + { + 'title': 'Modern Engagement', + 'short_name': current_app.config.get('DEFAULT_TENANT_SHORT_NAME'), + 'name': current_app.config.get('DEFAULT_TENANT_NAME'), + 'description': current_app.config.get( + 'DEFAULT_TENANT_DESCRIPTION' + ), + 'created_date': datetime.utcnow(), + } + ] + + # Perform bulk insert + op.bulk_insert(tenant_table, tenant_data) + + # Create an ad-hoc table for 'user_status' + user_status_table = table( + 'user_status', + column('id', Integer), + column('created_date', DateTime), + column('updated_date', DateTime), + column('status_name', String(50)), + column('description', String(50)), + column('created_by', String(50)), + column('updated_by', String(50)), + ) + + # Data for bulk insert + user_status_data = [ + { + 'id': 1, + 'status_name': 'ACTIVE', + 'description': 'Active User', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 2, + 'status_name': 'INACTIVE', + 'description': 'Inactive User', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + ] + + # Perform bulk insert + op.bulk_insert(user_status_table, user_status_data) + + # Create an ad-hoc table for 'staff_users' + staff_users_table = table( + 'staff_users', + column('id', Integer), + column('created_date', DateTime), + column('updated_date', DateTime), + column('first_name', String(50)), + column('middle_name', String(50)), + column('last_name', String(50)), + column('username', String(100)), + column('email_address', String(100)), + column('contact_number', String(50)), + column('external_id', String(50)), + column('status_id', Integer), + column('tenant_id', Integer), + column('created_by', String(50)), + column('updated_by', String(50)) + ) + + # Sample data for insertion + sample_data = { + 'first_name': 'MET', + 'middle_name': '', + 'last_name': 'System', + 'external_id': '1', # Replace with actual external_id value + 'status_id': 1, + 'contact_number': '1', + 'tenant_id': tenant_id, + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + } + + # Perform insert with sample data + op.bulk_insert(staff_users_table, [sample_data]) + + # Create an ad-hoc table for 'widget_type' + widget_type_table = table( + 'widget_type', + column('id', Integer), + column('name', String), + column('description', String), + column('created_date', DateTime), + column('updated_date', DateTime), + column('created_by', String), + column('updated_by', String), + ) + + # Prepare data for bulk insert + widget_data = [ + { + 'id': 1, + 'name': 'Who is Listening', + 'description': 'Displays contact information for someone who is monitoring the engagement', + }, + { + 'id': 3, + 'name': 'Phases', + 'description': 'Displays information about the engagement phase', + }, + { + 'id': 5, + 'name': 'Events', + 'description': 'Displays event details on the engagement', + }, + { + 'id': 2, + 'name': 'Documents', + 'description': 'Displays important documents on the engagement', + }, + { + 'id': 4, + 'name': 'Subscribe', + 'description': 'Allows users to subscribe to an engagement', + }, + { + 'id': 6, + 'name': 'Map', + 'description': 'Display a map that shows the location of the project', + }, + { + 'id': 7, + 'name': 'Video', + 'description': 'Add a link to a hosted video and link preview', + }, + { + 'id': 8, + 'name': 'CAC Form', + 'description': 'Add a CAC Form to your project', + }, + { + 'id': 9, + 'name': 'Timeline', + 'description': 'Create a timeline for a series of events', + }, + { + 'id': 10, + 'name': 'Poll', + 'description': 'The Poll Widget enables real-time polling and feedback collection from public.', + }, + ] + + for widget in widget_data: + widget['created_date'] = datetime.utcnow() + widget['updated_date'] = datetime.utcnow() + + # Perform bulk insert in a single operation + op.bulk_insert(widget_type_table, widget_data) + + # Create an ad-hoc table for 'engagement_metadata_taxa' + engagement_metadata_taxa_table = table( + 'engagement_metadata_taxa', + column('id', Integer), + column('tenant_id', Integer), + column('name', String(64)), + column('description', String(256)), + column('freeform', Boolean), + column('data_type', String(64)), + column('default_value', Text), + column('one_per_engagement', Boolean), + column('position', Integer), + column('created_date', DateTime), + column('updated_date', DateTime), + column('created_by', String(50)), + column('updated_by', String(50)), + ) + + + + # Data to be inserted + taxa_data = [ + { + 'position': 0, + 'tenant_id': tenant_id, + 'name': 'keywords', + 'description': 'Keywords for categorizing the engagement', + 'freeform': True, + 'one_per_engagement': False, + 'data_type': 'text', + }, + { + 'position': 1, + 'tenant_id': tenant_id, + 'name': 'description', + 'description': 'Description of the engagement', + 'freeform': True, + 'data_type': 'long_text', + 'one_per_engagement': True, + }, + { + 'position': 2, + 'tenant_id': tenant_id, + 'name': 'jira_ticket_url', + 'description': 'URL of the Jira ticket for this engagement', + 'freeform': True, + 'data_type': 'text', + 'one_per_engagement': True, + }, + { + 'position': 3, + 'tenant_id': tenant_id, + 'name': 'pmo_project_number', + 'description': 'PMO project number', + 'freeform': True, + 'data_type': 'text', + 'one_per_engagement': True, + }, + { + 'position': 4, + 'tenant_id': tenant_id, + 'name': 'engagement_category', + 'description': 'Category of the engagement', + 'data_type': 'text', + 'freeform': False, + 'one_per_engagement': False, + }, + { + 'position': 5, + 'tenant_id': tenant_id, + 'name': 'engagement_method', + 'description': 'Method of engagement', + 'data_type': 'text', + 'default_value': "Survey", + 'freeform': False, + 'one_per_engagement': False, + }, + { + 'position': 6, + 'tenant_id': tenant_id, + 'name': 'language', + 'description': 'Language of the engagement', + 'data_type': 'text', + 'default_value': "English", + 'freeform': False, + 'one_per_engagement': False, + }, + { + 'position': 7, + 'tenant_id': tenant_id, + 'name': 'ministry', + 'description': 'Ministry of the engagement', + 'freeform': False, + 'data_type': 'text', + 'one_per_engagement': True, + }, + ] + + for taxa in taxa_data: + taxa['created_date'] = datetime.utcnow() + taxa['updated_date'] = datetime.utcnow() + + # Perform bulk insert + op.bulk_insert(engagement_metadata_taxa_table, taxa_data) + + # Create an ad-hoc table for 'generated_document_type' + generated_document_type_table = table( + 'generated_document_type', + column('id', Integer), + column('created_date', DateTime), + column('updated_date', DateTime), + column('name', String(30)), + column('description', String(100)), + column('created_by', String(50)), + column('updated_by', String(50)), + ) + + # Data for bulk insert + document_type_data = [ + { + 'id': 1, + 'name': 'comment_sheet', + 'description': 'Comments export for staff', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 2, + 'name': 'cac_form_sheet', + 'description': 'cac form submission export for staff', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 3, + 'name': 'proponent_comments_sheet', + 'description': 'Comments export for proponent', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + ] + + # Perform bulk insert + op.bulk_insert(generated_document_type_table, document_type_data) + + # Create an ad-hoc table for 'generated_document_template' + generated_document_template_table = table( + 'generated_document_template', + column('id', Integer), + column('type_id', Integer), + column('hash_code', String(64)), + column('extension', String(10)), + column('created_date', DateTime), + column('updated_date', DateTime), + column('created_by', String(50)), + column('updated_by', String(50)), + ) + + # Data for bulk insert + document_template_data = [ + { + 'id': 1, + 'type_id': 1, + 'hash_code': None, + 'extension': 'xlsx', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 2, + 'type_id': 2, + 'hash_code': None, + 'extension': 'xlsx', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 3, + 'type_id': 3, + 'hash_code': None, + 'extension': 'xlsx', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + ] + + # Perform bulk insert + op.bulk_insert(generated_document_template_table, document_template_data) + + # Create an ad-hoc table for 'engagement_status' + engagement_status_table = table( + 'engagement_status', + column('id', Integer), + column('created_date', DateTime), + column('updated_date', DateTime), + column('status_name', String(50)), + column('description', String(50)), + column('created_by', String(50)), + column('updated_by', String(50)), + ) + + # Data for bulk insert + engagement_status_data = [ + { + 'id': 1, + 'status_name': 'Draft', + 'description': 'Not ready to the public', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 2, + 'status_name': 'Published', + 'description': 'Visible to the public', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 3, + 'status_name': 'Closed', + 'description': 'The engagement period is over', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 4, + 'status_name': 'Scheduled', + 'description': 'Scheduled to be published', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 5, + 'status_name': 'Unpublished', + 'description': 'Unpublished and hidden', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + ] + + # Perform bulk insert + op.bulk_insert(engagement_status_table, engagement_status_data) + + # Create an ad-hoc table for 'comment_status' + comment_status_table = table( + 'comment_status', + column('id', Integer), + column('created_date', DateTime), + column('updated_date', DateTime), + column('status_name', String(50)), + column('description', String(50)), + column('created_by', String(50)), + column('updated_by', String(50)), + ) + + # Data for the initial bulk insert + initial_comment_status_data = [ + { + 'id': 1, + 'status_name': 'Pending', + 'description': 'Comment is pending review', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 2, + 'status_name': 'Approved', + 'description': 'Comment is accepted for public view', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 3, + 'status_name': 'Rejected', + 'description': 'Comment is rejected and not shown', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 4, + 'status_name': 'Needs further review', + 'description': 'Comment needs further review', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + ] + + # Perform the initial bulk insert + op.bulk_insert(comment_status_table, initial_comment_status_data) + + # Create an ad-hoc table for 'membership_status_codes' + membership_status_codes_table = table( + 'membership_status_codes', + column('id', Integer), + column('created_date', DateTime), + column('updated_date', DateTime), + column('status_name', String(50)), + column('description', String(50)), + column('created_by', String(50)), + column('updated_by', String(50)), + ) + + # Data for bulk insert + membership_status_codes_data = [ + { + 'id': 1, + 'status_name': 'ACTIVE', + 'description': 'Active Membership', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 2, + 'status_name': 'INACTIVE', + 'description': 'Inactive Membership', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + { + 'id': 3, + 'status_name': 'REVOKED', + 'description': 'Revoked Membership', + 'created_date': datetime.utcnow(), + 'updated_date': datetime.utcnow(), + }, + ] + + # Perform bulk insert + op.bulk_insert(membership_status_codes_table, membership_status_codes_data) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + pass + # ### end Alembic commands ### \ No newline at end of file diff --git a/met-api/migrations/versions/3a88de1e3e7f_add_rich_description_to_subscribe_item.py b/met-api/migrations/versions/3a88de1e3e7f_add_rich_description_to_subscribe_item.py deleted file mode 100644 index c712af2be..000000000 --- a/met-api/migrations/versions/3a88de1e3e7f_add_rich_description_to_subscribe_item.py +++ /dev/null @@ -1,37 +0,0 @@ -""" Add rich description to subscribe_item table - -Revision ID: 3a88de1e3e7f -Revises: 155c64768a99 -Create Date: 2023-09-08 09:34:06.274642 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = '3a88de1e3e7f' -down_revision = '155c64768a99' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('subscribe_item', sa.Column('rich_description', sa.Text(), nullable=True)) - op.execute('UPDATE subscribe_item SET rich_description = description') - op.execute('UPDATE subscribe_item SET description = NULL') - op.alter_column('subscribe_item', 'call_to_action_type', - existing_type=sa.VARCHAR(length=25), - nullable=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - - op.alter_column('subscribe_item', 'call_to_action_type', - existing_type=sa.VARCHAR(length=25), - nullable=True) - op.drop_column('subscribe_item', 'rich_description') - - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/3e4dc76a96ab_added_the_timeline_widget.py b/met-api/migrations/versions/3e4dc76a96ab_added_the_timeline_widget.py deleted file mode 100644 index e2619da49..000000000 --- a/met-api/migrations/versions/3e4dc76a96ab_added_the_timeline_widget.py +++ /dev/null @@ -1,44 +0,0 @@ -"""Added the Timeline Widget. - -Revision ID: 3e4dc76a96ab -Revises: 02ff8ecc6b91 -Create Date: 2023-12-05 17:04:46.304368 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql -from met_api.constants.timeline_event_status import TimelineEventStatus - -# revision identifiers, used by Alembic. -revision = '3e4dc76a96ab' -down_revision = '02ff8ecc6b91' -branch_labels = None -depends_on = None - - -def upgrade(): - op.create_table('widget_timeline', - sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True, nullable=False), - sa.Column('engagement_id', sa.Integer(), nullable=False), - sa.Column('title', sa.String(length=255), nullable=True), - sa.Column('description', sa.Text(), nullable=True), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id'), - ) - op.create_table('timeline_event', - sa.Column('id', sa.Integer(), primary_key=True, autoincrement=True, nullable=False), - sa.Column('engagement_id', sa.Integer(), nullable=False), - sa.Column('timeline_id', sa.Integer(), nullable=False), - sa.Column('status', sa.Enum(TimelineEventStatus), nullable=True), - sa.Column('position', sa.Integer(), nullable=True), - sa.Column('description', sa.Text(), nullable=True), - sa.Column('time', sa.String(length=255), nullable=True), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['timeline_id'], ['widget_timeline.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id'), - ) - -def downgrade(): - op.drop_table('widget_timeline') - op.drop_table('timeline_event') diff --git a/met-api/migrations/versions/3f11e9145a08_events_table.py b/met-api/migrations/versions/3f11e9145a08_events_table.py deleted file mode 100644 index 258eebefe..000000000 --- a/met-api/migrations/versions/3f11e9145a08_events_table.py +++ /dev/null @@ -1,78 +0,0 @@ -"""events_table - -Revision ID: 3f11e9145a08 -Revises: 2253a00e73bf -Create Date: 2023-02-12 16:48:14.120190 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = '3f11e9145a08' -down_revision = '2253a00e73bf' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('widget_events', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('title', sa.String(length=50), nullable=True), - sa.Column('type', sa.Enum('OPENHOUSE', 'MEETUP', 'VIRTUAL', name='eventtypes'), nullable=False), - sa.Column('sort_index', sa.Integer(), nullable=True), - sa.Column('widget_id', sa.Integer(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('event_item', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('description', sa.String(length=500), nullable=True), - sa.Column('location_name', sa.String(length=50), nullable=True), - sa.Column('location_address', sa.String(length=100), nullable=True, comment='The address of the location'), - sa.Column('start_date', sa.DateTime(), nullable=True), - sa.Column('end_date', sa.DateTime(), nullable=True), - sa.Column('url', sa.String(length=500), nullable=True), - sa.Column('url_label', sa.String(length=100), nullable=True, comment='Label to show for href links'), - sa.Column('sort_index', sa.Integer(), nullable=True), - sa.Column('widget_events_id', sa.Integer(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['widget_events_id'], ['widget_events.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - - op.add_column('widget', sa.Column('title', sa.String(length=100), nullable=True, comment='Custom title for the widget.')) - # ### end Alembic commands ### - - widget_type_table = sa.table('widget_type', - sa.Column('id', sa.Integer), - sa.Column('name', sa.String), - sa.Column('description', sa.String)) - conn = op.get_bind() - res = conn.execute( - f"select max(id) from widget_type;") - latest_id = res.fetchall()[0][0] - - op.bulk_insert(widget_type_table, [ - {'id':latest_id+1 ,'name': 'Events', 'description': 'Displays event details on the engagement'} - ]) - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - - op.drop_column('widget', 'title') - - op.drop_table('event_item') - op.drop_table('widget_events') - op.execute("delete from widget_type where name='Events'") - op.execute('DROP TYPE eventtypes;') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/4114001e1a4c_add_widget_id_to_widget_timeline_and_.py b/met-api/migrations/versions/4114001e1a4c_add_widget_id_to_widget_timeline_and_.py deleted file mode 100644 index a34d93048..000000000 --- a/met-api/migrations/versions/4114001e1a4c_add_widget_id_to_widget_timeline_and_.py +++ /dev/null @@ -1,27 +0,0 @@ -"""Add widget_id to widget_timeline and timeline_event tables - -Revision ID: 4114001e1a4c -Revises: c09e77fde608 -Create Date: 2023-12-11 15:46:30.773046 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '4114001e1a4c' -down_revision = 'c09e77fde608' -branch_labels = None -depends_on = None - - -def upgrade(): - op.add_column('widget_timeline', sa.Column('widget_id', sa.Integer())) - op.create_foreign_key('timeline_widget_fk', 'widget_timeline', 'widget', ['widget_id'], ['id'], ondelete='CASCADE') - op.add_column('timeline_event', sa.Column('widget_id', sa.Integer())) - op.create_foreign_key('event_widget_fk', 'timeline_event', 'widget', ['widget_id'], ['id'], ondelete='CASCADE') - -def downgrade(): - op.drop_column('widget_timeline', 'widget_id') - op.drop_column('timeline_event', 'widget_id') diff --git a/met-api/migrations/versions/45f89f245e3d_engagement_metadata.py b/met-api/migrations/versions/45f89f245e3d_engagement_metadata.py deleted file mode 100644 index a9e71b9f0..000000000 --- a/met-api/migrations/versions/45f89f245e3d_engagement_metadata.py +++ /dev/null @@ -1,37 +0,0 @@ -"""engagement metadata - -Revision ID: 45f89f245e3d -Revises: f99eb7f53041 -Create Date: 2023-03-23 12:03:04.558661 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '45f89f245e3d' -down_revision = 'f99eb7f53041' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('engagement_metadata', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('engagement_id', sa.Integer(), nullable=False), - sa.Column('project_metadata', postgresql.JSONB(astext_type=sa.Text()), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('engagement_id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('engagement_metadata') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/46490dc02be5_added_new_columns_to_user_table.py b/met-api/migrations/versions/46490dc02be5_added_new_columns_to_user_table.py deleted file mode 100644 index b335677a3..000000000 --- a/met-api/migrations/versions/46490dc02be5_added_new_columns_to_user_table.py +++ /dev/null @@ -1,75 +0,0 @@ -"""added new columns to user table - -Revision ID: 46490dc02be5 -Revises: 2b12a6cd987a -Create Date: 2022-12-07 05:38:57.574536 - -""" -from datetime import datetime - -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = '46490dc02be5' -down_revision = '2b12a6cd987a' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - - rename_table_query = 'ALTER TABLE \"user\" rename to met_users' - op.execute(rename_table_query) - - op.create_table('user_status', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('status_name', sa.String(length=50), nullable=True), - sa.Column('description', sa.String(length=50), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('modified_by_id', sa.String(length=50), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - - user_status = sa.table('user_status', - sa.column('id', sa.Integer), - sa.column('status_name', sa.String), - sa.column('description', sa.String), - sa.column('created_date', sa.DateTime), - sa.column('updated_date', sa.DateTime)) - - op.bulk_insert(user_status, [ - {'id': 1, 'status_name': 'ACTIVE', 'description': 'Active User', 'created_date': datetime.utcnow(), - 'updated_date': datetime.utcnow()}, - {'id': 2, 'status_name': 'INACTIVE', 'description': 'Inactive User', 'created_date': datetime.utcnow(), - 'updated_date': datetime.utcnow()} - ]) - - op.add_column('met_users', sa.Column('username', sa.String(length=100), nullable=True)) - op.add_column('met_users', sa.Column('access_type', sa.String(length=200), nullable=True)) - op.add_column('met_users', sa.Column('status_id', sa.Integer(), nullable=True)) - op.create_index(op.f('ix_user_username'), 'met_users', ['username'], unique=False) - op.create_foreign_key('user_status_fk', 'met_users', 'user_status', ['status_id'], ['id']) - - # update everyone to active - update_all_users_to_active = 'UPDATE met_users SET status_id = 1' - op.execute(update_all_users_to_active) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - update_type_query = 'ALTER TABLE met_users rename to \"user\"' - op.execute(update_type_query) - - op.drop_constraint('user_status_fk', 'user', type_='foreignkey') - op.drop_index(op.f('ix_user_username'), table_name='user') - op.drop_column('user', 'status_id') - op.drop_column('user', 'access_type') - op.drop_column('user', 'username') - op.drop_table('user_status') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/47fc88fe0477_video_widget.py b/met-api/migrations/versions/47fc88fe0477_video_widget.py deleted file mode 100644 index d31bb95f5..000000000 --- a/met-api/migrations/versions/47fc88fe0477_video_widget.py +++ /dev/null @@ -1,52 +0,0 @@ -"""Add video widget - -Revision ID: 47fc88fe0477 -Revises: b3b5c66cea4b -Create Date: 2023-07-11 10:44:35.980432 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = '47fc88fe0477' -down_revision = 'b3b5c66cea4b' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('widget_video', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('widget_id', sa.Integer(), nullable=True), - sa.Column('engagement_id', sa.Integer(), nullable=True), - sa.Column('video_url', sa.String(length=255), nullable=False), - sa.Column('description', sa.Text(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - widget_type_table = sa.table('widget_type', - sa.Column('id', sa.Integer), - sa.Column('name', sa.String), - sa.Column('description', sa.String)) - - op.bulk_insert(widget_type_table, [ - {'id': 7, 'name': 'Video', 'description': 'Add a link to a hosted video and link preview'} - ]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('widget_video') - - conn = op.get_bind() - - conn.execute('DELETE FROM widget_type WHERE id=7') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/4c72047de4d3_add_staff_note_table.py b/met-api/migrations/versions/4c72047de4d3_add_staff_note_table.py deleted file mode 100644 index 1dd0e74d3..000000000 --- a/met-api/migrations/versions/4c72047de4d3_add_staff_note_table.py +++ /dev/null @@ -1,41 +0,0 @@ -"""add_staff_note_table - -Revision ID: 4c72047de4d3 -Revises: 0e043f976e2e -Create Date: 2023-01-10 12:23:47.566091 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '4c72047de4d3' -down_revision = '0e043f976e2e' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('staff_note', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('note', sa.Text(), nullable=True), - sa.Column('note_type', sa.String(length=50), nullable=True), - sa.Column('survey_id', sa.Integer(), nullable=False), - sa.Column('submission_id', sa.Integer(), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['submission_id'], ['submission.id'], ondelete='SET NULL'), - sa.ForeignKeyConstraint(['survey_id'], ['survey.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('staff_note') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/4f5f91937f5c_merge_heads.py b/met-api/migrations/versions/4f5f91937f5c_merge_heads.py deleted file mode 100644 index c5d408452..000000000 --- a/met-api/migrations/versions/4f5f91937f5c_merge_heads.py +++ /dev/null @@ -1,24 +0,0 @@ -"""merge heads - -Revision ID: 4f5f91937f5c -Revises: d9777850eb98, b1196306955f -Create Date: 2023-09-19 07:33:05.815625 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '4f5f91937f5c' -down_revision = ('d9777850eb98', 'b1196306955f') -branch_labels = None -depends_on = None - - -def upgrade(): - pass - - -def downgrade(): - pass diff --git a/met-api/migrations/versions/5110026db916_create_feedback_table.py b/met-api/migrations/versions/5110026db916_create_feedback_table.py deleted file mode 100644 index 0f629a47f..000000000 --- a/met-api/migrations/versions/5110026db916_create_feedback_table.py +++ /dev/null @@ -1,31 +0,0 @@ -"""Create feedback table - -Revision ID: 5110026db916 -Revises: ba02399c821c -Create Date: 2022-10-03 12:35:55.742573 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '5110026db916' -down_revision = 'ba02399c821c' -branch_labels = None -depends_on = None - - -def upgrade(): - op.create_table('feedback', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('created_date', sa.DateTime(), nullable=True), - sa.Column('rating', sa.Enum('VerySatisfied', 'Satisfied', 'Neutral', 'Unsatisfied', 'VeryUnsatisfied', name='ratingtype'), nullable=False), - sa.Column('comment_type', sa.Enum('Issue', 'Idea', 'Else', name='commenttype'), nullable=True), - sa.Column('comment', sa.Text(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - - -def downgrade(): - op.drop_table('feedback') diff --git a/met-api/migrations/versions/5423fd515e04_added_shapefile.py b/met-api/migrations/versions/5423fd515e04_added_shapefile.py deleted file mode 100644 index 5c173b8d8..000000000 --- a/met-api/migrations/versions/5423fd515e04_added_shapefile.py +++ /dev/null @@ -1,29 +0,0 @@ -"""added shapefile - -Revision ID: 5423fd515e04 -Revises: db3ffa0dd6ad -Create Date: 2023-03-21 10:32:22.728335 - -""" -import sqlalchemy as sa -from alembic import op -from sqlalchemy.dialects import postgresql - - -# revision identifiers, used by Alembic. -revision = '5423fd515e04' -down_revision = 'db3ffa0dd6ad' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('widget_map', sa.Column('geojson', sa.Text(), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('widget_map', 'geojson') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/587badc69491_email_queue.py b/met-api/migrations/versions/587badc69491_email_queue.py deleted file mode 100644 index f2419e3f6..000000000 --- a/met-api/migrations/versions/587badc69491_email_queue.py +++ /dev/null @@ -1,39 +0,0 @@ -"""email queue - -Revision ID: 587badc69491 -Revises: d2e7baa531ce -Create Date: 2023-06-05 06:17:14.373765 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '587badc69491' -down_revision = 'd2e7baa531ce' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('email_queue', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('entity_id', sa.Integer(), nullable=False), - sa.Column('entity_type', sa.String(length=100), nullable=False), - sa.Column('action', sa.String(length=100), nullable=True), - sa.Column('notification_status', sa.Enum('PROCESSING', 'SENT', name='notificationstatus'), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('email_queue') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/5880bead8f03_email_verification_type.py b/met-api/migrations/versions/5880bead8f03_email_verification_type.py deleted file mode 100644 index a362b3337..000000000 --- a/met-api/migrations/versions/5880bead8f03_email_verification_type.py +++ /dev/null @@ -1,30 +0,0 @@ -"""Email verification type - -Revision ID: 5880bead8f03 -Revises: d86a682d7096 -Create Date: 2023-01-16 14:34:48.541883 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '5880bead8f03' -down_revision = 'd86a682d7096' -branch_labels = None -depends_on = None - - -def upgrade(): - op.execute('CREATE TYPE emailverificationtype AS ENUM (\'Survey\', \'RejectedComment\', \'Subscribe\');') - op.add_column('email_verification', sa.Column('type', sa.Enum('Survey', 'RejectedComment', 'Subscribe', name='emailverificationtype'), nullable=True)) - op.execute('UPDATE email_verification SET type = \'RejectedComment\' WHERE submission_id IS NOT NULL;') - op.execute('UPDATE email_verification SET type = \'Survey\' WHERE type IS NULL;') - op.alter_column('email_verification', sa.Column('type', sa.Enum('Survey', 'RejectedComment', 'Subscribe', name='emailverificationtype'), nullable=False)) - - - -def downgrade(): - op.drop_column('email_verification', 'type') - op.execute('DROP TYPE emailverificationtype;') diff --git a/met-api/migrations/versions/5a1258a76598_add_subscribe_to_project.py b/met-api/migrations/versions/5a1258a76598_add_subscribe_to_project.py deleted file mode 100644 index e97bed547..000000000 --- a/met-api/migrations/versions/5a1258a76598_add_subscribe_to_project.py +++ /dev/null @@ -1,31 +0,0 @@ -"""add_subscribe_to_project - -Revision ID: 5a1258a76598 -Revises: 0329d7d10a5f -Create Date: 2023-07-26 11:54:08.922003 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '5a1258a76598' -down_revision = '0329d7d10a5f' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.execute('CREATE TYPE subscriptiontype AS ENUM (\'ENGAGEMENT\', \'PROJECT\', \'TENANT\');') - op.add_column('subscription', sa.Column('project_id', sa.String(length=50), nullable=True)) - op.add_column('subscription', sa.Column('type', sa.Enum('ENGAGEMENT', 'PROJECT', 'TENANT', name='subscriptiontype'), nullable=True)) - # ### end Alembic commands ### - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('subscription', 'type') - op.drop_column('subscription', 'project_id') - op.execute("""DROP TYPE subscriptiontype""") - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/642925969c53_added_documents_table.py b/met-api/migrations/versions/642925969c53_added_documents_table.py deleted file mode 100644 index 96899edde..000000000 --- a/met-api/migrations/versions/642925969c53_added_documents_table.py +++ /dev/null @@ -1,43 +0,0 @@ -"""added documents table - -Revision ID: 642925969c53 -Revises: e37d79be3a05 -Create Date: 2022-11-22 21:00:39.487971 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '642925969c53' -down_revision = 'e37d79be3a05' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('widget_documents', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('title', sa.String(length=50), nullable=True), - sa.Column('type', sa.String(length=50), nullable=True, comment='File or Folder identifier'), - sa.Column('parent_document_id', sa.Integer(), nullable=True), - sa.Column('url', sa.String(length=2000), nullable=True), - sa.Column('sort_index', sa.Integer(), nullable=True), - sa.Column('widget_id', sa.Integer(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('modified_by_id', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['parent_document_id'], ['widget_documents.id'], ), - sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('widget_documents') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/6764af39864e_.py b/met-api/migrations/versions/6764af39864e_.py deleted file mode 100644 index 93904a7f4..000000000 --- a/met-api/migrations/versions/6764af39864e_.py +++ /dev/null @@ -1,27 +0,0 @@ -""" - -Revision ID: 6764af39864e -Revises: ffac8f5b4288 -Create Date: 2022-12-13 19:47:27.460920 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = '6764af39864e' -down_revision = 'ffac8f5b4288' -branch_labels = None -depends_on = None - - -def upgrade(): - # reset users type - update_reset_access_type_query = f"update met_users set access_type = null where 0=0" - op.execute(update_reset_access_type_query) - # ### end Alembic commands ### - - -def downgrade(): - # no downgrade - print ("no downgrade") diff --git a/met-api/migrations/versions/6ce7831704cb_create_widget_and_contact_tables.py b/met-api/migrations/versions/6ce7831704cb_create_widget_and_contact_tables.py deleted file mode 100644 index 20e513158..000000000 --- a/met-api/migrations/versions/6ce7831704cb_create_widget_and_contact_tables.py +++ /dev/null @@ -1,79 +0,0 @@ -"""Create widget, widget item, widget type and contact tables - -Revision ID: 6ce7831704cb -Revises: ac4a505ed1e3 -Create Date: 2022-10-19 17:20:12.126201 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '6ce7831704cb' -down_revision = 'ac4a505ed1e3' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('contact', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('name', sa.String(length=50), nullable=True), - sa.Column('title', sa.String(length=50), nullable=True), - sa.Column('email', sa.String(length=50), nullable=True), - sa.Column('phone_number', sa.String(length=50), nullable=True), - sa.Column('address', sa.String(length=50), nullable=True), - sa.Column('bio', sa.String(length=500), nullable=True, comment='A biography or short biographical profile of someone.'), - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=False), - sa.Column('updated_by', sa.String(length=50), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - widget_type_table = op.create_table('widget_type', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(length=50), nullable=False), - sa.Column('description', sa.String(length=200), nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('name') - ) - op.create_table('widget', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('widget_type_id', sa.Integer(), nullable=True), - sa.Column('engagement_id', sa.Integer(), nullable=True), - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=False), - sa.Column('updated_by', sa.String(length=50), nullable=False), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['widget_type_id'], ['widget_type.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('widget_type_id', 'engagement_id', name='unique_widget_type') - ) - op.create_table('widget_item', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('widget_data_id', sa.Integer(), nullable=False, comment='A dynamic foreign key that could be to any table where the widget data is hosted.'), - sa.Column('widget_id', sa.Integer(), nullable=True), - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=False), - sa.Column('updated_by', sa.String(length=50), nullable=False), - sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('widget_data_id', 'widget_id', name='unique_widget_data') - ) - op.bulk_insert(widget_type_table, [ - {'id': 1, 'name': 'Who is Listening', 'description': 'Displays contact information for someone who is monitoring the engagement'} - ]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('widget_item') - op.drop_table('widget') - op.drop_table('widget_type') - op.drop_table('contact') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/6d3c33a79c5e_add_email_verification.py b/met-api/migrations/versions/6d3c33a79c5e_add_email_verification.py deleted file mode 100644 index e75146ee6..000000000 --- a/met-api/migrations/versions/6d3c33a79c5e_add_email_verification.py +++ /dev/null @@ -1,41 +0,0 @@ -"""Add email_verification - -Revision ID: 6d3c33a79c5e -Revises: 1113e0ad66c3 -Create Date: 2022-07-28 12:57:25.200851 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '6d3c33a79c5e' -down_revision = '1113e0ad66c3' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('email_verification', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('verification_token', sa.String(length=50), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=True), - sa.Column('survey_id', sa.Integer(), nullable=True), - sa.Column('is_active', sa.Boolean(), nullable=False), - sa.Column('created_date', sa.DateTime(), nullable=True), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['user_id'], ['user.id'], ), - sa.ForeignKeyConstraint(['survey_id'], ['survey.id'], ), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('email_verification') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/779d9125c8cb_add_reviewer_type.py b/met-api/migrations/versions/779d9125c8cb_add_reviewer_type.py deleted file mode 100644 index 106420e3d..000000000 --- a/met-api/migrations/versions/779d9125c8cb_add_reviewer_type.py +++ /dev/null @@ -1,32 +0,0 @@ -"""add_reviewer_type - -Revision ID: 779d9125c8cb -Revises: 8def759e43d9 -Create Date: 2023-06-12 16:26:29.300751 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '779d9125c8cb' -down_revision = '8def759e43d9' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('membership', 'type', type_=sa.Text()) - op.execute("ALTER TYPE membershiptype ADD VALUE IF NOT EXISTS 'REVIEWER'") - op.alter_column('membership', 'type', type_=sa.Enum('TEAM_MEMBER', 'REVIEWER', name='membershiptype'), postgresql_using='type::membershiptype') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('membership', 'type', - existing_type=postgresql.ENUM('TEAM_MEMBER', name='membershiptype'), - nullable=False) - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/7bf7394a517c_feedback_ratingtype.py b/met-api/migrations/versions/7bf7394a517c_feedback_ratingtype.py deleted file mode 100644 index 5062339b4..000000000 --- a/met-api/migrations/versions/7bf7394a517c_feedback_ratingtype.py +++ /dev/null @@ -1,36 +0,0 @@ -"""feedback_ratingtype - -Revision ID: 7bf7394a517c -Revises: 5423fd515e04 -Create Date: 2023-03-24 13:59:02.463795 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '7bf7394a517c' -down_revision = '5423fd515e04' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('feedback', 'rating', type_=sa.Text()) - op.execute('DROP TYPE ratingtype;') - op.execute('CREATE TYPE ratingtype AS ENUM (\'VerySatisfied\', \'Satisfied\', \'Neutral\', \'Unsatisfied\', \'VeryUnsatisfied\', \'NONE\');') - op.alter_column('feedback', 'rating', - type_=sa.Enum('NONE', 'VerySatisfied', 'Satisfied', 'Neutral', 'Unsatisfied', 'VeryUnsatisfied', name='ratingtype'), - postgresql_using='rating::ratingtype', - nullable=True) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('feedback', 'rating', - existing_type=postgresql.ENUM('VerySatisfied', 'Satisfied', 'Neutral', 'Unsatisfied', 'VeryUnsatisfied', name='ratingtype'), - nullable=False) - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/7cb3da03c2a2_.py b/met-api/migrations/versions/7cb3da03c2a2_.py deleted file mode 100644 index 97955bc24..000000000 --- a/met-api/migrations/versions/7cb3da03c2a2_.py +++ /dev/null @@ -1,28 +0,0 @@ -""" - -Revision ID: 7cb3da03c2a2 -Revises: 45f89f245e3d -Create Date: 2023-03-28 09:50:24.225706 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '7cb3da03c2a2' -down_revision = '45f89f245e3d' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('widget_map', sa.Column('file_name', sa.Text(), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('widget_map', 'file_name') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/7d8897c412de_tenant_model.py b/met-api/migrations/versions/7d8897c412de_tenant_model.py deleted file mode 100644 index ec1000e46..000000000 --- a/met-api/migrations/versions/7d8897c412de_tenant_model.py +++ /dev/null @@ -1,78 +0,0 @@ -"""Tenant model - -Revision ID: 7d8897c412de -Revises: 7cb3da03c2a2 -Create Date: 2023-04-03 16:05:38.516851 - -""" -from datetime import datetime - -from alembic import op -import sqlalchemy as sa -from flask import current_app -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '7d8897c412de' -down_revision = '7cb3da03c2a2' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - tenant_table = op.create_table('tenant', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('short_name', sa.String(length=10), nullable=False, comment='A small code for the tenant ie GDX , EAO.'), - sa.Column('name', sa.String(length=50), nullable=True, comment='Full name of the ministry.ie Env Assessment Office'), - sa.Column('description', sa.String(length=100), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - default_id = "1" - op.bulk_insert(tenant_table, [ - { - 'short_name': current_app.config.get('DEFAULT_TENANT_SHORT_NAME') , - 'name': current_app.config.get('DEFAULT_TENANT_NAME'), - 'description': current_app.config.get('DEFAULT_TENANT_DESCRIPTION'), - "created_date": datetime.utcnow()} - ]) - - op.add_column('email_verification', sa.Column('tenant_id', sa.Integer(), nullable=True)) - op.create_foreign_key('email_verification_tenant_fk', 'email_verification', 'tenant', ['tenant_id'], ['id']) - - op.add_column('engagement', sa.Column('tenant_id', sa.Integer(), nullable=True ,server_default = default_id)) - op.create_foreign_key('engagement_tenant_fk', 'engagement', 'tenant', ['tenant_id'], ['id']) - - op.add_column('feedback', sa.Column('tenant_id', sa.Integer(), nullable=True)) - op.create_foreign_key('feedback_tenant_fk', 'feedback', 'tenant', ['tenant_id'], ['id']) - - op.add_column('membership', sa.Column('tenant_id', sa.Integer(), nullable=True)) - op.create_foreign_key('membership_tenant_fk', 'membership', 'tenant', ['tenant_id'], ['id']) - - op.add_column('survey', sa.Column('tenant_id', sa.Integer(), nullable=True)) - op.create_foreign_key('survey_tenant_fk', 'survey', 'tenant', ['tenant_id'], ['id']) - - # ### end Alembic commands ### - - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('tenant') - op.drop_constraint('survey_tenant_fk', 'survey', type_='foreignkey') - op.drop_column('survey', 'tenant_id') - op.drop_constraint('membership_tenant_fk', 'membership', type_='foreignkey') - op.drop_column('membership', 'tenant_id') - op.drop_constraint('feedback_tenant_fk', 'feedback', type_='foreignkey') - op.drop_column('feedback', 'tenant_id') - op.drop_constraint('engagement_tenant_fk', 'engagement', type_='foreignkey') - op.drop_column('engagement', 'tenant_id') - op.drop_constraint('email_verification_tenant_fk', 'email_verification', type_='foreignkey') - - op.drop_table('tenant') - - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/7ebd9ecfccdd_.py b/met-api/migrations/versions/7ebd9ecfccdd_.py deleted file mode 100644 index 1ab60e6e2..000000000 --- a/met-api/migrations/versions/7ebd9ecfccdd_.py +++ /dev/null @@ -1,55 +0,0 @@ -""" Add new document type and template for cac form submission export - -Revision ID: 7ebd9ecfccdd -Revises: 3a88de1e3e7f -Create Date: 2023-09-12 14:58:03.712784 - -""" -from datetime import datetime -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '7ebd9ecfccdd' -down_revision = '3a88de1e3e7f' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - document_type = sa.Table( - 'generated_document_type', - sa.MetaData(), - sa.Column('id', sa.Integer), - sa.Column('name', sa.String), - sa.Column('description', sa.String), - sa.Column('created_date', sa.DateTime, default=datetime.utcnow) - ) - - document_template = sa.Table( - 'generated_document_template', - sa.MetaData(), - sa.Column('id', sa.Integer), - sa.Column('type_id', sa.Integer), - sa.Column('hash_code', sa.String), - sa.Column('extension', sa.String), - sa.Column('created_date', sa.DateTime, default=datetime.utcnow) - ) - - op.bulk_insert(document_type, [ - {'id': 2, 'name': 'cac_form_sheet', 'description': 'cac form submission export for staff'} - ]) - - op.bulk_insert(document_template, [ - {'id': 2, 'type_id': 2, 'hash_code': None, "extension": "xlsx"} - ]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.execute('DELETE FROM document_type WHERE id = 2') - op.execute('DELETE FROM document_template WHERE id = 2') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/7faee53e6759_alter_submission_add_comment_status.py b/met-api/migrations/versions/7faee53e6759_alter_submission_add_comment_status.py deleted file mode 100644 index babfc2d87..000000000 --- a/met-api/migrations/versions/7faee53e6759_alter_submission_add_comment_status.py +++ /dev/null @@ -1,60 +0,0 @@ -"""alter submission add comment_status - -Revision ID: 7faee53e6759 -Revises: 03ee1815f6a6 -Create Date: 2022-11-08 10:31:39.240317 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '7faee53e6759' -down_revision = '03ee1815f6a6' -branch_labels = None -depends_on = None - - -def upgrade(): - conn = op.get_bind() - op.drop_constraint('comment_status_id_fkey', 'comment', type_='foreignkey') - op.add_column('submission', sa.Column('reviewed_by', sa.String(length=50), nullable=True)) - op.add_column('submission', sa.Column('review_date', sa.DateTime(), nullable=True)) - op.add_column('submission', sa.Column('comment_status_id', sa.Integer(), nullable=True)) - op.create_foreign_key('submission_comment_status_id_fkey', 'submission', 'comment_status', ['comment_status_id'], ['id'], ondelete='SET NULL') - - conn.execute('UPDATE submission s \ - SET reviewed_by=c.reviewed_by, \ - review_date=c.review_date,\ - comment_status_id=c.status_id\ - FROM comment c \ - WHERE \ - s.comment_status_id is null AND \ - s.id = c.submission_id') - - op.drop_column('comment', 'reviewed_by') - op.drop_column('comment', 'review_date') - op.drop_column('comment', 'status_id') - - -def downgrade(): - conn = op.get_bind() - op.drop_constraint('submission_comment_status_id_fkey', 'submission', type_='foreignkey') - op.add_column('comment', sa.Column('status_id', sa.Integer(), nullable=True)) - op.add_column('comment', sa.Column('review_date', sa.DateTime(), nullable=True)) - op.add_column('comment', sa.Column('reviewed_by', sa.String(length=50), nullable=True)) - op.create_foreign_key('comment_status_id_fkey', 'comment', 'comment_status', ['status_id'], ['id'], ondelete='SET NULL') - - conn.execute('UPDATE comment c \ - SET reviewed_by=s.reviewed_by, \ - review_date=s.review_date,\ - status_id=s.comment_status_id\ - FROM submission s \ - WHERE \ - c.status_id is null AND \ - c.submission_id = s.id') - - op.drop_column('submission', 'comment_status_id') - op.drop_column('submission', 'review_date') - op.drop_column('submission', 'reviewed_by') diff --git a/met-api/migrations/versions/8595172f9d96_add_map_type.py b/met-api/migrations/versions/8595172f9d96_add_map_type.py deleted file mode 100644 index aed843b49..000000000 --- a/met-api/migrations/versions/8595172f9d96_add_map_type.py +++ /dev/null @@ -1,36 +0,0 @@ -"""Add the map widget - -Revision ID: 8595172f9d96 -Revises: 3f11e9145a08 -Create Date: 2023-03-03 13:42:48.413988 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = '8595172f9d96' -down_revision = '3f11e9145a08' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - widget_type_table = sa.table('widget_type', - sa.Column('id', sa.Integer), - sa.Column('name', sa.String), - sa.Column('description', sa.String)) - - op.bulk_insert(widget_type_table, [ - {'id': 6, 'name': 'Map', 'description': 'Display a map that shows the location of the project'} - ]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - conn = op.get_bind() - - conn.execute('DELETE FROM widget_type WHERE id=6') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/88aba309bc23_add_engagement_slug.py b/met-api/migrations/versions/88aba309bc23_add_engagement_slug.py deleted file mode 100644 index 08028d4de..000000000 --- a/met-api/migrations/versions/88aba309bc23_add_engagement_slug.py +++ /dev/null @@ -1,70 +0,0 @@ -""" Add engagement slug - -Revision ID: 88aba309bc23 -Revises: 779d9125c8cb -Create Date: 2023-06-20 15:35:49.824000 - -""" -from alembic import op -import sqlalchemy as sa -from datetime import datetime -from met_api.services.slug_generation_service import SlugGenerationService - -# revision identifiers, used by Alembic. -revision = '88aba309bc23' -down_revision = '779d9125c8cb' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - engagement_slug_table = op.create_table('engagement_slug', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('engagement_id', sa.Integer(), nullable=False), - sa.Column('slug', sa.String(length=200), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('engagement_id'), - sa.UniqueConstraint('slug') - ) - op.create_index('idx_slug', 'engagement_slug', ['slug'], unique=False) - - # Retrieve engagement names that don't have slugs - connection = op.get_bind() - result = connection.execute(""" - SELECT id, name - FROM engagement - """) - - engagements_without_slugs = result.fetchall() - - # Generate unique slugs for each engagement - slugify = SlugGenerationService.create_custom_unique_slugify() - slug_data = [] - for engagement in engagements_without_slugs: - engagement_id = engagement[0] - engagement_name = engagement[1] - slug = slugify(engagement_name) - slug_data.append({"engagement_id": engagement_id, "slug": slug, "created_date": datetime.utcnow()}) - - # Bulk insert the generated slugs into the engagement_slug table - if slug_data: - op.bulk_insert( - engagement_slug_table, - slug_data - ) - - op.execute("COMMIT") - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index('idx_slug', table_name='engagement_slug') - op.drop_table('engagement_slug') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/8ab640f6e60d_alter_user_table_add_external_id.py b/met-api/migrations/versions/8ab640f6e60d_alter_user_table_add_external_id.py deleted file mode 100644 index f6c6fb2d3..000000000 --- a/met-api/migrations/versions/8ab640f6e60d_alter_user_table_add_external_id.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Alter user table add external_id - -Revision ID: 8ab640f6e60d -Revises: eef9cc71cca7 -Create Date: 2022-06-16 12:32:10.933832 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '8ab640f6e60d' -down_revision = 'eef9cc71cca7' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('user', sa.Column('external_id', sa.String(length=50), nullable=True)) - op.execute('UPDATE "user" SET external_id = id WHERE external_id IS NULL') - op.alter_column('user', 'external_id', nullable=False) - op.create_unique_constraint(None, 'user', ['external_id']) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'user', type_='unique') - op.drop_column('user', 'external_id') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/8ca063aafc01_create_comment_table.py b/met-api/migrations/versions/8ca063aafc01_create_comment_table.py deleted file mode 100644 index f287ec2e4..000000000 --- a/met-api/migrations/versions/8ca063aafc01_create_comment_table.py +++ /dev/null @@ -1,56 +0,0 @@ -"""Create comment table - -Revision ID: 8ca063aafc01 -Revises: 6d3c33a79c5e -Create Date: 2022-07-28 15:13:35.368696 - -""" -from alembic import op -import sqlalchemy as sa -from datetime import datetime - - -# revision identifiers, used by Alembic. -revision = '8ca063aafc01' -down_revision = '6d3c33a79c5e' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - comment_status_table = op.create_table('comment_status', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('status_name', sa.String(length=50), unique= True, nullable=False), - sa.Column('description', sa.String(length=50), nullable=True), - sa.Column('created_date', sa.DateTime(), nullable=True), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('comment', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('text', sa.Text(), nullable=False), - sa.Column('submission_date', sa.DateTime(), nullable=True), - sa.Column('reviewed_by', sa.String(length=50), nullable=True), - sa.Column('review_date', sa.DateTime(), nullable=True), - sa.Column('status_id', sa.Integer(), nullable=True), - sa.Column('survey_id', sa.Integer(), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['status_id'], ['comment_status.id'], ondelete='SET NULL'), - sa.ForeignKeyConstraint(['survey_id'], ['survey.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='SET NULL'), - sa.PrimaryKeyConstraint('id') - ) - op.bulk_insert(comment_status_table, [ - {'id': 1, 'status_name': 'Pending', 'description': 'Comment is pending review', 'created_date': datetime.utcnow(), 'updated_date': datetime.utcnow()}, - {'id': 2, 'status_name': 'Accepted', 'description': 'Comment is accepted for public view', 'created_date': datetime.utcnow(), 'updated_date': datetime.utcnow()}, - {'id': 3, 'status_name': 'Rejected', 'description': 'Comment is rejected and not shown', 'created_date': datetime.utcnow(), 'updated_date': datetime.utcnow()}, - ]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('comment') - op.drop_table('comment_status') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/8def759e43d9_add_participant_table.py b/met-api/migrations/versions/8def759e43d9_add_participant_table.py deleted file mode 100644 index 0edd9a209..000000000 --- a/met-api/migrations/versions/8def759e43d9_add_participant_table.py +++ /dev/null @@ -1,93 +0,0 @@ -"""Add participant table - -Revision ID: 8def759e43d9 -Revises: 36c315ec5801 -Create Date: 2023-06-01 15:48:05.428175 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql -import sqlalchemy_utils - -# revision identifiers, used by Alembic. -revision = '8def759e43d9' -down_revision = '36c315ec5801' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('participant', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.Column('email_address', sa.String(length=500), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - - op.execute('INSERT INTO participant (id, email_address, created_date, updated_date, created_by, updated_by) \ - SELECT id, email_address, created_date, updated_date, created_by, updated_by FROM met_users;') - - op.create_index(op.f('ix_participant_email_address'), 'participant', ['email_address'], unique=False) - op.add_column('comment', sa.Column('participant_id', sa.Integer(), nullable=True)) - op.create_foreign_key('comment_participant_id_fkey', 'comment', 'participant', ['participant_id'], ['id'], ondelete='SET NULL') - op.drop_constraint('comment_user_id_fkey', 'comment', type_='foreignkey') - op.execute('UPDATE comment SET participant_id = user_id') - op.drop_column('comment', 'user_id') - - op.add_column('email_verification', sa.Column('participant_id', sa.Integer(), nullable=True)) - op.create_foreign_key('email_verification_participant_id_fkey', 'email_verification', 'participant', ['participant_id'], ['id']) - op.drop_constraint('email_verification_user_id_fkey', 'email_verification', type_='foreignkey') - op.execute('UPDATE email_verification SET participant_id = user_id') - op.drop_column('email_verification', 'user_id') - - op.add_column('submission', sa.Column('participant_id', sa.Integer(), nullable=True)) - op.drop_constraint('submission_user_id_fkey', 'submission', type_='foreignkey') - op.create_foreign_key('submission_participant_id_fkey', 'submission', 'participant', ['participant_id'], ['id']) - op.execute('UPDATE submission SET participant_id = user_id') - op.drop_column('submission', 'user_id') - - op.add_column('subscription', sa.Column('participant_id', sa.Integer(), nullable=True)) - op.drop_constraint('subscription_user_id_fkey', 'subscription', type_='foreignkey') - op.create_foreign_key('subscription_participant_id_fkey', 'subscription', 'participant', ['participant_id'], ['id']) - op.execute('UPDATE subscription SET participant_id = user_id') - op.drop_column('subscription', 'user_id') - - op.execute('SELECT setval(\'participant_id_seq\', (SELECT MAX(id) + 1 FROM participant), true);') - op.drop_table('met_users') - - -def downgrade(): - op.create_table('met_users', - sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False), - sa.Column('created_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=False), - sa.Column('updated_date', postgresql.TIMESTAMP(), autoincrement=False, nullable=True), - sa.Column('created_by', sa.VARCHAR(length=50), autoincrement=False, nullable=True), - sa.Column('updated_by', sa.VARCHAR(length=50), autoincrement=False, nullable=True), - sa.Column('tenant_id', sa.INTEGER(), autoincrement=False, nullable=True), - sa.Column('email_address', sa.VARCHAR(), autoincrement=False, nullable=True), - sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], name='met_users_tenant_fk'), - sa.PrimaryKeyConstraint('id', name='user_pkey') - ) - - op.execute('INSERT INTO met_users (id, email_address, created_date, updated_date, created_by, updated_by) \ - SELECT id, email_address, created_date, updated_date, created_by, updated_by FROM participant;') - - op.add_column('submission', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True)) - op.drop_constraint('submission_participant_id_fkey', 'submission', type_='foreignkey') - op.create_foreign_key('submission_user_id_fkey', 'submission', 'met_users', ['user_id'], ['id']) - op.drop_column('submission', 'participant_id') - op.add_column('email_verification', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True)) - op.drop_constraint('email_verification_participant_id_fkey', 'email_verification', type_='foreignkey') - op.create_foreign_key('email_verification_user_id_fkey', 'email_verification', 'met_users', ['user_id'], ['id']) - op.drop_column('email_verification', 'participant_id') - op.add_column('comment', sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=True)) - op.drop_constraint('comment_participant_id_fkey', 'comment', type_='foreignkey') - op.create_foreign_key('comment_user_id_fkey', 'comment', 'met_users', ['user_id'], ['id'], ondelete='SET NULL') - op.drop_column('comment', 'participant_id') - op.drop_index(op.f('ix_participant_email_address'), table_name='participant') - op.drop_table('participant') diff --git a/met-api/migrations/versions/904c1ebca3e3_merge_heads.py b/met-api/migrations/versions/904c1ebca3e3_merge_heads.py deleted file mode 100644 index f037d964b..000000000 --- a/met-api/migrations/versions/904c1ebca3e3_merge_heads.py +++ /dev/null @@ -1,24 +0,0 @@ -"""merge heads - -Revision ID: 904c1ebca3e3 -Revises: e69d7ac92afb, fda10461892d -Create Date: 2022-12-22 15:13:49.045237 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '904c1ebca3e3' -down_revision = ('e69d7ac92afb', 'fda10461892d') -branch_labels = None -depends_on = None - - -def upgrade(): - pass - - -def downgrade(): - pass diff --git a/met-api/migrations/versions/9536f547cdd5_.py b/met-api/migrations/versions/9536f547cdd5_.py deleted file mode 100644 index 4208fae8e..000000000 --- a/met-api/migrations/versions/9536f547cdd5_.py +++ /dev/null @@ -1,30 +0,0 @@ -"""empty message - -Revision ID: 9536f547cdd5 -Revises: f2b3f08c8d60 -Create Date: 2022-11-09 09:07:27.443401 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '9536f547cdd5' -down_revision = 'f2b3f08c8d60' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('widget_item', sa.Column('sort_index', sa.Integer(), nullable=True, default=1)) - op.execute('UPDATE widget_item SET sort_index = 1') - op.alter_column('widget_item', 'sort_index', nullable=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('widget_item', 'sort_index') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/9714d7f8d7cc_size_increase.py b/met-api/migrations/versions/9714d7f8d7cc_size_increase.py deleted file mode 100644 index 9b6b977eb..000000000 --- a/met-api/migrations/versions/9714d7f8d7cc_size_increase.py +++ /dev/null @@ -1,30 +0,0 @@ -"""size increase - -Revision ID: 9714d7f8d7cc -Revises: 1c5883959156 -Create Date: 2023-09-06 11:43:37.142580 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = '9714d7f8d7cc' -down_revision = '1c5883959156' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('report_setting', 'question_key', type_=sa.String(length=250)) - op.alter_column('report_setting', 'question_type', type_=sa.String(length=250)) - op.alter_column('report_setting', 'question', type_=sa.String(length=250)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - pass - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/9f86fdcfb248_add_widget_type_document.py b/met-api/migrations/versions/9f86fdcfb248_add_widget_type_document.py deleted file mode 100644 index e7ba153b6..000000000 --- a/met-api/migrations/versions/9f86fdcfb248_add_widget_type_document.py +++ /dev/null @@ -1,33 +0,0 @@ -"""add_widget_type_document - -Revision ID: 9f86fdcfb248 -Revises: 7faee53e6759 -Create Date: 2022-11-16 13:58:32.284108 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = '9f86fdcfb248' -down_revision = '7faee53e6759' -branch_labels = None -depends_on = None - - -def upgrade(): - widget_type_table = sa.table('widget_type', - sa.Column('id', sa.Integer), - sa.Column('name', sa.String), - sa.Column('description', sa.String)) - - op.bulk_insert(widget_type_table, [ - {'id': 2, 'name': 'Documents', 'description': 'Displays important documents on the engagement'} - ]) - - -def downgrade(): - conn = op.get_bind() - - conn.execute('DELETE FROM widget_type WHERE id=2') \ No newline at end of file diff --git a/met-api/migrations/versions/a1237c8a3df9_.py b/met-api/migrations/versions/a1237c8a3df9_.py deleted file mode 100644 index ac044912d..000000000 --- a/met-api/migrations/versions/a1237c8a3df9_.py +++ /dev/null @@ -1,43 +0,0 @@ -""" - -Revision ID: a1237c8a3df9 -Revises: 3f11e9145a08 -Create Date: 2023-03-07 12:19:32.133932 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql -from datetime import datetime - -# revision identifiers, used by Alembic. -revision = 'a1237c8a3df9' -down_revision = '3f11e9145a08' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('widget_map', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('description', sa.String(length=500), nullable=True), - sa.Column('longitude', sa.Float(), nullable=False), - sa.Column('latitude', sa.Float(), nullable=False), - sa.Column('engagement_id', sa.Integer(), nullable=True), - sa.Column('widget_id', sa.Integer(), nullable=True), - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('widget_map') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/a2d20b31e275_.py b/met-api/migrations/versions/a2d20b31e275_.py deleted file mode 100644 index f0dc2d971..000000000 --- a/met-api/migrations/versions/a2d20b31e275_.py +++ /dev/null @@ -1,78 +0,0 @@ -"""empty message - -Revision ID: a2d20b31e275 -Revises: -Create Date: 2022-05-06 11:21:08.457737 - -""" -from alembic import op -import sqlalchemy as sa -from datetime import datetime - -# revision identifiers, used by Alembic. -revision = 'a2d20b31e275' -down_revision = None -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - user_table = op.create_table('user', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('first_name', sa.String(length=50), nullable=True), - sa.Column('middle_name', sa.String(length=50), nullable=True), - sa.Column('last_name', sa.String(length=50), nullable=True), - sa.Column('email_id', sa.String(length=50), nullable=True), - sa.Column('contact_number', sa.String(length=50), nullable=True), - sa.Column('created_date', sa.DateTime(), nullable=True), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - - op.create_table('engagement', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('name', sa.String(length=50), nullable=True), - sa.Column('description', sa.String(), nullable=True), - sa.Column('start_date', sa.DateTime(), nullable=True), - sa.Column('end_date', sa.DateTime(), nullable=True), - sa.Column('status_id', sa.Integer(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('created_date', sa.DateTime(), nullable=True), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('published_date', sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - - engagement_status_table = op.create_table('engagement_status', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('status_name', sa.String(length=50), nullable=True), - sa.Column('description', sa.String(length=50), nullable=True), - sa.Column('created_date', sa.DateTime(), nullable=True), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - - conn = op.get_bind() - - op.bulk_insert(engagement_status_table, [ - {'id': 1, 'status_name': 'draft', 'description': 'Test Description', 'created_date': datetime.utcnow(), 'updated_date': datetime.utcnow()} - ]) - - conn.execute('SELECT setval(\'engagement_status_id_seq\', 1);') - - op.bulk_insert(user_table, [ - {'id': 1, 'first_name': 'A', 'middle_name': 'B', 'last_name': 'C', 'email_id': 1, 'contact_number': 1, 'created_date': datetime.utcnow(), 'updated_date': datetime.utcnow()} - ]) - - conn.execute('SELECT setval(\'user_id_seq\', 1);') - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('engagement_status') - op.drop_table('engagement') - op.drop_table('user') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/ac4a505ed1e3_add_feedback_source.py b/met-api/migrations/versions/ac4a505ed1e3_add_feedback_source.py deleted file mode 100644 index b2a8a2ef5..000000000 --- a/met-api/migrations/versions/ac4a505ed1e3_add_feedback_source.py +++ /dev/null @@ -1,30 +0,0 @@ -"""add feedback source - -Revision ID: ac4a505ed1e3 -Revises: 224b70277ac4 -Create Date: 2022-10-05 13:36:41.944071 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'ac4a505ed1e3' -down_revision = '224b70277ac4' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - source = sa.Enum('Public', 'Internal', name='feedbacksourcetype') - source.create(op.get_bind()) - op.add_column('feedback', sa.Column('source', sa.Enum('Public', 'Internal', name='feedbacksourcetype'), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('feedback', 'source') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/b1196306955f_tracking_id_for_metadata.py b/met-api/migrations/versions/b1196306955f_tracking_id_for_metadata.py deleted file mode 100644 index 6bf2285f1..000000000 --- a/met-api/migrations/versions/b1196306955f_tracking_id_for_metadata.py +++ /dev/null @@ -1,28 +0,0 @@ -"""tracking id for metadata - -Revision ID: b1196306955f -Revises: 7ebd9ecfccdd -Create Date: 2023-09-17 22:11:54.456358 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'b1196306955f' -down_revision = '7ebd9ecfccdd' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('engagement_metadata', sa.Column('project_tracking_id', sa.String(length=100), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('engagement_metadata', 'project_tracking_id') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/b3b5c66cea4b_report_setting.py b/met-api/migrations/versions/b3b5c66cea4b_report_setting.py deleted file mode 100644 index dc58967cc..000000000 --- a/met-api/migrations/versions/b3b5c66cea4b_report_setting.py +++ /dev/null @@ -1,45 +0,0 @@ -"""report_setting - -Revision ID: b3b5c66cea4b -Revises: 88aba309bc23 -Create Date: 2023-06-28 12:05:22.187795 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = 'b3b5c66cea4b' -down_revision = '88aba309bc23' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('report_setting', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('survey_id', sa.Integer(), nullable=False), - sa.Column('question_id', sa.String(length=250), nullable=True), - sa.Column('question_key', sa.String(length=100), nullable=True), - sa.Column('question_type', sa.String(length=100), nullable=True), - sa.Column('question', sa.String(length=200), nullable=True), - sa.Column('display', sa.Boolean(), nullable=True, - comment='Flag to identify if the question needs to be diplayed on the dashboard.'), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['survey_id'], ['survey.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - op.add_column('survey', sa.Column('generate_dashboard', sa.Boolean(), nullable=True)) - op.execute('UPDATE survey SET generate_dashboard = True') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('survey', 'generate_dashboard') - op.drop_table('report_setting') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/ba02399c821c_add_closed_status.py b/met-api/migrations/versions/ba02399c821c_add_closed_status.py deleted file mode 100644 index fd4ba1440..000000000 --- a/met-api/migrations/versions/ba02399c821c_add_closed_status.py +++ /dev/null @@ -1,41 +0,0 @@ -"""update status and user - -Revision ID: ec504565fab3 -Revises: d0f92ae9ba77 -Create Date: 2022-06-29 13:34:24.214735 - -""" -from alembic import op -import sqlalchemy as sa -from datetime import datetime - - -# revision identifiers, used by Alembic. -revision = 'ba02399c821c' -down_revision = 'cb965cb4a3ad' -branch_labels = None -depends_on = None - - -def upgrade(): - conn = op.get_bind() - - engagement_status = sa.table('engagement_status', - sa.column('id', sa.Integer), - sa.column('status_name', sa.String), - sa.column('description', sa.String), - sa.column('created_date', sa.DateTime), - sa.column('updated_date', sa.DateTime)) - - op.bulk_insert(engagement_status, [ - {'id': 3, 'status_name': 'Closed', 'description': 'The engagement period is over', 'created_date': datetime.utcnow(), 'updated_date': datetime.utcnow()} - ]) - - conn.execute('SELECT setval(\'engagement_status_id_seq\', 3);') - - -def downgrade(): - conn = op.get_bind() - - conn.execute('DELETE FROM engagement_status WHERE id=3') - conn.execute('SELECT setval(\'engagement_status_id_seq\', 2);') diff --git a/met-api/migrations/versions/bd0eb0d25caf_adding_engagement_consent_message.py b/met-api/migrations/versions/bd0eb0d25caf_adding_engagement_consent_message.py deleted file mode 100644 index 2d2ce9577..000000000 --- a/met-api/migrations/versions/bd0eb0d25caf_adding_engagement_consent_message.py +++ /dev/null @@ -1,28 +0,0 @@ -"""adding_engagement_consent_message - -Revision ID: bd0eb0d25caf -Revises: 4114001e1a4c -Create Date: 2024-01-10 12:21:32.781720 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'bd0eb0d25caf' -down_revision = '4114001e1a4c' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('engagement', sa.Column('consent_message', postgresql.JSON(astext_type=sa.Text()), nullable=True)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('engagement', 'consent_message') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/be3880132244_merge_heads.py b/met-api/migrations/versions/be3880132244_merge_heads.py deleted file mode 100644 index 823bc4afd..000000000 --- a/met-api/migrations/versions/be3880132244_merge_heads.py +++ /dev/null @@ -1,24 +0,0 @@ -"""merge heads - -Revision ID: be3880132244 -Revises: 8595172f9d96, a1237c8a3df9 -Create Date: 2023-03-08 15:04:38.905600 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'be3880132244' -down_revision = ('8595172f9d96', 'a1237c8a3df9') -branch_labels = None -depends_on = None - - -def upgrade(): - pass - - -def downgrade(): - pass diff --git a/met-api/migrations/versions/c09e77fde608_added_enum_value_for_timeline_widget.py b/met-api/migrations/versions/c09e77fde608_added_enum_value_for_timeline_widget.py deleted file mode 100644 index 0d55ae41d..000000000 --- a/met-api/migrations/versions/c09e77fde608_added_enum_value_for_timeline_widget.py +++ /dev/null @@ -1,61 +0,0 @@ -"""Added enum value for Timeline Widget. - -Revision ID: c09e77fde608 -Revises: 3e4dc76a96ab -Create Date: 2023-12-06 11:46:20.934373 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'c09e77fde608' -down_revision = '3e4dc76a96ab' -branch_labels = None -depends_on = None - - -def upgrade(): - op.add_column('timeline_event', sa.Column('created_date', sa.DateTime(), nullable=False)) - op.add_column('timeline_event', sa.Column('updated_date', sa.DateTime(), nullable=True)) - op.add_column('timeline_event', sa.Column('created_by', sa.String(length=50), nullable=True)) - op.add_column('timeline_event', sa.Column('updated_by', sa.String(length=50), nullable=True)) - - op.add_column('widget_timeline', sa.Column('created_date', sa.DateTime(), nullable=False)) - op.add_column('widget_timeline', sa.Column('updated_date', sa.DateTime(), nullable=True)) - op.add_column('widget_timeline', sa.Column('created_by', sa.String(length=50), nullable=True)) - op.add_column('widget_timeline', sa.Column('updated_by', sa.String(length=50), nullable=True)) - - widget_type_table = sa.table('widget_type', - sa.Column('id', sa.Integer), - sa.Column('name', sa.String), - sa.Column('description', sa.String)) - - op.bulk_insert( - widget_type_table, - [ - { - 'id': 8, - 'name': 'CAC Form', - 'description': 'Add a CAC Form to your project', - }, - { - 'id': 9, - 'name': 'Timeline', - 'description': 'Create a timeline for a series of events', - }, - ] - ) - -def downgrade(): - op.drop_column('widget_timeline', 'updated_by') - op.drop_column('widget_timeline', 'created_by') - op.drop_column('widget_timeline', 'updated_date') - op.drop_column('widget_timeline', 'created_date') - op.drop_column('timeline_event', 'updated_by') - op.drop_column('timeline_event', 'created_by') - op.drop_column('timeline_event', 'updated_date') - op.drop_column('timeline_event', 'created_date') - op.delete(widget_type_table).filter_by(id=8) - op.delete(widget_type_table).filter_by(id=9) diff --git a/met-api/migrations/versions/c19bc1af9f2b_alter_engagement_add_scheduled.py b/met-api/migrations/versions/c19bc1af9f2b_alter_engagement_add_scheduled.py deleted file mode 100644 index 25b01d743..000000000 --- a/met-api/migrations/versions/c19bc1af9f2b_alter_engagement_add_scheduled.py +++ /dev/null @@ -1,38 +0,0 @@ -"""alter engagement add scheduled - -Revision ID: c19bc1af9f2b -Revises: 2aa7554dde59 -Create Date: 2022-10-21 11:43:06.798995 - -""" -from datetime import datetime -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'c19bc1af9f2b' -down_revision = '2aa7554dde59' -branch_labels = None -depends_on = None - - -def upgrade(): - op.add_column('engagement', sa.Column('scheduled_date', sa.DateTime(), nullable=True)) - - engagement_status = sa.table('engagement_status', - sa.column('id', sa.Integer), - sa.column('status_name', sa.String), - sa.column('description', sa.String), - sa.column('created_date', sa.DateTime), - sa.column('updated_date', sa.DateTime)) - - op.bulk_insert(engagement_status, [ - {'id': 4, 'status_name': 'Scheduled', 'description': 'Scheduled to be published', 'created_date': datetime.utcnow(), 'updated_date': datetime.utcnow()} - ]) - - -def downgrade(): - conn = op.get_bind() - op.drop_column('engagement', 'scheduled_date') - conn.execute('DELETE FROM engagement_status WHERE id=4') diff --git a/met-api/migrations/versions/cad222167ce7_memberships_added.py b/met-api/migrations/versions/cad222167ce7_memberships_added.py deleted file mode 100644 index 174e7c020..000000000 --- a/met-api/migrations/versions/cad222167ce7_memberships_added.py +++ /dev/null @@ -1,58 +0,0 @@ -"""memberships added - -Revision ID: cad222167ce7 -Revises: 5880bead8f03 -Create Date: 2023-01-24 14:31:48.024605 - -""" -from datetime import datetime - -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'cad222167ce7' -down_revision = '5880bead8f03' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - membership_status_codes = op.create_table('membership_status_codes', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('status_name', sa.String(length=50), nullable=True), - sa.Column('description', sa.String(length=50), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('membership', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('status', sa.Integer(), nullable=True), - sa.Column('engagement_id', sa.Integer(), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=True), - sa.Column('type', sa.Enum('TEAM_MEMBER', name='membershiptype'), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['status'], ['membership_status_codes.id'], ), - sa.ForeignKeyConstraint(['user_id'], ['met_users.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.bulk_insert(membership_status_codes, [ - {'id': 1, 'status_name': 'ACTIVE', 'description': 'Active Membership', 'created_date': datetime.utcnow(), - 'updated_date': datetime.utcnow()}, - {'id': 2, 'status_name': 'INACTIVE', 'description': 'Inactive Membership', 'created_date': datetime.utcnow(), - 'updated_date': datetime.utcnow()} - ]) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('membership') - op.drop_table('membership_status_codes') - op.execute("""DROP TYPE membershiptype""") - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/cb965cb4a3ad_update_comment_status.py b/met-api/migrations/versions/cb965cb4a3ad_update_comment_status.py deleted file mode 100644 index e19d13b12..000000000 --- a/met-api/migrations/versions/cb965cb4a3ad_update_comment_status.py +++ /dev/null @@ -1,27 +0,0 @@ -"""update comment_status status_name column - -Revision ID: cb965cb4a3ad -Revises: 8ca063aafc01 -Create Date: 2022-08-08 14:48:08.856309 - -""" -from alembic import op - - -# revision identifiers, used by Alembic. -revision = 'cb965cb4a3ad' -down_revision = '8ca063aafc01' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.execute('UPDATE comment_status SET status_name = \'Approved\' WHERE id = 2;') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.execute('UPDATE comment_status SET status_name = \'Accepted\' WHERE id = 2;') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/d0f92ae9ba77_alter_engagement_alter_banner_url.py b/met-api/migrations/versions/d0f92ae9ba77_alter_engagement_alter_banner_url.py deleted file mode 100644 index 6b4b7523b..000000000 --- a/met-api/migrations/versions/d0f92ae9ba77_alter_engagement_alter_banner_url.py +++ /dev/null @@ -1,30 +0,0 @@ -"""Alter engagement alter banner_url - -Revision ID: d0f92ae9ba77 -Revises: 2545d45bb29c -Create Date: 2022-06-27 13:36:48.323235 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'd0f92ae9ba77' -down_revision = '2545d45bb29c' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('engagement', sa.Column('banner_filename', sa.String(), nullable=True)) - op.drop_column('engagement', 'banner_url') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('engagement', sa.Column('banner_url', sa.VARCHAR(), autoincrement=False, nullable=True)) - op.drop_column('engagement', 'banner_filename') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/d152f85734f9_subscription_models.py b/met-api/migrations/versions/d152f85734f9_subscription_models.py deleted file mode 100644 index 4716a203b..000000000 --- a/met-api/migrations/versions/d152f85734f9_subscription_models.py +++ /dev/null @@ -1,40 +0,0 @@ -"""subscription_models - -Revision ID: d152f85734f9 -Revises: 196b0abc23b6 -Create Date: 2023-05-31 12:50:57.863157 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'd152f85734f9' -down_revision = '196b0abc23b6' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('subscription', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('email_verification_id', sa.Integer(), nullable=True), - sa.Column('user_id', sa.Integer(), nullable=True), - sa.Column('is_subscribed', sa.Boolean(), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['email_verification_id'], ['email_verification.id'], ), - sa.ForeignKeyConstraint(['user_id'], ['met_users.id'], ), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('subscription') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/d2e7baa531ce_edit_subscription_models.py b/met-api/migrations/versions/d2e7baa531ce_edit_subscription_models.py deleted file mode 100644 index 44c8ac2bd..000000000 --- a/met-api/migrations/versions/d2e7baa531ce_edit_subscription_models.py +++ /dev/null @@ -1,32 +0,0 @@ -"""edit_subscription_models - -Revision ID: d2e7baa531ce -Revises: d152f85734f9 -Create Date: 2023-06-01 21:09:11.767623 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'd2e7baa531ce' -down_revision = 'd152f85734f9' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('subscription', sa.Column('engagement_id', sa.Integer(), nullable=True)) - op.drop_constraint('subscription_email_verification_id_fkey', 'subscription', type_='foreignkey') - op.drop_column('subscription', 'email_verification_id') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('subscription', sa.Column('email_verification_id', sa.INTEGER(), autoincrement=False, nullable=True)) - op.create_foreign_key('subscription_email_verification_id_fkey', 'subscription', 'email_verification', ['email_verification_id'], ['id']) - op.drop_column('subscription', 'engagement_id') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/d5a6d9bb804b_merge_heads.py b/met-api/migrations/versions/d5a6d9bb804b_merge_heads.py deleted file mode 100644 index b029041cf..000000000 --- a/met-api/migrations/versions/d5a6d9bb804b_merge_heads.py +++ /dev/null @@ -1,24 +0,0 @@ -"""merge heads - -Revision ID: d5a6d9bb804b -Revises: 4f5f91937f5c, d822eacf35c9 -Create Date: 2023-09-19 13:12:04.624782 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'd5a6d9bb804b' -down_revision = ('4f5f91937f5c', 'd822eacf35c9') -branch_labels = None -depends_on = None - - -def upgrade(): - pass - - -def downgrade(): - pass diff --git a/met-api/migrations/versions/d822eacf35c9_add_engagement_unpublished_status.py b/met-api/migrations/versions/d822eacf35c9_add_engagement_unpublished_status.py deleted file mode 100644 index 4c8250d32..000000000 --- a/met-api/migrations/versions/d822eacf35c9_add_engagement_unpublished_status.py +++ /dev/null @@ -1,34 +0,0 @@ -""" Add unpublished status to engagement - -Revision ID: d822eacf35c9 -Revises: 7ebd9ecfccdd -Create Date: 2023-09-15 15:34:32.854902 - -""" -from datetime import datetime -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = 'd822eacf35c9' -down_revision = '7ebd9ecfccdd' -branch_labels = None -depends_on = None - - -def upgrade(): - engagement_status = sa.table('engagement_status', - sa.column('id', sa.Integer), - sa.column('status_name', sa.String), - sa.column('description', sa.String), - sa.column('created_date', sa.DateTime), - sa.column('updated_date', sa.DateTime)) - - op.bulk_insert(engagement_status, [ - {'id': 5, 'status_name': 'Unpublished', 'description': 'Unpublished and hidden', 'created_date': datetime.utcnow(), 'updated_date': datetime.utcnow()} - ]) - - -def downgrade(): - conn = op.get_bind() - conn.execute('DELETE FROM engagement_status WHERE id=5') diff --git a/met-api/migrations/versions/d86a682d7096_merge_heads.py b/met-api/migrations/versions/d86a682d7096_merge_heads.py deleted file mode 100644 index b91273382..000000000 --- a/met-api/migrations/versions/d86a682d7096_merge_heads.py +++ /dev/null @@ -1,24 +0,0 @@ -"""merge heads - -Revision ID: d86a682d7096 -Revises: 242c9f0364df, 4c72047de4d3 -Create Date: 2023-01-12 19:33:57.854477 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'd86a682d7096' -down_revision = ('242c9f0364df', '4c72047de4d3') -branch_labels = None -depends_on = None - - -def upgrade(): - pass - - -def downgrade(): - pass diff --git a/met-api/migrations/versions/d9777850eb98_add_proponent_template.py b/met-api/migrations/versions/d9777850eb98_add_proponent_template.py deleted file mode 100644 index 08e9e0d23..000000000 --- a/met-api/migrations/versions/d9777850eb98_add_proponent_template.py +++ /dev/null @@ -1,56 +0,0 @@ -"""add_proponent_template - -Revision ID: d9777850eb98 -Revises: 7ebd9ecfccdd -Create Date: 2023-09-17 12:47:48.475329 - -""" -from datetime import datetime -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'd9777850eb98' -down_revision = '7ebd9ecfccdd' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - document_type = sa.Table( - 'generated_document_type', - sa.MetaData(), - sa.Column('id', sa.Integer), - sa.Column('name', sa.String), - sa.Column('description', sa.String), - sa.Column('created_date', sa.DateTime, default=datetime.utcnow) - ) - - document_template = sa.Table( - 'generated_document_template', - sa.MetaData(), - sa.Column('id', sa.Integer), - sa.Column('type_id', sa.Integer), - sa.Column('hash_code', sa.String), - sa.Column('extension', sa.String), - sa.Column('created_date', sa.DateTime, default=datetime.utcnow) - ) - - op.bulk_insert(document_type, [ - {'id': 3, 'name': 'proponent_comments_sheet', 'description': 'Comments export for proponent'} - ]) - - op.bulk_insert(document_template, [ - {'id': 3, 'type_id': 3, 'hash_code': None, "extension": "xlsx"} - ]) - op.execute('UPDATE generated_document_template SET hash_code = null where id = 1') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.execute('DELETE FROM document_type WHERE id = 3') - op.execute('DELETE FROM document_template WHERE id = 3') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/db3ffa0dd6ad_.py b/met-api/migrations/versions/db3ffa0dd6ad_.py deleted file mode 100644 index 5369da924..000000000 --- a/met-api/migrations/versions/db3ffa0dd6ad_.py +++ /dev/null @@ -1,29 +0,0 @@ -"""Add marker label column instead of description -Revision ID: db3ffa0dd6ad -Revises: be3880132244 -Create Date: 2023-03-14 13:14:35.088089 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'db3ffa0dd6ad' -down_revision = 'be3880132244' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('widget_map', sa.Column('marker_label', sa.String(length=30), nullable=True)) - op.drop_column('widget_map', 'description') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('widget_map', sa.Column('description', sa.VARCHAR(length=500), autoincrement=False, nullable=True)) - op.drop_column('widget_map', 'marker_label') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/db737a0db061_.py b/met-api/migrations/versions/db737a0db061_.py deleted file mode 100644 index ec56787f0..000000000 --- a/met-api/migrations/versions/db737a0db061_.py +++ /dev/null @@ -1,43 +0,0 @@ -""" Fill empty widget titles -Revision ID: db737a0db061 -Revises: df73727dc6d9b7_add_sub_tbl -Create Date: 2023-08-04 14:11:01.993136 -""" - -from alembic import op - -# revision identifiers, used by Alembic. -revision = 'db737a0db061' -down_revision = 'df73727dc6d9b7_add_sub_tbl' -branch_labels = None -depends_on = None - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - - # Execute an UPDATE statement to set 'title' based on 'widget_type_id' - op.execute(""" - UPDATE widget - SET title = - CASE - WHEN widget_type_id = 1 THEN 'Who is Listening' - WHEN widget_type_id = 2 THEN 'Documents' - WHEN widget_type_id = 3 THEN 'Environmental Assessment Process' - WHEN widget_type_id = 4 THEN 'Sign Up for Updates' - WHEN widget_type_id = 5 THEN 'Events' - WHEN widget_type_id = 6 THEN 'Map' - WHEN widget_type_id = 7 THEN 'Video' - ELSE 'Default Title' -- This is for any widget_type_id not covered above - END - WHERE title IS NULL; - """) - - # ### end Alembic commands ### - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - - # Execute an UPDATE statement to set 'title' to NULL for all rows - op.execute("UPDATE widget SET title = NULL;") - - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/df73727dc6d9b7_add_sub_tabl.py b/met-api/migrations/versions/df73727dc6d9b7_add_sub_tabl.py deleted file mode 100644 index 5d3d625d3..000000000 --- a/met-api/migrations/versions/df73727dc6d9b7_add_sub_tabl.py +++ /dev/null @@ -1,55 +0,0 @@ -""" Add subscribe_item table to database - -Revision ID: df73727dc6d9b7_add_sub_tbl -Revises: 5a1258a76598 -Create Date: 2023-07-26 13:03:24.113767 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = 'df73727dc6d9b7_add_sub_tbl' -down_revision = '5a1258a76598' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('widget_subscribe', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('type', sa.Enum('EMAIL_LIST', 'SIGN_UP', name='subscribetypes'), nullable=False), - sa.Column('sort_index', sa.Integer(), nullable=True), - sa.Column('widget_id', sa.Integer(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('subscribe_item', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('description', sa.String(length=500), nullable=True), - sa.Column('call_to_action_text', sa.String(length=25), nullable=True), - sa.Column('call_to_action_type', sa.String(length=25), nullable=True), - sa.Column('sort_index', sa.Integer(), nullable=True), - sa.Column('widget_subscribe_id', sa.Integer(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['widget_subscribe_id'], ['widget_subscribe.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') - ) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - - op.drop_table('subscribe_item') - op.drop_table('widget_subscribe') - op.execute('DROP TYPE subscribetypes;') - # ### end Alembic commands ### \ No newline at end of file diff --git a/met-api/migrations/versions/df842dc6d0b7_.py b/met-api/migrations/versions/df842dc6d0b7_.py deleted file mode 100644 index 0fd73adbf..000000000 --- a/met-api/migrations/versions/df842dc6d0b7_.py +++ /dev/null @@ -1,27 +0,0 @@ -""" Add is_uploaded column to widget_documents table - -Revision ID: df842dc6d0b7 -Revises: 47fc88fe0477 -Create Date: 2023-07-14 13:03:24.113767 - -""" -from alembic import op -import sqlalchemy as sa - -# revision identifiers, used by Alembic. -revision = 'df842dc6d0b7' -down_revision = '47fc88fe0477' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('widget_documents', sa.Column('is_uploaded', sa.Boolean(), nullable=False, server_default=sa.false())) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('widget_documents', 'is_uploaded') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/e2d5d38220d9_add_revoked_membership.py b/met-api/migrations/versions/e2d5d38220d9_add_revoked_membership.py deleted file mode 100644 index 63b769715..000000000 --- a/met-api/migrations/versions/e2d5d38220d9_add_revoked_membership.py +++ /dev/null @@ -1,46 +0,0 @@ -""" Add revoked_date and revoked status for membership - -Revision ID: e2d5d38220d9 -Revises: db737a0db061 -Create Date: 2023-08-09 07:21:47.043458 - -""" -from datetime import datetime -from alembic import op -import sqlalchemy as sa -# revision identifiers, used by Alembic. -revision = 'e2d5d38220d9' -down_revision = 'db737a0db061' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('membership', sa.Column('revoked_date', sa.DateTime(), nullable=True)) - - membership_status_codes = sa.table( - 'membership_status_codes', - sa.Column('id', sa.Integer), - sa.Column('status_name', sa.String), - sa.Column('description', sa.String), - sa.Column('created_date', sa.DateTime), - sa.Column('updated_date', sa.DateTime) - ) - op.execute( - membership_status_codes.insert().values( - id=3, - status_name='REVOKED', - description='Revoked Membership', - created_date=datetime.utcnow(), - updated_date=datetime.utcnow() - ) - ) - - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('membership', 'revoked_date') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/e37d79be3a05_added_sort_for_widgets.py b/met-api/migrations/versions/e37d79be3a05_added_sort_for_widgets.py deleted file mode 100644 index 3ff1f201f..000000000 --- a/met-api/migrations/versions/e37d79be3a05_added_sort_for_widgets.py +++ /dev/null @@ -1,28 +0,0 @@ -"""added sort for widgets - -Revision ID: e37d79be3a05 -Revises: 9f86fdcfb248 -Create Date: 2022-11-20 17:25:42.697782 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'e37d79be3a05' -down_revision = '9f86fdcfb248' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### Add Sort index to widget.### - op.add_column('widget', sa.Column('sort_index', sa.Integer(), nullable=False, server_default='1')) - # ### end Alembic commands ### - - -def downgrade(): - # ### Remove the sort index column. ### - op.drop_column('widget', 'sort_index') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/e5d3bbb8d2f0_add_survey_hidden_column.py b/met-api/migrations/versions/e5d3bbb8d2f0_add_survey_hidden_column.py deleted file mode 100644 index 4cfb1cd1e..000000000 --- a/met-api/migrations/versions/e5d3bbb8d2f0_add_survey_hidden_column.py +++ /dev/null @@ -1,30 +0,0 @@ -"""add_survey_hidden_column - -Revision ID: e5d3bbb8d2f0 -Revises: 7d8897c412de -Create Date: 2023-04-05 16:47:19.185256 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'e5d3bbb8d2f0' -down_revision = '7d8897c412de' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('survey', sa.Column('is_hidden', sa.Boolean(), nullable=True)) - op.execute('UPDATE survey SET is_hidden = false') - op.alter_column('survey', 'is_hidden', nullable=False, server_default=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('survey', 'is_hidden') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/e69d7ac92afb_alter_submission.py b/met-api/migrations/versions/e69d7ac92afb_alter_submission.py deleted file mode 100644 index 6e5e08667..000000000 --- a/met-api/migrations/versions/e69d7ac92afb_alter_submission.py +++ /dev/null @@ -1,47 +0,0 @@ -"""alter submission - -Revision ID: e69d7ac92afb -Revises: 6764af39864e -Create Date: 2022-12-20 17:08:59.040079 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'e69d7ac92afb' -down_revision = '6764af39864e' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('comment', sa.Column('created_date', sa.DateTime(), nullable=True)) - op.add_column('comment', sa.Column('updated_date', sa.DateTime(), nullable=True)) - op.add_column('comment', sa.Column('created_by', sa.String(length=50), nullable=True)) - op.add_column('comment', sa.Column('updated_by', sa.String(length=50), nullable=True)) - op.add_column('email_verification', sa.Column('submission_id', sa.Integer(), nullable=True)) - op.create_foreign_key('email_verification_submission_id_fkey', 'email_verification', 'submission', ['submission_id'], ['id']) - op.add_column('submission', sa.Column('engagement_id', sa.Integer(), nullable=True)) - op.create_foreign_key('submission_engagement_id_fkey', 'submission', 'engagement', ['engagement_id'], ['id'], ondelete='CASCADE') - - op.execute('UPDATE submission SET engagement_id = (select survey.engagement_id from survey where survey.id = submission.survey_id) WHERE engagement_id IS NULL') - op.alter_column('submission', 'engagement_id', nullable=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('submission_engagement_id_fkey', 'submission', type_='foreignkey') - op.drop_column('submission', 'engagement_id') - op.drop_index(op.f('ix_met_users_username'), table_name='met_users') - op.create_index('ix_user_username', 'met_users', ['username'], unique=False) - op.drop_constraint('email_verification_submission_id_fkey', 'email_verification', type_='foreignkey') - op.drop_column('email_verification', 'submission_id') - op.drop_column('comment', 'updated_by') - op.drop_column('comment', 'created_by') - op.drop_column('comment', 'updated_date') - op.drop_column('comment', 'created_date') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/ec0128056a33_rework_engagement_metadata.py b/met-api/migrations/versions/ec0128056a33_rework_engagement_metadata.py deleted file mode 100644 index db404b097..000000000 --- a/met-api/migrations/versions/ec0128056a33_rework_engagement_metadata.py +++ /dev/null @@ -1,164 +0,0 @@ -"""Rework engagement metadata - -Revision ID: ec0128056a33 -Revises: 08f69642b7ae -Create Date: 2023-12-18 18:37:08.781433 - -""" -from enum import auto -from alembic import op -from regex import F -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql -from flask import current_app - -from met_api.models.tenant import Tenant as TenantModel - - -# revision identifiers, used by Alembic. -revision = 'ec0128056a33' -down_revision = '08f69642b7ae' -branch_labels = None -depends_on = None - - -def upgrade(): - op.create_table('engagement_metadata_taxa', - sa.Column('created_date', sa.DateTime(), nullable=False), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('id', sa.Integer(), nullable=False, unique=True, autoincrement=True), - sa.Column('tenant_id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(length=64), nullable=True), - sa.Column('description', sa.String(length=256), nullable=True), - sa.Column('freeform', sa.Boolean(), nullable=False), - sa.Column('data_type', sa.String(length=64), nullable=True), - sa.Column('default_value', sa.Text(), nullable=True), - sa.Column('one_per_engagement', sa.Boolean(), nullable=True), - sa.Column('position', sa.Integer(), nullable=False), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id', name='pk_engagement_metadata_taxa'), - sa.UniqueConstraint('id', name='uq_engagement_metadata_taxa_id') - ) - # remove old data from engagement_metadata table - op.execute('DELETE FROM engagement_metadata') - - # Drop the existing primary key constraint - op.drop_constraint('engagement_metadata_pkey', 'engagement_metadata', type_='primary') - - # Create a new index on engagement_metadata_taxa - op.create_index(op.f('ix_engagement_metadata_taxa_position'), 'engagement_metadata_taxa', ['position'], unique=False) - - # Add new columns to engagement_metadata - op.add_column('engagement_metadata', sa.Column('id', sa.Integer(), nullable=False)) - op.add_column('engagement_metadata', sa.Column('taxon_id', sa.Integer(), nullable=False)) - op.add_column('engagement_metadata', sa.Column('value', sa.Text(), nullable=False)) - - # Create a new primary key constraint on the 'id' column - op.create_primary_key('pk_engagement_metadata', 'engagement_metadata', ['id']) - - # Create a new sequence and set it as the default for the 'id' column - op.execute('CREATE SEQUENCE engagement_metadata_id_seq START 1') - op.execute('ALTER TABLE engagement_metadata ALTER COLUMN id SET DEFAULT nextval(\'engagement_metadata_id_seq\')') - op.execute('ALTER SEQUENCE engagement_metadata_id_seq OWNED BY engagement_metadata.id') - - # Remove the not-null constraint from 'engagement_id' - op.alter_column('engagement_metadata', 'engagement_id', existing_type=sa.INTEGER(), nullable=True) - - # Create a foreign key constraint - op.create_foreign_key('fk_engagement_meta_taxon', 'engagement_metadata', 'engagement_metadata_taxa', ['taxon_id'], ['id'], ondelete='CASCADE') - - # Remove the 'project_tracking_id' and 'project_metadata' column - op.drop_column('engagement_metadata', 'project_tracking_id') - op.drop_column('engagement_metadata', 'project_metadata') - - # add default taxa for default tenant - default_short_name = current_app.config.get('DEFAULT_TENANT_SHORT_NAME') - tenant_id = TenantModel.find_by_short_name(default_short_name).id - taxa = [ - { - 'name': 'keywords', - 'description': 'Keywords for categorizing the engagement', - 'freeform': True, - 'one_per_engagement': False, - 'data_type': 'text', - }, - { - 'name': 'description', - 'description': 'Description of the engagement', - 'freeform': True, - 'data_type': 'long_text', - }, - { - 'name': 'jira_ticket_url', - 'description': 'URL of the Jira ticket for this engagement', - 'freeform': True, - 'data_type': 'text', - }, - { - 'name': 'pmo_project_number', - 'description': 'PMO project number', - 'freeform': True, - 'data_type': 'text', - }, - { - 'name': 'engagement_category', - 'description': 'Category of the engagement', - 'data_type': 'text', - 'one_per_engagement': False, - }, - { - 'name': 'engagement_method', - 'description': 'Method of engagement', - 'data_type': 'text', - 'default_value': "Survey", - 'one_per_engagement': False, - }, - { - 'name': 'language', - 'description': 'Language of the engagement', - 'data_type': 'text', - 'default_value': "English", - 'one_per_engagement': False, - }, - { - 'name': 'ministry', - 'description': 'Ministry of the engagement', - 'data_type': 'text', - } - ] - for index, taxon in enumerate(taxa): - op.execute( - sa.text('INSERT INTO engagement_metadata_taxa (tenant_id, name, description, freeform, data_type, default_value, one_per_engagement, position, created_date, updated_date) ' - 'VALUES (:tenant_id, :name, :description, :freeform, :data_type, :default_value, :one_per_engagement, :position, now(), now())') - .params( - tenant_id=tenant_id, - name=taxon['name'], - description=taxon['description'], - freeform=taxon.get('freeform', False), - data_type=taxon['data_type'], - default_value=taxon.get('default_value'), - one_per_engagement=taxon.get('one_per_engagement', True), - position=index + 1, - ) - ) - - # ### end Alembic commands ### - - -def downgrade(): - op.add_column('engagement_metadata', sa.Column('project_metadata', postgresql.JSONB(astext_type=sa.Text()), nullable=True)) - op.add_column('engagement_metadata', sa.Column('project_tracking_id', sa.VARCHAR(length=100), autoincrement=False, nullable=True)) - op.alter_column('engagement_metadata', 'engagement_id', existing_type=sa.INTEGER(), nullable=False) - op.drop_constraint('fk_engagement_meta_taxon', 'engagement_metadata', type_='foreignkey') - # remove primary key constraint from engagement_metadata.id - op.drop_constraint('pk_engagement_metadata', 'engagement_metadata', type_='primary') - op.drop_column('engagement_metadata', 'value') - op.drop_column('engagement_metadata', 'taxon_id') - op.drop_column('engagement_metadata', 'id') - op.drop_index(op.f('ix_engagement_metadata_taxa_position'), table_name='engagement_metadata_taxa') - # add primary key constraint to engagement_metadata.engagement_id - op.create_primary_key('engagement_metadata_pkey', 'engagement_metadata', ['engagement_id']) - op.drop_table('engagement_metadata_taxa') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/ec0128056a33_table_until_feb_09_2024.py b/met-api/migrations/versions/ec0128056a33_table_until_feb_09_2024.py new file mode 100644 index 000000000..f682ed458 --- /dev/null +++ b/met-api/migrations/versions/ec0128056a33_table_until_feb_09_2024.py @@ -0,0 +1,709 @@ +"""Tables Until Feb 09 2024 + +Revision ID: ec0128056a33 +Revises: +Create Date: 2023-12-18 18:37:08.781433 + +""" +from enum import auto +from alembic import op +from regex import F +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql +from flask import current_app + +from met_api.models.tenant import Tenant as TenantModel + + +# revision identifiers, used by Alembic. +revision = 'ec0128056a33' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('comment_status', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('status_name', sa.String(length=50), nullable=False), + sa.Column('description', sa.String(length=50), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('status_name') + ) + op.create_table('email_queue', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('entity_id', sa.Integer(), nullable=False), + sa.Column('entity_type', sa.String(length=100), nullable=False), + sa.Column('action', sa.String(length=100), nullable=True), + sa.Column('notification_status', sa.Enum('PROCESSING', 'SENT', name='notificationstatus'), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('engagement_status', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('status_name', sa.String(length=50), nullable=True), + sa.Column('description', sa.String(length=50), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('generated_document_type', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('name', sa.String(length=30), nullable=False), + sa.Column('description', sa.String(length=100), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('membership_status_codes', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('status_name', sa.String(length=50), nullable=True), + sa.Column('description', sa.String(length=50), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('participant', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('email_address', sa.String(length=500), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('tenant', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('short_name', sa.String(length=10), nullable=False, comment='A small code for the tenant ie GDX , EAO.'), + sa.Column('name', sa.String(length=50), nullable=True, comment='Full name of the ministry.ie Env Assessment Office'), + sa.Column('description', sa.String(length=300), nullable=True), + sa.Column('title', sa.String(length=30), nullable=False), + sa.Column('logo_url', sa.String(length=300), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('user_status', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('status_name', sa.String(length=50), nullable=True), + sa.Column('description', sa.String(length=50), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('widget_type', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=50), nullable=False), + sa.Column('description', sa.String(length=200), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('name') + ) + op.create_table('contact', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('name', sa.String(length=50), nullable=True), + sa.Column('title', sa.String(length=50), nullable=True), + sa.Column('email', sa.String(length=50), nullable=True), + sa.Column('phone_number', sa.String(length=50), nullable=True), + sa.Column('address', sa.String(length=150), nullable=True), + sa.Column('bio', sa.String(length=500), nullable=True, comment='A biography or short biographical profile of someone.'), + sa.Column('avatar_filename', sa.String(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('engagement', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('name', sa.String(length=50), nullable=True), + sa.Column('description', sa.Text(), nullable=False), + sa.Column('rich_description', postgresql.JSON(astext_type=sa.Text()), nullable=False), + sa.Column('start_date', sa.DateTime(), nullable=True), + sa.Column('end_date', sa.DateTime(), nullable=True), + sa.Column('status_id', sa.Integer(), nullable=True), + sa.Column('published_date', sa.DateTime(), nullable=True), + sa.Column('scheduled_date', sa.DateTime(), nullable=True), + sa.Column('content', sa.Text(), nullable=False), + sa.Column('rich_content', postgresql.JSON(astext_type=sa.Text()), nullable=False), + sa.Column('banner_filename', sa.String(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=True), + sa.Column('is_internal', sa.Boolean(), nullable=False), + sa.Column('consent_message', postgresql.JSON(astext_type=sa.Text()), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['status_id'], ['engagement_status.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('engagement_metadata_taxa', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(length=64), nullable=True), + sa.Column('description', sa.String(length=256), nullable=True), + sa.Column('freeform', sa.Boolean(), nullable=False), + sa.Column('data_type', sa.String(length=64), nullable=True), + sa.Column('default_value', sa.Text(), nullable=True), + sa.Column('one_per_engagement', sa.Boolean(), nullable=True), + sa.Column('position', sa.Integer(), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('id') + ) + op.create_index(op.f('ix_engagement_metadata_taxa_position'), 'engagement_metadata_taxa', ['position'], unique=False) + op.create_index(op.f('ix_engagement_metadata_taxa_tenant_id'), 'engagement_metadata_taxa', ['tenant_id'], unique=False) + op.create_table('feedback', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('status', sa.Enum('Unreviewed', 'Archived', name='feedbackstatustype'), nullable=False), + sa.Column('rating', sa.Enum('NONE', 'VerySatisfied', 'Satisfied', 'Neutral', 'Unsatisfied', 'VeryUnsatisfied', name='ratingtype'), nullable=True), + sa.Column('comment_type', sa.Enum('NONE', 'Issue', 'Idea', 'Else', name='commenttype'), nullable=True), + sa.Column('comment', sa.Text(), nullable=True), + sa.Column('submission_path', sa.Text(), nullable=True), + sa.Column('source', sa.Enum('Public', 'Internal', name='feedbacksourcetype'), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('generated_document_template', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('type_id', sa.Integer(), nullable=False), + sa.Column('hash_code', sa.String(length=64), nullable=True), + sa.Column('extension', sa.String(length=10), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['type_id'], ['generated_document_type.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('hash_code') + ) + op.create_table('staff_users', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('first_name', sa.String(length=50), nullable=True), + sa.Column('middle_name', sa.String(length=50), nullable=True), + sa.Column('last_name', sa.String(length=50), nullable=True), + sa.Column('username', sa.String(length=100), nullable=True), + sa.Column('email_address', sa.String(length=100), nullable=True), + sa.Column('contact_number', sa.String(length=50), nullable=True), + sa.Column('external_id', sa.String(length=50), nullable=False), + sa.Column('status_id', sa.Integer(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['status_id'], ['user_status.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('external_id') + ) + op.create_index(op.f('ix_staff_users_username'), 'staff_users', ['username'], unique=True) + op.create_table('subscription', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('engagement_id', sa.Integer(), nullable=True), + sa.Column('participant_id', sa.Integer(), nullable=True), + sa.Column('is_subscribed', sa.Boolean(), nullable=False), + sa.Column('project_id', sa.String(length=50), nullable=True), + sa.Column('type', sa.Enum('ENGAGEMENT', 'PROJECT', 'TENANT', name='subscriptiontype'), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['participant_id'], ['participant.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('cac_form', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('engagement_id', sa.Integer(), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=True), + sa.Column('understand', sa.Boolean(), nullable=False), + sa.Column('terms_of_reference', sa.Boolean(), nullable=False), + sa.Column('first_name', sa.String(length=50), nullable=False), + sa.Column('last_name', sa.String(length=50), nullable=False), + sa.Column('city', sa.String(length=50), nullable=False), + sa.Column('email', sa.String(length=50), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('engagement_metadata', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('engagement_id', sa.Integer(), nullable=True), + sa.Column('taxon_id', sa.Integer(), nullable=False), + sa.Column('value', sa.Text(), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['taxon_id'], ['engagement_metadata_taxa.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_engagement_metadata_engagement_id'), 'engagement_metadata', ['engagement_id'], unique=False) + op.create_index(op.f('ix_engagement_metadata_taxon_id'), 'engagement_metadata', ['taxon_id'], unique=False) + op.create_index(op.f('ix_engagement_metadata_value'), 'engagement_metadata', ['value'], unique=False) + op.create_table('engagement_settings', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('engagement_id', sa.Integer(), nullable=False), + sa.Column('send_report', sa.Boolean(), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('engagement_id') + ) + op.create_table('engagement_slug', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('engagement_id', sa.Integer(), nullable=False), + sa.Column('slug', sa.String(length=200), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('engagement_id'), + sa.UniqueConstraint('slug') + ) + op.create_index('idx_slug', 'engagement_slug', ['slug'], unique=False) + op.create_table('engagement_status_block', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('engagement_id', sa.Integer(), nullable=True), + sa.Column('survey_status', sa.Enum('Upcoming', 'Open', 'Closed', name='submissionstatus'), nullable=False), + sa.Column('block_text', postgresql.JSON(astext_type=sa.Text()), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('engagement_id', 'survey_status', name='unique_engagement_status_block') + ) + op.create_table('membership', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('status', sa.Integer(), nullable=True), + sa.Column('revoked_date', sa.DateTime(), nullable=True), + sa.Column('engagement_id', sa.Integer(), nullable=False), + sa.Column('user_id', sa.Integer(), nullable=True), + sa.Column('type', sa.Enum('TEAM_MEMBER', 'REVIEWER', name='membershiptype'), nullable=False), + sa.Column('tenant_id', sa.Integer(), nullable=True), + sa.Column('version', sa.Integer(), nullable=False), + sa.Column('is_latest', sa.Boolean(), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['status'], ['membership_status_codes.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ), + sa.ForeignKeyConstraint(['user_id'], ['staff_users.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('survey', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('name', sa.String(length=50), nullable=True), + sa.Column('form_json', postgresql.JSONB(astext_type=sa.Text()), server_default='{}', nullable=False), + sa.Column('engagement_id', sa.Integer(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=True), + sa.Column('is_hidden', sa.Boolean(), nullable=False), + sa.Column('is_template', sa.Boolean(), nullable=False), + sa.Column('generate_dashboard', sa.Boolean(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_survey_name'), 'survey', ['name'], unique=False) + op.create_table('widget', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('widget_type_id', sa.Integer(), nullable=True), + sa.Column('engagement_id', sa.Integer(), nullable=True), + sa.Column('title', sa.String(length=100), nullable=True, comment='Custom title for the widget.'), + sa.Column('sort_index', sa.Integer(), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['widget_type_id'], ['widget_type.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('widget_type_id', 'engagement_id', name='unique_widget_type') + ) + op.create_table('report_setting', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('survey_id', sa.Integer(), nullable=False), + sa.Column('question_id', sa.Text(), nullable=True), + sa.Column('question_key', sa.Text(), nullable=True), + sa.Column('question_type', sa.Text(), nullable=True), + sa.Column('question', sa.Text(), nullable=True), + sa.Column('display', sa.Boolean(), nullable=True, comment='Flag to identify if the question needs to be diplayed on the dashboard.'), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['survey_id'], ['survey.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('submission', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('submission_json', postgresql.JSONB(astext_type=sa.Text()), server_default='{}', nullable=False), + sa.Column('survey_id', sa.Integer(), nullable=False), + sa.Column('engagement_id', sa.Integer(), nullable=False), + sa.Column('participant_id', sa.Integer(), nullable=True), + sa.Column('reviewed_by', sa.String(length=50), nullable=True), + sa.Column('review_date', sa.DateTime(), nullable=True), + sa.Column('comment_status_id', sa.Integer(), nullable=True), + sa.Column('has_personal_info', sa.Boolean(), nullable=True), + sa.Column('has_profanity', sa.Boolean(), nullable=True), + sa.Column('rejected_reason_other', sa.String(length=500), nullable=True), + sa.Column('has_threat', sa.Boolean(), nullable=True), + sa.Column('notify_email', sa.Boolean(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['comment_status_id'], ['comment_status.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['participant_id'], ['participant.id'], ), + sa.ForeignKeyConstraint(['survey_id'], ['survey.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('widget_documents', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(length=50), nullable=True), + sa.Column('type', sa.String(length=50), nullable=True, comment='File or Folder identifier'), + sa.Column('parent_document_id', sa.Integer(), nullable=True), + sa.Column('url', sa.String(length=2000), nullable=True), + sa.Column('sort_index', sa.Integer(), nullable=True), + sa.Column('widget_id', sa.Integer(), nullable=True), + sa.Column('is_uploaded', sa.Boolean(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['parent_document_id'], ['widget_documents.id'], ), + sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('widget_events', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(length=50), nullable=True), + sa.Column('type', sa.Enum('OPENHOUSE', 'MEETUP', 'VIRTUAL', name='eventtypes'), nullable=False), + sa.Column('sort_index', sa.Integer(), nullable=True), + sa.Column('widget_id', sa.Integer(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('widget_item', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('widget_data_id', sa.Integer(), nullable=False, comment='A dynamic foreign key that could be to any table where the widget data is hosted.'), + sa.Column('widget_id', sa.Integer(), nullable=True), + sa.Column('sort_index', sa.Integer(), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('widget_data_id', 'widget_id', name='unique_widget_data') + ) + op.create_table('widget_map', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('widget_id', sa.Integer(), nullable=True), + sa.Column('engagement_id', sa.Integer(), nullable=True), + sa.Column('marker_label', sa.String(length=30), nullable=True), + sa.Column('latitude', sa.Float(), nullable=False), + sa.Column('longitude', sa.Float(), nullable=False), + sa.Column('geojson', sa.Text(), nullable=True), + sa.Column('file_name', sa.Text(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('widget_polls', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('title', sa.String(length=255), nullable=False), + sa.Column('description', sa.String(length=2048), nullable=True), + sa.Column('status', sa.Enum('active', 'inactive', name='poll_status'), nullable=True), + sa.Column('widget_id', sa.Integer(), nullable=False), + sa.Column('engagement_id', sa.Integer(), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('widget_subscribe', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('type', sa.Enum('EMAIL_LIST', 'SIGN_UP', name='subscribetypes'), nullable=False), + sa.Column('sort_index', sa.Integer(), nullable=True), + sa.Column('widget_id', sa.Integer(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('widget_timeline', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('engagement_id', sa.Integer(), nullable=False), + sa.Column('widget_id', sa.Integer(), nullable=False), + sa.Column('title', sa.String(length=255), nullable=True), + sa.Column('description', sa.Text(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('widget_video', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('widget_id', sa.Integer(), nullable=True), + sa.Column('engagement_id', sa.Integer(), nullable=True), + sa.Column('video_url', sa.String(length=255), nullable=False), + sa.Column('description', sa.Text(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('comment', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('text', sa.Text(), nullable=False), + sa.Column('submission_date', sa.DateTime(), nullable=True), + sa.Column('survey_id', sa.Integer(), nullable=False), + sa.Column('participant_id', sa.Integer(), nullable=True), + sa.Column('submission_id', sa.Integer(), nullable=True), + sa.Column('component_id', sa.String(length=10), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['participant_id'], ['participant.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['submission_id'], ['submission.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['survey_id'], ['survey.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('email_verification', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('verification_token', sa.String(length=50), nullable=False), + sa.Column('participant_id', sa.Integer(), nullable=True), + sa.Column('is_active', sa.Boolean(), nullable=False), + sa.Column('type', sa.Enum('Survey', 'RejectedComment', 'Subscribe', name='emailverificationtype'), nullable=False), + sa.Column('survey_id', sa.Integer(), nullable=True), + sa.Column('submission_id', sa.Integer(), nullable=True), + sa.Column('tenant_id', sa.Integer(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['participant_id'], ['participant.id'], ), + sa.ForeignKeyConstraint(['submission_id'], ['submission.id'], ), + sa.ForeignKeyConstraint(['survey_id'], ['survey.id'], ), + sa.ForeignKeyConstraint(['tenant_id'], ['tenant.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('event_item', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('description', sa.String(length=500), nullable=True), + sa.Column('location_name', sa.String(length=50), nullable=True), + sa.Column('location_address', sa.String(length=100), nullable=True, comment='The address of the location'), + sa.Column('start_date', sa.DateTime(), nullable=True), + sa.Column('end_date', sa.DateTime(), nullable=True), + sa.Column('url', sa.String(length=500), nullable=True), + sa.Column('url_label', sa.String(length=100), nullable=True, comment='Label to show for href links'), + sa.Column('sort_index', sa.Integer(), nullable=True), + sa.Column('widget_events_id', sa.Integer(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['widget_events_id'], ['widget_events.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('poll_answers', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('answer_text', sa.String(length=255), nullable=False), + sa.Column('poll_id', sa.Integer(), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['poll_id'], ['widget_polls.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('staff_note', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('note', sa.Text(), nullable=True), + sa.Column('note_type', sa.String(length=50), nullable=True), + sa.Column('survey_id', sa.Integer(), nullable=False), + sa.Column('submission_id', sa.Integer(), nullable=False), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['submission_id'], ['submission.id'], ondelete='SET NULL'), + sa.ForeignKeyConstraint(['survey_id'], ['survey.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('subscribe_item', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('description', sa.String(length=500), nullable=True), + sa.Column('rich_description', sa.Text(), nullable=True), + sa.Column('call_to_action_text', sa.String(length=25), nullable=True), + sa.Column('call_to_action_type', sa.String(length=25), nullable=False), + sa.Column('sort_index', sa.Integer(), nullable=True), + sa.Column('widget_subscribe_id', sa.Integer(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['widget_subscribe_id'], ['widget_subscribe.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('timeline_event', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('engagement_id', sa.Integer(), nullable=False), + sa.Column('widget_id', sa.Integer(), nullable=False), + sa.Column('timeline_id', sa.Integer(), nullable=False), + sa.Column('status', sa.Enum('Pending', 'InProgress', 'Completed', name='timelineeventstatus'), nullable=False), + sa.Column('position', sa.Integer(), nullable=False), + sa.Column('description', sa.Text(), nullable=True), + sa.Column('time', sa.String(length=255), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['engagement_id'], ['engagement.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['timeline_id'], ['widget_timeline.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('poll_responses', + sa.Column('created_date', sa.DateTime(), nullable=False), + sa.Column('updated_date', sa.DateTime(), nullable=True), + sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), + sa.Column('participant_id', sa.String(length=255), nullable=False), + sa.Column('selected_answer_id', sa.Integer(), nullable=False), + sa.Column('poll_id', sa.Integer(), nullable=False), + sa.Column('widget_id', sa.Integer(), nullable=False), + sa.Column('is_deleted', sa.Boolean(), nullable=True), + sa.Column('created_by', sa.String(length=50), nullable=True), + sa.Column('updated_by', sa.String(length=50), nullable=True), + sa.ForeignKeyConstraint(['poll_id'], ['widget_polls.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['selected_answer_id'], ['poll_answers.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['widget_id'], ['widget.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('poll_responses') + op.drop_table('timeline_event') + op.drop_table('subscribe_item') + op.drop_table('staff_note') + op.drop_table('poll_answers') + op.drop_table('event_item') + op.drop_table('email_verification') + op.drop_table('comment') + op.drop_table('widget_video') + op.drop_table('widget_timeline') + op.drop_table('widget_subscribe') + op.drop_table('widget_polls') + op.drop_table('widget_map') + op.drop_table('widget_item') + op.drop_table('widget_events') + op.drop_table('widget_documents') + op.drop_table('submission') + op.drop_table('report_setting') + op.drop_table('widget') + op.drop_index(op.f('ix_survey_name'), table_name='survey') + op.drop_table('survey') + op.drop_table('membership') + op.drop_table('engagement_status_block') + op.drop_index('idx_slug', table_name='engagement_slug') + op.drop_table('engagement_slug') + op.drop_table('engagement_settings') + op.drop_index(op.f('ix_engagement_metadata_value'), table_name='engagement_metadata') + op.drop_index(op.f('ix_engagement_metadata_taxon_id'), table_name='engagement_metadata') + op.drop_index(op.f('ix_engagement_metadata_engagement_id'), table_name='engagement_metadata') + op.drop_table('engagement_metadata') + op.drop_table('cac_form') + op.drop_table('subscription') + op.drop_index(op.f('ix_staff_users_username'), table_name='staff_users') + op.drop_table('staff_users') + op.drop_table('generated_document_template') + op.drop_table('feedback') + op.drop_index(op.f('ix_engagement_metadata_taxa_tenant_id'), table_name='engagement_metadata_taxa') + op.drop_index(op.f('ix_engagement_metadata_taxa_position'), table_name='engagement_metadata_taxa') + op.drop_table('engagement_metadata_taxa') + op.drop_table('engagement') + op.drop_table('contact') + op.drop_table('widget_type') + op.drop_table('user_status') + op.drop_table('tenant') + op.drop_table('participant') + op.drop_table('membership_status_codes') + op.drop_table('generated_document_type') + op.drop_table('engagement_status') + op.drop_table('email_queue') + op.drop_table('comment_status') + # ### end Alembic commands ### \ No newline at end of file diff --git a/met-api/migrations/versions/ec504565fab3_update_status_and_user.py b/met-api/migrations/versions/ec504565fab3_update_status_and_user.py deleted file mode 100644 index 853d40264..000000000 --- a/met-api/migrations/versions/ec504565fab3_update_status_and_user.py +++ /dev/null @@ -1,53 +0,0 @@ -"""update status and user - -Revision ID: ec504565fab3 -Revises: d0f92ae9ba77 -Create Date: 2022-06-29 13:34:24.214735 - -""" -from alembic import op -import sqlalchemy as sa -from datetime import datetime - - -# revision identifiers, used by Alembic. -revision = 'ec504565fab3' -down_revision = 'd0f92ae9ba77' -branch_labels = None -depends_on = None - - -def upgrade(): - conn = op.get_bind() - - engagement_status = sa.table('engagement_status', - sa.column('id', sa.Integer), - sa.column('status_name', sa.String), - sa.column('description', sa.String), - sa.column('created_date', sa.DateTime), - sa.column('updated_date', sa.DateTime)) - - conn.execute('UPDATE "user" SET first_name=\'MET\', middle_name=\'\', last_name=\'System\' WHERE id=1') - - conn.execute( - engagement_status.update() - .where(engagement_status.c.id==1) - .values({'status_name': 'Draft', 'description': 'Not ready to the public'})) - - op.bulk_insert(engagement_status, [ - {'id': 2, 'status_name': 'Published', 'description': 'Visible to the public', 'created_date': datetime.utcnow(), 'updated_date': datetime.utcnow()} - ]) - - conn.execute('SELECT setval(\'engagement_status_id_seq\', 2);') - # ### end Alembic commands ### - - -def downgrade(): - conn = op.get_bind() - - conn.execute('UPDATE engagement_status SET status_name=\'draft\', description=\'Test Description\' WHERE id=1') - conn.execute('UPDATE "user" SET first_name=\'A\', middle_name=\'B\', last_name=\'C\' WHERE id=1') - conn.execute('DELETE FROM engagement_status WHERE id=2') - - conn.execute('SELECT setval(\'engagement_status_id_seq\', 1);') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/eef9cc71cca7_.py b/met-api/migrations/versions/eef9cc71cca7_.py deleted file mode 100644 index 666ece2a8..000000000 --- a/met-api/migrations/versions/eef9cc71cca7_.py +++ /dev/null @@ -1,28 +0,0 @@ -"""empty message - -Revision ID: eef9cc71cca7 -Revises: 326419c08f59 -Create Date: 2022-05-26 09:03:34.300400 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'eef9cc71cca7' -down_revision = '326419c08f59' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('engagement', sa.Column('rich_description', postgresql.JSON(astext_type=sa.Text()), nullable=False)) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('engagement', 'rich_description') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/f037908194df_kc_attribute_script.py b/met-api/migrations/versions/f037908194df_kc_attribute_script.py deleted file mode 100644 index 656c02ca3..000000000 --- a/met-api/migrations/versions/f037908194df_kc_attribute_script.py +++ /dev/null @@ -1,39 +0,0 @@ -"""kc attribute script - -Revision ID: f037908194df -Revises: 04e6c48187da -Create Date: 2023-08-27 22:50:02.047232 - -""" -from typing import List - -from alembic import op -import sqlalchemy as sa - -from met_api.models import StaffUser -from met_api.services.participant_service import KEYCLOAK_SERVICE - -# revision identifiers, used by Alembic. -revision = 'f037908194df' -down_revision = '04e6c48187da' -branch_labels = None -depends_on = None - - -def upgrade(): - default_tenant_id = 1 - conn = op.get_bind() - - user_res = conn.execute("SELECT * FROM staff_users WHERE external_id IS NOT NULL;") - user_list: List[StaffUser] = user_res.fetchall() - for user in user_list: - try: - print(f'Processing profile for {user.first_name} {user.last_name}',) - KEYCLOAK_SERVICE.add_attribute_to_user(user_id=user.external_id, attribute_value=default_tenant_id) - except Exception as exc: - print('Profile Error for', user.first_name) - print(exc) - - -def downgrade(): - pass diff --git a/met-api/migrations/versions/f2b3f08c8d60_alter_comment_add_submission_id.py b/met-api/migrations/versions/f2b3f08c8d60_alter_comment_add_submission_id.py deleted file mode 100644 index a0764c9c0..000000000 --- a/met-api/migrations/versions/f2b3f08c8d60_alter_comment_add_submission_id.py +++ /dev/null @@ -1,51 +0,0 @@ -"""alter comment add submission_id - -Revision ID: f2b3f08c8d60 -Revises: c19bc1af9f2b -Create Date: 2022-11-01 11:59:02.563717 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'f2b3f08c8d60' -down_revision = 'c19bc1af9f2b' -branch_labels = None -depends_on = None - - -def upgrade(): - conn = op.get_bind() - op.add_column('comment', sa.Column('submission_id', sa.Integer(), nullable=True)) - op.add_column('comment', sa.Column('component_id', sa.String(), nullable=True)) - op.create_foreign_key('comment_submission_id_fkey', 'comment', 'submission', ['submission_id'], ['id'], ondelete='SET NULL') - # Attempt to populate the submission id for previous answers BUT - # this could potentially link a comment with a wrong submission id - # when there are multiple submissions for the same survey from the same user (we are unable to identify different submissions for the same user) - conn.execute('UPDATE comment c \ - SET submission_id=s.id \ - FROM submission s \ - WHERE \ - c.submission_id is null AND \ - s.survey_id = c.survey_id AND \ - s.user_id = c.user_id') - - # Attempt to populate the corresponding question/componnent id for a comment BUT - # this could potentially link a comment with its a wrong question/component - # when there are multiple questions in the survey (we are unable to identify which question it belongs to) - conn.execute('UPDATE comment c \ - SET component_id=item_object->>\'key\' \ - FROM survey s, \ - jsonb_array_elements(s.form_json->\'components\') with ordinality arr(item_object, position) \ - WHERE \ - c.component_id is null AND \ - c.survey_id = s.id AND \ - item_object->>\'inputType\' = \'text\'') - - -def downgrade(): - op.drop_constraint('comment_submission_id_fkey', 'comment', type_='foreignkey') - op.drop_column('comment', 'submission_id') - op.drop_column('comment', 'component_id') diff --git a/met-api/migrations/versions/f40da1b8f3e0_initialize_user_status.py b/met-api/migrations/versions/f40da1b8f3e0_initialize_user_status.py deleted file mode 100644 index b4a610f77..000000000 --- a/met-api/migrations/versions/f40da1b8f3e0_initialize_user_status.py +++ /dev/null @@ -1,28 +0,0 @@ -""" Initialize user status -P -Revision ID: f40da1b8f3e0 -Revises: 31041fb90d53 -Create Date: 2023-08-18 09:50:27.567044 - -""" -from alembic import op - -# revision identifiers, used by Alembic. -revision = 'f40da1b8f3e0' -down_revision = '31041fb90d53' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.execute("UPDATE staff_users SET status_id = 1") - op.alter_column('staff_users', 'status_id', nullable=False, server_default='1') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('staff_users', 'status_id', nullable=True, server_default=None) - op.execute("UPDATE staff_users SET status_id = NULL") - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/f6f480b5b664_add_survey_template_column.py b/met-api/migrations/versions/f6f480b5b664_add_survey_template_column.py deleted file mode 100644 index 1816e50e9..000000000 --- a/met-api/migrations/versions/f6f480b5b664_add_survey_template_column.py +++ /dev/null @@ -1,30 +0,0 @@ -"""add_survey_template_column - -Revision ID: f6f480b5b664 -Revises: e5d3bbb8d2f0 -Create Date: 2023-04-10 15:33:38.529726 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'f6f480b5b664' -down_revision = 'e5d3bbb8d2f0' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('survey', sa.Column('is_template', sa.Boolean(), nullable=True)) - op.execute('UPDATE survey SET is_template = false') - op.alter_column('survey', 'is_template', nullable=False, server_default=False) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('survey', 'is_template') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/f99eb7f53041_.py b/met-api/migrations/versions/f99eb7f53041_.py deleted file mode 100644 index 0fc66957a..000000000 --- a/met-api/migrations/versions/f99eb7f53041_.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Increase submission.rejected_reason_other length - -Revision ID: f99eb7f53041 -Revises: 7bf7394a517c -Create Date: 2023-03-27 11:15:52.342030 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'f99eb7f53041' -down_revision = '7bf7394a517c' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('submission', 'rejected_reason_other', - existing_type=sa.VARCHAR(length=50), - type_=sa.VARCHAR(length=500), - nullable=True) - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('submission', 'rejected_reason_other', - existing_type=sa.VARCHAR(length=500), - type_=sa.VARCHAR(length=50), - nullable=True) - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/fc570c0faace_survey_migration.py b/met-api/migrations/versions/fc570c0faace_survey_migration.py deleted file mode 100644 index 00d97d85d..000000000 --- a/met-api/migrations/versions/fc570c0faace_survey_migration.py +++ /dev/null @@ -1,41 +0,0 @@ -"""Survey Migration - -Revision ID: fc570c0faace -Revises: d0f92ae9ba77 -Create Date: 2022-07-05 12:21:37.175093 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'fc570c0faace' -down_revision = 'ec504565fab3' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('survey', - sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), - sa.Column('name', sa.String(length=50), nullable=True, index=True), - sa.Column('form_json', postgresql.JSONB(astext_type=sa.Text()), server_default='{}', nullable=False), - sa.Column('engagement_id', sa.Integer(), nullable=True), - sa.Column('created_date', sa.DateTime(), nullable=True), - sa.Column('updated_date', sa.DateTime(), nullable=True), - sa.Column('created_by', sa.String(length=50), nullable=True), - sa.Column('updated_by', sa.String(length=50), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - - op.create_foreign_key('fk_survey_engagement', 'survey', 'engagement', ['engagement_id'], ['id'], ondelete='CASCADE') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('fk_survey_engagement', 'survey', type_='foreignkey') - op.drop_table('survey') - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/fda10461892d_basemodel_column_change.py b/met-api/migrations/versions/fda10461892d_basemodel_column_change.py deleted file mode 100644 index a2168ab77..000000000 --- a/met-api/migrations/versions/fda10461892d_basemodel_column_change.py +++ /dev/null @@ -1,52 +0,0 @@ -"""basemodel column change - -Revision ID: fda10461892d -Revises: 0d863f773838 -Create Date: 2022-12-22 05:21:58.579344 - -""" -from alembic import op -import sqlalchemy as sa -from sqlalchemy.dialects import postgresql - -# revision identifiers, used by Alembic. -revision = 'fda10461892d' -down_revision = '0d863f773838' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('engagement', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=False) - op.alter_column('engagement', 'created_by', - existing_type=sa.VARCHAR(length=50), - nullable=True) - op.alter_column('engagement', 'updated_by', - existing_type=sa.VARCHAR(length=50), - nullable=True) - op.add_column('user_status', sa.Column('updated_by', sa.String(length=50), nullable=True)) - op.drop_column('user_status', 'modified_by_id') - op.add_column('widget_documents', sa.Column('updated_by', sa.String(length=50), nullable=True)) - op.drop_column('widget_documents', 'modified_by_id') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('widget_documents', sa.Column('modified_by_id', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) - op.drop_column('widget_documents', 'updated_by') - op.add_column('user_status', sa.Column('modified_by_id', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) - op.drop_column('user_status', 'updated_by') - op.alter_column('engagement', 'updated_by', - existing_type=sa.VARCHAR(length=50), - nullable=False) - op.alter_column('engagement', 'created_by', - existing_type=sa.VARCHAR(length=50), - nullable=False) - op.alter_column('engagement', 'created_date', - existing_type=postgresql.TIMESTAMP(), - nullable=True) - # ### end Alembic commands ### diff --git a/met-api/migrations/versions/ffac8f5b4288_add_reject_reason.py b/met-api/migrations/versions/ffac8f5b4288_add_reject_reason.py deleted file mode 100644 index 9b7538911..000000000 --- a/met-api/migrations/versions/ffac8f5b4288_add_reject_reason.py +++ /dev/null @@ -1,30 +0,0 @@ -"""add reject reason - -Revision ID: ffac8f5b4288 -Revises: 46490dc02be5 -Create Date: 2022-12-07 12:11:33.172817 - -""" -from alembic import op -import sqlalchemy as sa - - -# revision identifiers, used by Alembic. -revision = 'ffac8f5b4288' -down_revision = '46490dc02be5' -branch_labels = None -depends_on = None - - -def upgrade(): - op.add_column('submission', sa.Column('has_personal_info', sa.Boolean(), nullable=True)) - op.add_column('submission', sa.Column('has_profanity', sa.Boolean(), nullable=True)) - op.add_column('submission', sa.Column('rejected_reason_other', sa.String(length=50), nullable=True)) - op.add_column('submission', sa.Column('has_threat', sa.Boolean(), nullable=True)) - - -def downgrade(): - op.drop_column('submission', 'has_threat') - op.drop_column('submission', 'rejected_reason_other') - op.drop_column('submission', 'has_profanity') - op.drop_column('submission', 'has_personal_info') diff --git a/met-api/tests/utilities/factory_scenarios.py b/met-api/tests/utilities/factory_scenarios.py index 8e3acf1b3..477363623 100644 --- a/met-api/tests/utilities/factory_scenarios.py +++ b/met-api/tests/utilities/factory_scenarios.py @@ -619,7 +619,7 @@ class TestCommentInfo(dict, Enum): comment1 = { 'text': fake.paragraph(nb_sentences=3), - 'component_id': 'simpletextarea', + 'component_id': 'simpletext', 'submission_date': datetime.now().strftime('%Y-%m-%d'), }