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

--auto creates invalid Python file #16

Open
dev-zero opened this issue Jul 7, 2016 · 2 comments
Open

--auto creates invalid Python file #16

dev-zero opened this issue Jul 7, 2016 · 2 comments

Comments

@dev-zero
Copy link

dev-zero commented Jul 7, 2016

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.

@dev-zero
Copy link
Author

dev-zero commented Jul 7, 2016

the same goes for the rollback which contains the following invalid lines:

    migrator.remove_model('model')

    migrator.remove_model('basemodel')

@Thorbijoern
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants