Migrations that set default values

To reverse a migration that sets a default value, do you set the default
to nil?

And, if you’re setting a couple of default values just to make early
development easier, is it best to do that directly to the database and
not clutter your migrations with them? (I.e., it’s not a real db
change.)

Thanks,

Austin G.
Thinking & Making: IA, UX, and IxD
http://thinkingandmaking.com
[email protected]

Austin G. wrote:

To reverse a migration that sets a default value, do you set the default
to nil?

And, if you’re setting a couple of default values just to make early
development easier, is it best to do that directly to the database and
not clutter your migrations with them? (I.e., it’s not a real db
change.)

Thanks,

Austin G.
Thinking & Making: IA, UX, and IxD
http://thinkingandmaking.com
[email protected]

You should be able to just supply the “:default => nil” option but the
last few times I tried that MySQL complained loudly about some SQL
error.

As for migrations, don’t put anything in them you wouldn’t want done to
your production database, because that is where they ultimately go. If
you want default values for testing, put them in fixtures. If you want
to use them development mode through your browser, insert them directly
or via the console with “Model.create(:foo => ‘bar’)”

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs