klen / peewee_migrate

Simple migration engine for Peewee

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use pw.SQL instead of SQL in migration files

mekanix opened this issue · comments

Given the following simple model, generated migration has a typo:

class User(BaseModel):
    active = BooleanField(default=True)

Migration I get (the relevant part):

@migrator.create_model                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
class User(pw.Model):                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    id = pw.AutoField()                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    active = pw.BooleanField(constraints=[SQL("DEFAULT True")])                        

This fails, but replacing SQL with pw.SQL works like a charm. I can't find the code which generates it, so if you help me debug this issue, I'll be happy to send PR.

commented

Hello, I have faced the same question too. I wonder if there is a normal way to solve the problem. Now I use the same way like you to deal with it but I hope a better solution.