corridor/sqlalchemy-history

When I use sa.Identity() in my table - sqla-history version table doesnt work with alembic

AbdealiLoKo opened this issue · 1 comments

If I have a table like:

import sqlalchemy as sa
from sqlalchemy.ext.declarative import declarative_base

Base = declarative_base()

class Article(Base):
    __tablename__ = 'article'

    id = sa.Column(sa.Integer, sa.Identity(), primary_key=True, autoincrement=True)
    name = sa.Column(sa.String(255))

When I add __versioned__ = {} to add it to sqla-history, I get the following issue with alembic autogeneration:

sqlalchemy.exc.ArgumentError: A column with an Identity object cannot specify autoincrement=False

It looks like the issue is related to when sqla-history is copying the table, the autoincrement flag is being set to False
But then sqlalchemy cannot handle cases where autoincrement is False + Identity() is provided
https://github.com/corridor/sqlalchemy-history/blob/v2.0.0/sqlalchemy_history/table_builder.py#L30

And the confusing is arising because: