klen / peewee_migrate

Simple migration engine for Peewee
MIT License
352 stars 86 forks source link

Incorrect index drop/remove syntax #230

Open dmwyatt opened 9 months ago

dmwyatt commented 9 months ago

I'm getting auto-generated migrations with lines like this:

migrator.drop_index('schoolsport', 'school', 'sport')

migrator.add_index('schoolsport', <Model: School>, 'sport', unique=True)

Note the <Model: School>...the default repr generated by peewee. It's not even wrapped in quotes, it's just this text making these migration files invalid python.

Because this only started happening after I refactored my models into multiple modules in a package rather than all in one module, I'm guessing it's somehow related to model discovery? The other thing is, is that there's no reason for it to be dropping these indexes...I haven't changed them.

I don't mind working on a PR if anyone can give me some pointers to where the likely culprit of this is. I don't have time at this very moment to work on a repro, but I will soon if no one has an idea of what's going on.