piccolo
piccolo copied to clipboard
Migrations don't use db_column_name when performing ALTERs
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
Thanks for reporting this - seems like a bug.