peewee_migrate2 icon indicating copy to clipboard operation
peewee_migrate2 copied to clipboard

Add constraints

Open Nathan-Riviere opened this issue 3 years ago • 2 comments

Hi,

Is it possible to add the constraints? I have in my model :

class Test(BaseModel): id = PrimaryKeyField(unique=True) quantity = IntegerField(constraints=[Check('quantity > 0')])

And in my migration :

class Test(BaseModel): id = PrimaryKeyField(unique=True) quantity = IntegerField()

My constraint is ignored by the migration module.

Thanks.

Nathan-Riviere avatar Apr 26 '21 17:04 Nathan-Riviere

Hi. Sure, i will check it

spumer avatar Apr 26 '21 17:04 spumer

Thanks,

Another alternative for setting constraints is as follows:

class Test(BaseModel): -id = PrimaryKeyField(unique=True) -quantity = IntegerField() -class Meta: --constraints = [Check('quantity > 0')]

Nathan-Riviere avatar Apr 26 '21 18:04 Nathan-Riviere