loading...

re: Postgres enums with Rails VIEW POST

TOP OF THREAD FULL DISCUSSION
re: Everything is great until we will need to add value to your enumeration You can define your enums as a hash to make the mapping explicit, then AR...
 

Also if storage size is an issue then you can add the limit: option to the migration, which let's you select integer sizes:

gist.github.com/stream7/1069589/e0...

So in your example something like:

t.integer :status, null: false, limit: 1

On MySQL this will become a tinyint (1 byte) and on Postgres a smallint (2 bytes). Of course this doesn't solve the problem of enum values not being meaningful outside the app context.

code of conduct - report abuse