diff --git a/Taskfile.yml b/Taskfile.yml index a9ca44ac021..70f6f23dd9f 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -151,7 +151,7 @@ tasks: py:migrate: desc: generates a new database migration file e.g. task py:migrate -- "add new column" cmds: - - poetry run alembic revision --autogenerate -m "{{ .CLI_ARGS }}" + - poetry run alembic --config mealie/alembic/alembic.ini revision --autogenerate -m "{{ .CLI_ARGS }}" - task: py:format ui:build: diff --git a/docker/Dockerfile b/docker/Dockerfile index 6c9c09066ee..056825c4195 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -109,10 +109,6 @@ COPY --from=crfpp /usr/local/bin/crf_test /usr/local/bin/crf_test COPY ./mealie $MEALIE_HOME/mealie COPY ./poetry.lock ./pyproject.toml $MEALIE_HOME/ -# Alembic -COPY ./alembic $MEALIE_HOME/alembic -COPY ./alembic.ini $MEALIE_HOME/ - # venv already has runtime deps installed we get a quicker install WORKDIR $MEALIE_HOME RUN . $VENV_PATH/bin/activate && poetry install -E pgsql --only main diff --git a/alembic/README b/mealie/alembic/README similarity index 100% rename from alembic/README rename to mealie/alembic/README diff --git a/alembic.ini b/mealie/alembic/alembic.ini similarity index 98% rename from alembic.ini rename to mealie/alembic/alembic.ini index c068265c89d..d955e61bebc 100644 --- a/alembic.ini +++ b/mealie/alembic/alembic.ini @@ -2,7 +2,7 @@ [alembic] # path to migration scripts -script_location = alembic +script_location = %(here)s # template used to generate migration files file_template = %%(year)d-%%(month).2d-%%(day).2d-%%(hour).2d.%%(minute).2d.%%(second).2d_%%(rev)s_%%(slug)s diff --git a/alembic/env.py b/mealie/alembic/env.py similarity index 100% rename from alembic/env.py rename to mealie/alembic/env.py index 4b38d2830e8..bff312261e8 100644 --- a/alembic/env.py +++ b/mealie/alembic/env.py @@ -1,9 +1,9 @@ from typing import Any import sqlalchemy as sa +from alembic import context import mealie.db.models._all_models # noqa: F401 -from alembic import context from mealie.core.config import get_app_settings from mealie.db.models._model_base import SqlAlchemyBase diff --git a/alembic/script.py.mako b/mealie/alembic/script.py.mako similarity index 100% rename from alembic/script.py.mako rename to mealie/alembic/script.py.mako index 3bf7e9e4d13..ccd9c8a36c4 100644 --- a/alembic/script.py.mako +++ b/mealie/alembic/script.py.mako @@ -6,9 +6,9 @@ Create Date: ${create_date} """ import sqlalchemy as sa +from alembic import op import mealie.db.migration_types -from alembic import op % if imports: ${imports} % endif diff --git a/alembic/versions/2022-02-21-19.56.24_6b0f5f32d602_initial_tables.py b/mealie/alembic/versions/2022-02-21-19.56.24_6b0f5f32d602_initial_tables.py similarity index 100% rename from alembic/versions/2022-02-21-19.56.24_6b0f5f32d602_initial_tables.py rename to mealie/alembic/versions/2022-02-21-19.56.24_6b0f5f32d602_initial_tables.py diff --git a/alembic/versions/2022-03-23-17.43.34_263dd6707191_convert_quantity_from_integer_to_float.py b/mealie/alembic/versions/2022-03-23-17.43.34_263dd6707191_convert_quantity_from_integer_to_float.py similarity index 100% rename from alembic/versions/2022-03-23-17.43.34_263dd6707191_convert_quantity_from_integer_to_float.py rename to mealie/alembic/versions/2022-03-23-17.43.34_263dd6707191_convert_quantity_from_integer_to_float.py diff --git a/alembic/versions/2022-03-27-19.30.28_f1a2dbee5fe9_add_original_text_column_to_recipes_.py b/mealie/alembic/versions/2022-03-27-19.30.28_f1a2dbee5fe9_add_original_text_column_to_recipes_.py similarity index 100% rename from alembic/versions/2022-03-27-19.30.28_f1a2dbee5fe9_add_original_text_column_to_recipes_.py rename to mealie/alembic/versions/2022-03-27-19.30.28_f1a2dbee5fe9_add_original_text_column_to_recipes_.py diff --git a/alembic/versions/2022-03-31-19.19.55_59eb59135381_add_tags_to_cookbooks.py b/mealie/alembic/versions/2022-03-31-19.19.55_59eb59135381_add_tags_to_cookbooks.py similarity index 100% rename from alembic/versions/2022-03-31-19.19.55_59eb59135381_add_tags_to_cookbooks.py rename to mealie/alembic/versions/2022-03-31-19.19.55_59eb59135381_add_tags_to_cookbooks.py diff --git a/alembic/versions/2022-04-03-10.48.51_09dfc897ad62_add_require_all_for_cookbook_filters.py b/mealie/alembic/versions/2022-04-03-10.48.51_09dfc897ad62_add_require_all_for_cookbook_filters.py similarity index 100% rename from alembic/versions/2022-04-03-10.48.51_09dfc897ad62_add_require_all_for_cookbook_filters.py rename to mealie/alembic/versions/2022-04-03-10.48.51_09dfc897ad62_add_require_all_for_cookbook_filters.py diff --git a/alembic/versions/2022-06-01-11.12.06_ab0bae02578f_add_use_abbreviation_column_to_.py b/mealie/alembic/versions/2022-06-01-11.12.06_ab0bae02578f_add_use_abbreviation_column_to_.py similarity index 100% rename from alembic/versions/2022-06-01-11.12.06_ab0bae02578f_add_use_abbreviation_column_to_.py rename to mealie/alembic/versions/2022-06-01-11.12.06_ab0bae02578f_add_use_abbreviation_column_to_.py diff --git a/alembic/versions/2022-06-15-21.05.34_f30cf048c228_add_new_webhook_fields.py b/mealie/alembic/versions/2022-06-15-21.05.34_f30cf048c228_add_new_webhook_fields.py similarity index 100% rename from alembic/versions/2022-06-15-21.05.34_f30cf048c228_add_new_webhook_fields.py rename to mealie/alembic/versions/2022-06-15-21.05.34_f30cf048c228_add_new_webhook_fields.py diff --git a/alembic/versions/2022-08-12-19.05.59_188374910655_add_login_attemps_and_locked_at_field_.py b/mealie/alembic/versions/2022-08-12-19.05.59_188374910655_add_login_attemps_and_locked_at_field_.py similarity index 100% rename from alembic/versions/2022-08-12-19.05.59_188374910655_add_login_attemps_and_locked_at_field_.py rename to mealie/alembic/versions/2022-08-12-19.05.59_188374910655_add_login_attemps_and_locked_at_field_.py diff --git a/alembic/versions/2022-08-13-17.07.07_089bfa50d0ed_add_is_ocr_recipe_column_to_recipes.py b/mealie/alembic/versions/2022-08-13-17.07.07_089bfa50d0ed_add_is_ocr_recipe_column_to_recipes.py similarity index 100% rename from alembic/versions/2022-08-13-17.07.07_089bfa50d0ed_add_is_ocr_recipe_column_to_recipes.py rename to mealie/alembic/versions/2022-08-13-17.07.07_089bfa50d0ed_add_is_ocr_recipe_column_to_recipes.py diff --git a/alembic/versions/2022-08-29-13.57.40_44e8d670719d_add_extras_to_shopping_lists_list_items_.py b/mealie/alembic/versions/2022-08-29-13.57.40_44e8d670719d_add_extras_to_shopping_lists_list_items_.py similarity index 100% rename from alembic/versions/2022-08-29-13.57.40_44e8d670719d_add_extras_to_shopping_lists_list_items_.py rename to mealie/alembic/versions/2022-08-29-13.57.40_44e8d670719d_add_extras_to_shopping_lists_list_items_.py diff --git a/alembic/versions/2022-09-27-14.53.14_2ea7a807915c_add_recipe_timeline_events_table.py b/mealie/alembic/versions/2022-09-27-14.53.14_2ea7a807915c_add_recipe_timeline_events_table.py similarity index 100% rename from alembic/versions/2022-09-27-14.53.14_2ea7a807915c_add_recipe_timeline_events_table.py rename to mealie/alembic/versions/2022-09-27-14.53.14_2ea7a807915c_add_recipe_timeline_events_table.py diff --git a/alembic/versions/2022-11-03-13.10.24_1923519381ad_renamed_timeline_event_message_and_.py b/mealie/alembic/versions/2022-11-03-13.10.24_1923519381ad_renamed_timeline_event_message_and_.py similarity index 100% rename from alembic/versions/2022-11-03-13.10.24_1923519381ad_renamed_timeline_event_message_and_.py rename to mealie/alembic/versions/2022-11-03-13.10.24_1923519381ad_renamed_timeline_event_message_and_.py diff --git a/alembic/versions/2022-11-22-03.42.45_167eb69066ad_add_recipe_scale_to_shopping_list_item_.py b/mealie/alembic/versions/2022-11-22-03.42.45_167eb69066ad_add_recipe_scale_to_shopping_list_item_.py similarity index 100% rename from alembic/versions/2022-11-22-03.42.45_167eb69066ad_add_recipe_scale_to_shopping_list_item_.py rename to mealie/alembic/versions/2022-11-22-03.42.45_167eb69066ad_add_recipe_scale_to_shopping_list_item_.py diff --git a/alembic/versions/2023-01-21-16.54.44_165d943c64ee_add_related_user_to_mealplan.py b/mealie/alembic/versions/2023-01-21-16.54.44_165d943c64ee_add_related_user_to_mealplan.py similarity index 100% rename from alembic/versions/2023-01-21-16.54.44_165d943c64ee_add_related_user_to_mealplan.py rename to mealie/alembic/versions/2023-01-21-16.54.44_165d943c64ee_add_related_user_to_mealplan.py diff --git a/alembic/versions/2023-02-07-20.57.21_ff5f73b01a7a_add_missing_foreign_key_and_order_.py b/mealie/alembic/versions/2023-02-07-20.57.21_ff5f73b01a7a_add_missing_foreign_key_and_order_.py similarity index 100% rename from alembic/versions/2023-02-07-20.57.21_ff5f73b01a7a_add_missing_foreign_key_and_order_.py rename to mealie/alembic/versions/2023-02-07-20.57.21_ff5f73b01a7a_add_missing_foreign_key_and_order_.py diff --git a/alembic/versions/2023-02-10-21.18.32_16160bf731a0_add_more_indices_necessary_for_search.py b/mealie/alembic/versions/2023-02-10-21.18.32_16160bf731a0_add_more_indices_necessary_for_search.py similarity index 100% rename from alembic/versions/2023-02-10-21.18.32_16160bf731a0_add_more_indices_necessary_for_search.py rename to mealie/alembic/versions/2023-02-10-21.18.32_16160bf731a0_add_more_indices_necessary_for_search.py diff --git a/alembic/versions/2023-02-14-20.45.41_5ab195a474eb_add_normalized_search_properties.py b/mealie/alembic/versions/2023-02-14-20.45.41_5ab195a474eb_add_normalized_search_properties.py similarity index 100% rename from alembic/versions/2023-02-14-20.45.41_5ab195a474eb_add_normalized_search_properties.py rename to mealie/alembic/versions/2023-02-14-20.45.41_5ab195a474eb_add_normalized_search_properties.py diff --git a/alembic/versions/2023-02-21-22.03.19_b04a08da2108_added_shopping_list_label_settings.py b/mealie/alembic/versions/2023-02-21-22.03.19_b04a08da2108_added_shopping_list_label_settings.py similarity index 100% rename from alembic/versions/2023-02-21-22.03.19_b04a08da2108_added_shopping_list_label_settings.py rename to mealie/alembic/versions/2023-02-21-22.03.19_b04a08da2108_added_shopping_list_label_settings.py diff --git a/alembic/versions/2023-02-22-21.45.52_38514b39a824_add_auth_method_to_user_table.py b/mealie/alembic/versions/2023-02-22-21.45.52_38514b39a824_add_auth_method_to_user_table.py similarity index 100% rename from alembic/versions/2023-02-22-21.45.52_38514b39a824_add_auth_method_to_user_table.py rename to mealie/alembic/versions/2023-02-22-21.45.52_38514b39a824_add_auth_method_to_user_table.py diff --git a/alembic/versions/2023-04-13-06.47.04_b3dbb554ba53_postgres_fuzzy_search.py b/mealie/alembic/versions/2023-04-13-06.47.04_b3dbb554ba53_postgres_fuzzy_search.py similarity index 100% rename from alembic/versions/2023-04-13-06.47.04_b3dbb554ba53_postgres_fuzzy_search.py rename to mealie/alembic/versions/2023-04-13-06.47.04_b3dbb554ba53_postgres_fuzzy_search.py diff --git a/alembic/versions/2023-08-06-21.00.34_04ac51cbe9a4_added_group_slug.py b/mealie/alembic/versions/2023-08-06-21.00.34_04ac51cbe9a4_added_group_slug.py similarity index 100% rename from alembic/versions/2023-08-06-21.00.34_04ac51cbe9a4_added_group_slug.py rename to mealie/alembic/versions/2023-08-06-21.00.34_04ac51cbe9a4_added_group_slug.py diff --git a/alembic/versions/2023-08-14-19.30.49_1825b5225403_added_recipe_note_to_shopping_list_.py b/mealie/alembic/versions/2023-08-14-19.30.49_1825b5225403_added_recipe_note_to_shopping_list_.py similarity index 100% rename from alembic/versions/2023-08-14-19.30.49_1825b5225403_added_recipe_note_to_shopping_list_.py rename to mealie/alembic/versions/2023-08-14-19.30.49_1825b5225403_added_recipe_note_to_shopping_list_.py diff --git a/alembic/versions/2023-08-15-16.25.07_bcfdad6b7355_remove_tool_name_and_slug_unique_.py b/mealie/alembic/versions/2023-08-15-16.25.07_bcfdad6b7355_remove_tool_name_and_slug_unique_.py similarity index 100% rename from alembic/versions/2023-08-15-16.25.07_bcfdad6b7355_remove_tool_name_and_slug_unique_.py rename to mealie/alembic/versions/2023-08-15-16.25.07_bcfdad6b7355_remove_tool_name_and_slug_unique_.py diff --git a/alembic/versions/2023-09-01-14.55.42_0341b154f79a_added_normalized_unit_and_food_names.py b/mealie/alembic/versions/2023-09-01-14.55.42_0341b154f79a_added_normalized_unit_and_food_names.py similarity index 100% rename from alembic/versions/2023-09-01-14.55.42_0341b154f79a_added_normalized_unit_and_food_names.py rename to mealie/alembic/versions/2023-09-01-14.55.42_0341b154f79a_added_normalized_unit_and_food_names.py diff --git a/alembic/versions/2023-10-04-14.29.26_dded3119c1fe_added_unique_constraints.py b/mealie/alembic/versions/2023-10-04-14.29.26_dded3119c1fe_added_unique_constraints.py similarity index 100% rename from alembic/versions/2023-10-04-14.29.26_dded3119c1fe_added_unique_constraints.py rename to mealie/alembic/versions/2023-10-04-14.29.26_dded3119c1fe_added_unique_constraints.py diff --git a/alembic/versions/2023-10-19-19.22.55_ba1e4a6cfe99_added_plural_names_and_alias_tables_for_.py b/mealie/alembic/versions/2023-10-19-19.22.55_ba1e4a6cfe99_added_plural_names_and_alias_tables_for_.py similarity index 100% rename from alembic/versions/2023-10-19-19.22.55_ba1e4a6cfe99_added_plural_names_and_alias_tables_for_.py rename to mealie/alembic/versions/2023-10-19-19.22.55_ba1e4a6cfe99_added_plural_names_and_alias_tables_for_.py diff --git a/alembic/versions/2024-02-23-16.15.07_2298bb460ffd_added_user_to_shopping_list.py b/mealie/alembic/versions/2024-02-23-16.15.07_2298bb460ffd_added_user_to_shopping_list.py similarity index 100% rename from alembic/versions/2024-02-23-16.15.07_2298bb460ffd_added_user_to_shopping_list.py rename to mealie/alembic/versions/2024-02-23-16.15.07_2298bb460ffd_added_user_to_shopping_list.py index d9afe0beda1..311e376db5c 100644 --- a/alembic/versions/2024-02-23-16.15.07_2298bb460ffd_added_user_to_shopping_list.py +++ b/mealie/alembic/versions/2024-02-23-16.15.07_2298bb460ffd_added_user_to_shopping_list.py @@ -9,10 +9,10 @@ from uuid import UUID import sqlalchemy as sa +from alembic import op from sqlalchemy import orm import mealie.db.migration_types -from alembic import op from mealie.core.root_logger import get_logger logger = get_logger() diff --git a/alembic/versions/2024-03-10-05.08.32_09aba125b57a_add_oidc_auth_method.py b/mealie/alembic/versions/2024-03-10-05.08.32_09aba125b57a_add_oidc_auth_method.py similarity index 100% rename from alembic/versions/2024-03-10-05.08.32_09aba125b57a_add_oidc_auth_method.py rename to mealie/alembic/versions/2024-03-10-05.08.32_09aba125b57a_add_oidc_auth_method.py diff --git a/alembic/versions/2024-03-18-02.28.15_d7c6efd2de42_migrate_favorites_and_ratings_to_user_.py b/mealie/alembic/versions/2024-03-18-02.28.15_d7c6efd2de42_migrate_favorites_and_ratings_to_user_.py similarity index 100% rename from alembic/versions/2024-03-18-02.28.15_d7c6efd2de42_migrate_favorites_and_ratings_to_user_.py rename to mealie/alembic/versions/2024-03-18-02.28.15_d7c6efd2de42_migrate_favorites_and_ratings_to_user_.py index 357f660f50a..8873532bcf6 100644 --- a/alembic/versions/2024-03-18-02.28.15_d7c6efd2de42_migrate_favorites_and_ratings_to_user_.py +++ b/mealie/alembic/versions/2024-03-18-02.28.15_d7c6efd2de42_migrate_favorites_and_ratings_to_user_.py @@ -12,10 +12,10 @@ from uuid import uuid4 import sqlalchemy as sa +from alembic import op from sqlalchemy import orm import mealie.db.migration_types -from alembic import op # revision identifiers, used by Alembic. revision = "d7c6efd2de42" diff --git a/alembic/versions/2024-04-07-01.05.20_7788478a0338_add_group_recipe_actions.py b/mealie/alembic/versions/2024-04-07-01.05.20_7788478a0338_add_group_recipe_actions.py similarity index 100% rename from alembic/versions/2024-04-07-01.05.20_7788478a0338_add_group_recipe_actions.py rename to mealie/alembic/versions/2024-04-07-01.05.20_7788478a0338_add_group_recipe_actions.py index 39810210b67..ad390b1725a 100644 --- a/alembic/versions/2024-04-07-01.05.20_7788478a0338_add_group_recipe_actions.py +++ b/mealie/alembic/versions/2024-04-07-01.05.20_7788478a0338_add_group_recipe_actions.py @@ -7,9 +7,9 @@ """ import sqlalchemy as sa +from alembic import op import mealie.db.migration_types -from alembic import op # revision identifiers, used by Alembic. revision = "7788478a0338" diff --git a/alembic/versions/2024-06-22-10.17.03_32d69327997b_add_staple_flag_to_foods.py b/mealie/alembic/versions/2024-06-22-10.17.03_32d69327997b_add_staple_flag_to_foods.py similarity index 99% rename from alembic/versions/2024-06-22-10.17.03_32d69327997b_add_staple_flag_to_foods.py rename to mealie/alembic/versions/2024-06-22-10.17.03_32d69327997b_add_staple_flag_to_foods.py index bd8cf64f545..8537a8c0de9 100644 --- a/alembic/versions/2024-06-22-10.17.03_32d69327997b_add_staple_flag_to_foods.py +++ b/mealie/alembic/versions/2024-06-22-10.17.03_32d69327997b_add_staple_flag_to_foods.py @@ -7,9 +7,8 @@ """ import sqlalchemy as sa -from sqlalchemy import orm - from alembic import op +from sqlalchemy import orm # revision identifiers, used by Alembic. revision = "32d69327997b" diff --git a/alembic/versions/2024-07-12-16.16.29_feecc8ffb956_add_households.py b/mealie/alembic/versions/2024-07-12-16.16.29_feecc8ffb956_add_households.py similarity index 100% rename from alembic/versions/2024-07-12-16.16.29_feecc8ffb956_add_households.py rename to mealie/alembic/versions/2024-07-12-16.16.29_feecc8ffb956_add_households.py index 2ad26f093e6..0578a764302 100644 --- a/alembic/versions/2024-07-12-16.16.29_feecc8ffb956_add_households.py +++ b/mealie/alembic/versions/2024-07-12-16.16.29_feecc8ffb956_add_households.py @@ -12,11 +12,11 @@ from uuid import uuid4 import sqlalchemy as sa +from alembic import op from slugify import slugify from sqlalchemy import orm import mealie.db.migration_types -from alembic import op from mealie.core.config import get_app_settings # revision identifiers, used by Alembic. diff --git a/alembic/versions/2024-09-02-21.39.49_be568e39ffdf_added_household_recipe_lock_setting_and_.py b/mealie/alembic/versions/2024-09-02-21.39.49_be568e39ffdf_added_household_recipe_lock_setting_and_.py similarity index 99% rename from alembic/versions/2024-09-02-21.39.49_be568e39ffdf_added_household_recipe_lock_setting_and_.py rename to mealie/alembic/versions/2024-09-02-21.39.49_be568e39ffdf_added_household_recipe_lock_setting_and_.py index 83f2e55186a..be8f54ce645 100644 --- a/alembic/versions/2024-09-02-21.39.49_be568e39ffdf_added_household_recipe_lock_setting_and_.py +++ b/mealie/alembic/versions/2024-09-02-21.39.49_be568e39ffdf_added_household_recipe_lock_setting_and_.py @@ -9,7 +9,6 @@ from textwrap import dedent import sqlalchemy as sa - from alembic import op # revision identifiers, used by Alembic. diff --git a/alembic/versions/2024-09-18-14.52.55_1fe4bd37ccc8_add_households_filter_to_meal_plans.py b/mealie/alembic/versions/2024-09-18-14.52.55_1fe4bd37ccc8_add_households_filter_to_meal_plans.py similarity index 100% rename from alembic/versions/2024-09-18-14.52.55_1fe4bd37ccc8_add_households_filter_to_meal_plans.py rename to mealie/alembic/versions/2024-09-18-14.52.55_1fe4bd37ccc8_add_households_filter_to_meal_plans.py index a127e72f44a..6460aa5bb65 100644 --- a/alembic/versions/2024-09-18-14.52.55_1fe4bd37ccc8_add_households_filter_to_meal_plans.py +++ b/mealie/alembic/versions/2024-09-18-14.52.55_1fe4bd37ccc8_add_households_filter_to_meal_plans.py @@ -7,9 +7,9 @@ """ import sqlalchemy as sa +from alembic import op import mealie.db.migration_types -from alembic import op # revision identifiers, used by Alembic. revision = "1fe4bd37ccc8" diff --git a/alembic/versions/2024-10-01-14.17.00_602927e1013e_add_the_rest_of_the_schema_org_.py b/mealie/alembic/versions/2024-10-01-14.17.00_602927e1013e_add_the_rest_of_the_schema_org_.py similarity index 99% rename from alembic/versions/2024-10-01-14.17.00_602927e1013e_add_the_rest_of_the_schema_org_.py rename to mealie/alembic/versions/2024-10-01-14.17.00_602927e1013e_add_the_rest_of_the_schema_org_.py index dbeea910fa6..cca6ec7d9bf 100644 --- a/alembic/versions/2024-10-01-14.17.00_602927e1013e_add_the_rest_of_the_schema_org_.py +++ b/mealie/alembic/versions/2024-10-01-14.17.00_602927e1013e_add_the_rest_of_the_schema_org_.py @@ -7,7 +7,6 @@ """ import sqlalchemy as sa - from alembic import op # revision identifiers, used by Alembic. diff --git a/alembic/versions/2024-10-08-21.17.31_86054b40fd06_added_query_filter_string_to_cookbook_.py b/mealie/alembic/versions/2024-10-08-21.17.31_86054b40fd06_added_query_filter_string_to_cookbook_.py similarity index 100% rename from alembic/versions/2024-10-08-21.17.31_86054b40fd06_added_query_filter_string_to_cookbook_.py rename to mealie/alembic/versions/2024-10-08-21.17.31_86054b40fd06_added_query_filter_string_to_cookbook_.py index 3f5eb908c8d..6737cdf5977 100644 --- a/alembic/versions/2024-10-08-21.17.31_86054b40fd06_added_query_filter_string_to_cookbook_.py +++ b/mealie/alembic/versions/2024-10-08-21.17.31_86054b40fd06_added_query_filter_string_to_cookbook_.py @@ -7,9 +7,9 @@ """ import sqlalchemy as sa +from alembic import op from sqlalchemy import orm -from alembic import op from mealie.db.models._model_utils import guid # revision identifiers, used by Alembic. diff --git a/alembic/versions/2024-10-20-09.47.46_3897397b4631_add_summary_to_recipe_instructions.py b/mealie/alembic/versions/2024-10-20-09.47.46_3897397b4631_add_summary_to_recipe_instructions.py similarity index 99% rename from alembic/versions/2024-10-20-09.47.46_3897397b4631_add_summary_to_recipe_instructions.py rename to mealie/alembic/versions/2024-10-20-09.47.46_3897397b4631_add_summary_to_recipe_instructions.py index 1175ca6ef9d..eba3b1b1a9f 100644 --- a/alembic/versions/2024-10-20-09.47.46_3897397b4631_add_summary_to_recipe_instructions.py +++ b/mealie/alembic/versions/2024-10-20-09.47.46_3897397b4631_add_summary_to_recipe_instructions.py @@ -7,7 +7,6 @@ """ import sqlalchemy as sa - from alembic import op # revision identifiers, used by Alembic. diff --git a/alembic/versions/2024-10-23-15.50.59_b1020f328e98_add_recipe_yield_quantity.py b/mealie/alembic/versions/2024-10-23-15.50.59_b1020f328e98_add_recipe_yield_quantity.py similarity index 100% rename from alembic/versions/2024-10-23-15.50.59_b1020f328e98_add_recipe_yield_quantity.py rename to mealie/alembic/versions/2024-10-23-15.50.59_b1020f328e98_add_recipe_yield_quantity.py index 4aee9ab795b..ba9b21db23f 100644 --- a/alembic/versions/2024-10-23-15.50.59_b1020f328e98_add_recipe_yield_quantity.py +++ b/mealie/alembic/versions/2024-10-23-15.50.59_b1020f328e98_add_recipe_yield_quantity.py @@ -7,9 +7,9 @@ """ import sqlalchemy as sa +from alembic import op from sqlalchemy import orm -from alembic import op from mealie.db.models._model_utils.guid import GUID from mealie.services.scraper.cleaner import clean_yield diff --git a/mealie/db/init_db.py b/mealie/db/init_db.py index 9dc3b13981e..75950a5a299 100644 --- a/mealie/db/init_db.py +++ b/mealie/db/init_db.py @@ -3,11 +3,11 @@ from pathlib import Path from time import sleep -from sqlalchemy import engine, orm, text - from alembic import command, config, script from alembic.config import Config from alembic.runtime import migration +from sqlalchemy import engine, orm, text + from mealie.core import root_logger from mealie.core.config import get_app_settings from mealie.db.db_setup import session_context @@ -22,7 +22,7 @@ from mealie.services.group_services.group_service import GroupService from mealie.services.household_services.household_service import HouseholdService -PROJECT_DIR = Path(__file__).parent.parent.parent +ALEMBIC_DIR = Path(__file__).parent.parent / "alembic" logger = root_logger.get_logger() @@ -101,7 +101,7 @@ def main(): if max_retry == 0: raise ConnectionError("Database connection failed - exiting application.") - alembic_cfg_path = os.getenv("ALEMBIC_CONFIG_FILE", default=str(PROJECT_DIR / "alembic.ini")) + alembic_cfg_path = os.getenv("ALEMBIC_CONFIG_FILE", default=str(ALEMBIC_DIR / "alembic.ini")) if not os.path.isfile(alembic_cfg_path): raise Exception("Provided alembic config path doesn't exist") diff --git a/mealie/services/backups_v2/alchemy_exporter.py b/mealie/services/backups_v2/alchemy_exporter.py index 95dc1d37a2b..24fd37544f5 100644 --- a/mealie/services/backups_v2/alchemy_exporter.py +++ b/mealie/services/backups_v2/alchemy_exporter.py @@ -3,25 +3,23 @@ import uuid from logging import Logger from os import path -from pathlib import Path from textwrap import dedent from typing import Any +from alembic import command +from alembic.config import Config from fastapi.encoders import jsonable_encoder from pydantic import BaseModel from sqlalchemy import Connection, ForeignKey, ForeignKeyConstraint, MetaData, Table, create_engine, insert, text from sqlalchemy.engine import base from sqlalchemy.orm import sessionmaker -from alembic import command -from alembic.config import Config from mealie.db import init_db from mealie.db.fixes.fix_migration_data import fix_migration_data +from mealie.db.init_db import ALEMBIC_DIR from mealie.db.models._model_utils.guid import GUID from mealie.services._base_service import BaseService -PROJECT_DIR = Path(__file__).parent.parent.parent.parent - class ForeignKeyDisabler: def __init__(self, connection: Connection, dialect_name: str, *, logger: Logger | None = None): @@ -193,15 +191,12 @@ def restore(self, db_dump: dict) -> None: alembic_data = db_dump["alembic_version"] alembic_version = alembic_data[0]["version_num"] - alembic_cfg_path = os.getenv("ALEMBIC_CONFIG_FILE", default=str(PROJECT_DIR / "alembic.ini")) + alembic_cfg_path = os.getenv("ALEMBIC_CONFIG_FILE", default=str(ALEMBIC_DIR / "alembic.ini")) if not path.isfile(alembic_cfg_path): raise Exception("Provided alembic config path doesn't exist") alembic_cfg = Config(alembic_cfg_path) - # alembic's file resolver wants to use the "mealie" subdirectory when called from within the server package - # Just override this to use the correct migrations path - alembic_cfg.set_main_option("script_location", path.join(PROJECT_DIR, "alembic")) command.upgrade(alembic_cfg, alembic_version) del db_dump["alembic_version"] diff --git a/pyproject.toml b/pyproject.toml index 73c86eca939..0171889c925 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -158,8 +158,8 @@ select = [ [tool.ruff.lint.per-file-ignores] "__init__.py" = ["E402", "E501"] -"alembic/versions/2022*" = ["E501"] -"alembic/versions/2023*" = ["E501"] +"mealie/alembic/versions/2022*" = ["E501", "I001"] +"mealie/alembic/versions/2023*" = ["E501", "I001"] "dev/scripts/all_recipes_stress_test.py" = ["E501"] "ldap_provider.py" = ["UP032"] "tests/conftest.py" = ["E402"] diff --git a/tests/utils/alembic_reader.py b/tests/utils/alembic_reader.py index 2bba446f456..e8fda449436 100644 --- a/tests/utils/alembic_reader.py +++ b/tests/utils/alembic_reader.py @@ -2,9 +2,9 @@ import pathlib from functools import lru_cache -from mealie.db.init_db import PROJECT_DIR +from mealie.db.init_db import ALEMBIC_DIR -ALEMBIC_MIGRATIONS = PROJECT_DIR / "alembic" / "versions" +ALEMBIC_MIGRATIONS = ALEMBIC_DIR / "versions" def import_file(module_name: str, file_path: pathlib.Path):