I have written every single table in IGNORE_TABLES to exclude the table from alembic revision --autogenerate, didn't found any automated solution, which auto detects the tables not included in target_metadata = Base.metadata, and exclude them from migration.

IGNORE_TABLES = ["django_migrations", "django_content_type", "django_admin_log", "auth_group", "auth_group_permissions",
                 "django_session", "oms_role", "oms_user", "oms_entitymodel", "oms_user_group", "oms_user_roles",
                 "enterprise_company", "enterprise_branch", "enterprise_department", "enterprise_designation",
                 "enterprise_designationattachment", "oms_user_user_permissions", "oms_tenantconfiguration",
                 "oms_microservicesconfig", "oms_user_groups", "enterprise_section", "employee_employmentmodel",
                 "oms_tenantconfiguration_micro_services", "employee_employee_employment_model", "auth_permission"]


def include_object(object, name, type_, reflected, compare_to):
    if type_ == 'table' and name in IGNORE_TABLES:
        return False
    return True

Tried the include_object in run_migrations_offline and run_migrations_online, want to find the automated solution.

0

There are 0 best solutions below