Skip to content

Table prefixes are not picked up by autogenerate #721

Description

@CaselIT

Describe the bug
Currently sqlalchemy Table.prefixes are not picked up by alembic when generating a migration using
alembic revision --autogenerate
Expected behavior
The prefixes are picked up by alembic. I've not tested it with other table keyboard, but maybe it's a more common theme.

To Reproduce
Please try to provide a Minimal, Complete, and Verifiable example, with the migration script and/or the SQLAlchemy tables or models involved.
See also Reporting Bugs on the website.

# Add a new table like this one to the metadata
import sqlalchemy as sa

sa.Table(
    "foo",
    metadata,
    sa.Column("id", sa.Integer(), primary_key=True),
    sa.Column("other", sa.Integer),
    prefixes=["UNLOGGED"],
)

Error

# The reflected migration code generated is
def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table(
        "foo",
        sa.Column("id", sa.Integer(), nullable=False),
        sa.Column("other", sa.Integer(), nullable=True),
        sa.PrimaryKeyConstraint("id"),
    )
    # ### end Alembic commands ###

Versions.

  • OS: windows
  • Python: 3.7.7
  • Alembic: 1.4.2
  • SQLAlchemy: 1.3.18
  • Database: postgres
  • DBAPI: pycopg2

Additional context
Manually adding prefixes=[...] to the create_table function after autogenerate does work correctly, so this is just a nice to have feature

Have a nice day!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions