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

Limit select on alembic_version to return only version_num #1

Closed
wants to merge 1 commit into from

Conversation

maver1ck
Copy link
Collaborator

I want to use Alembic with Starrocks database.

To achieve this I need to patch alembic_version table with following code

def patch_alembic_version(context, **kwargs):
    migration_context = context._proxy._migration_context
    old_version = migration_context._version
    metadata = old_version.metadata
    metadata.remove(old_version)

    version = Table(
        'alembic_version',
        metadata,
        Column('id', types.BIGINT, autoincrement=True, primary_key=True),
        Column('version_num', types.VARCHAR(32), primary_key=False),
        starrocks_primary_key="id"
    )
    migration_context._version = version

This solution works with one exception - select on alembic_version always read version_num from first column.

Description

Fixes: sqlalchemy#1560

Checklist

This pull request is:

  • A documentation / typographical error fix
    • Good to go, no issue or tests are needed
  • A short code fix
    • please include the issue number, and create an issue if none exists, which
      must include a complete example of the issue. one line code fixes without an
      issue and demonstration will not be accepted.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests. one line code fixes without tests will not be accepted.
  • A new feature implementation
    • please include the issue number, and create an issue if none exists, which must
      include a complete example of how the feature would look.
    • Please include: Fixes: #<issue number> in the commit message
    • please include tests.

Have a nice day!

@maver1ck maver1ck closed this Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make version table customizable by dialects
1 participant