Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage subscriptions_search view through SQLalchemy #724

Open
Mark90 opened this issue Jul 29, 2024 · 0 comments
Open

Manage subscriptions_search view through SQLalchemy #724

Mark90 opened this issue Jul 29, 2024 · 0 comments
Labels
maintenance Keeping the framework up to date

Comments

@Mark90
Copy link
Contributor

Mark90 commented Jul 29, 2024

subscriptions_search is a materialized view created manually through a migration. When running alembic's revision it creates the following migration

def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "subscriptions_search",
        sa.Column("subscription_id", sqlalchemy_utils.types.uuid.UUIDType(), nullable=False),
        sa.Column("tsv", sqlalchemy_utils.types.ts_vector.TSVectorType(), nullable=True),
        sa.ForeignKeyConstraint(
            ["subscription_id"],
            ["subscriptions.subscription_id"],
        ),
        sa.PrimaryKeyConstraint("subscription_id"),
    )
    op.create_index(
        op.f("ix_subscriptions_search_subscription_id"), "subscriptions_search", ["subscription_id"], unique=False
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_subscriptions_search_subscription_id"), table_name="subscriptions_search")
    op.drop_table("subscriptions_search")
    # ### end Alembic commands ###

With the following log messages:

2024-07-29 13:14:47 [info     ] Detected added table 'subscriptions_search' [alembic.autogenerate.compare]
2024-07-29 13:14:47 [info     ] Detected added index ''ix_subscriptions_search_subscription_id'' on '('subscription_id',)' [alembic.autogenerate.compare]

This is not correct and should be fixed by preferably modifying orchestrator.db.models.SubscriptionSearchView so that alembic recognizes it as a materialized view. If that is not possible, the model should be excluded from alembic altogether.

@Mark90 Mark90 added the maintenance Keeping the framework up to date label Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Keeping the framework up to date
Projects
None yet
Development

No branches or pull requests

1 participant