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

Table prefixes are not picked up by autogenerate #721

Closed
CaselIT opened this issue Aug 6, 2020 · 4 comments
Closed

Table prefixes are not picked up by autogenerate #721

CaselIT opened this issue Aug 6, 2020 · 4 comments
Labels
autogenerate - detection autogenerate - rendering good first issue Good for newcomers use case not quite a feature and not quite a bug, something we just didn't think of

Comments

@CaselIT
Copy link
Member

CaselIT commented Aug 6, 2020

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!

@CaselIT CaselIT added good first issue Good for newcomers autogenerate - detection autogenerate - rendering use case not quite a feature and not quite a bug, something we just didn't think of labels Aug 6, 2020
@rmoretto
Copy link
Contributor

rmoretto commented Sep 5, 2020

If no one is working in this issue I would like to contribute!

@CaselIT
Copy link
Member Author

CaselIT commented Sep 5, 2020

I don't think anyone is working on it. If you could contribute a pr it would be great!

rmoretto added a commit to rmoretto/alembic that referenced this issue Sep 5, 2020
…eter and add it to the 'create table' render if it exists
@sqla-tester
Copy link
Collaborator

rmoretto has proposed a fix for this issue in the master branch:

Added detection of Table prefixes in the create table render https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/2212

@markfickett
Copy link

For posterity, fixed in alembic==1.5.0 per release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autogenerate - detection autogenerate - rendering good first issue Good for newcomers use case not quite a feature and not quite a bug, something we just didn't think of
Projects
None yet
Development

No branches or pull requests

4 participants