piccolo icon indicating copy to clipboard operation
piccolo copied to clipboard

Migrations don't use db_column_name when performing ALTERs

Open theelderbeever opened this issue 3 years ago • 1 comments

This specifically showed up when adding an index on a column.

class MyTable(Table):
  # Column shares name with reserved name so we use `db_column_name`
  # Initial creation migration works fine
  from_address = Text(db_column_name="from")

Needed an index on the column

class MyTable(Table):
  from_address = Text(index=True, db_column_name="from")

Autogenerate the migration and note that the column_name uses the class attribute name not the alias.

    manager.alter_column(
        table_class_name="MyTable",
        tablename="mytable",
        column_name="from_address",
        params={"index": True},
        old_params={"index": False},
        column_class=Text,
        old_column_class=Text,
    )

Python Version: 3.10.2 Piccolo Version: 0.74.0

theelderbeever avatar May 16 '22 18:05 theelderbeever

Thanks for reporting this - seems like a bug.

dantownsend avatar May 17 '22 12:05 dantownsend