Add Timestamps to Existing Tables in Rails
Have you ever gotten deep into a Rails project before realizing that you forgot to add timestamps to some (or all) of your tables? Yes, me too. We all have. Adding them to a few tables is not so bad, but if you have a huge schema file, doing all the digging and column adding can be a pain.
I wrote a short & sweet database migration that will find all tables lacking
updated_at, and add those accordingly.
You can check out the gist here.
I originally thought about turning this into gem, but that's probably overkill. One caveat is that this doesn't include
null: false. I ran into errors when adding that (specifically on
schema_migrations), so if you wanted to add the
null option, you may have to skip that table.