Skip to content

SQL Server: Possible to tell Alembic to ignore sa.Identity(always=True)? #1533

Closed Answered by CaselIT
abceleung asked this question in Usage Questions
Discussion options

You must be logged in to vote

I'm suggesting something like

def include_object(
    object,
    name,
    type_,
    reflected,
    compare_to,
):
    if os.getenv("sqlalchemy_connection_string","").startswith("mssql") and type_ == "column" and reflected:
        if object.info.get("alembic_normalize_identity", "") == "sql_server" and object.identity and object.identity.always is False:
            object.identity.always=True
    return True

I haven't tried it, but this should make the identity compare equally

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@CaselIT
Comment options

@abceleung
Comment options

@CaselIT
Comment options

Answer selected by abceleung
@abceleung
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants