Skip to content

Add Alembic support sqlalchemy 2.0 #77

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

Closed
wants to merge 2 commits into from
Closed

Conversation

Mac3g0d
Copy link

@Mac3g0d Mac3g0d commented Jun 19, 2025

copy
#20
from @abdalazizrashid

with passed codestyle but not fully tested
for base case like simple table with strings, ints, and uuidv7 as primary_key its works fine

Виктор Жирнов added 2 commits June 19, 2025 18:46
@vgvoleg
Copy link
Collaborator

vgvoleg commented Jul 9, 2025

Hi! have you followed instructions described here? alembic works fine with them
https://github.com/ydb-platform/ydb-sqlalchemy/tree/main/examples/alembic

@Mac3g0d
Copy link
Author

Mac3g0d commented Jul 13, 2025

Hi! have you followed instructions described here? alembic works fine with them https://github.com/ydb-platform/ydb-sqlalchemy/tree/main/examples/alembic

Hi @vgvoleg!
Sorry, I made a mistake.
The problem is as follows: if you specify a naming convention in the metadata that you set in the Base class and then pass it to other classes, SQLAlchemy thinks that the field is a primary key and tries to generate a string like
PRIMARY KEY ...

Here is an example of the base class code that breaks the YQL dialect:

convention = {
    "ix": "ix_%(column_0_label)s",
    "uq": "uq_%(table_name)s_%(column_0_name)s",
    "ck": "ck_%(table_name)s_%(constraint_name)s",
    "fk": "fk_%(table_name)s_%(column_0_name)s_%(referred_table_name)s",
    "pk": "pk_%(table_name)s",
}

class Base(DeclarativeBase):
    __abstract__ = True

    metadata = MetaData(naming_convention=convention)

I solved my problem, I will cancel the PR, but probably this case should be recorded as a bug.

@Mac3g0d Mac3g0d closed this Jul 13, 2025
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.

2 participants