peewee_migrate
peewee_migrate copied to clipboard
`--auto` creates invalid Python file
I tried to use the --auto option to generate the migration files. The result is:
def migrate(migrator, database, fake=False, **kwargs):
"""Write your migrations here."""
@migrator.create_model
class BaseModel(pw.Model):
@migrator.create_model
class BasissetFamily(pw.Model):
name = pw.CharField(max_length=255, unique=True)
@migrator.create_model
class MyModel1(pw.Model):
family = pw.ForeignKeyField(db_column='family_id', rel_model=MyModel1, to_field='id')
element = pw.CharField(max_length=255)
basis = pw.TextField()
@migrator.create_model
class Model(pw.Model):
@migrator.create_model
class MyModel2(pw.Model):
name = pw.CharField(max_length=255, unique=True)
The problem are the empty bodies for the BaseModel and Model classes which is invalid Python.
the same goes for the rollback which contains the following invalid lines:
migrator.remove_model('model')
migrator.remove_model('basemodel')
Your models just seem to be empty... you can ignore models by writing IGNORE=['basemodel'] in a conf.py in your migration directory.
rollback is completely valid python, but the models/tables might not be in the database because they are empty or so