How to constrain range using beego orm

100 Views Asked by At

I would like to constrain an attribute to a certain range using beego orm, similar to

CHECK(“column” >= 0 AND “column” <= 10)

in the table setup. Can I do this with beego, and if yes, how?

1

There are 1 best solutions below

0
On

The command doesn't seem to give any options for inserting CHECK, it's quite an esoteric SQL command, and there is no hint of it in the source at getDbCreateSQL or the docs.

I suggest you just create your tables with SQL instead and insert the sql you have above, this should be a one-time task so not too onerous.