lomba/schema_plus — pull request #51 by lukesaunders (2012-01-28 13:31:36+00:00)
Title: Add support for allowing column SQL expression defaults in the database

For example in PostgreSQL it's sometimes desirable to have datetime columns default to the current time, so the database schema should reflect this with default NOW().

The following syntaxes are supported in migrations and schema files and are correctly parsed from the database when dumping the schema:

```ruby
# default to NOW() in PostgreSQL, DATETIME('now') in SQLite and raises
# an exception in MySQL as MySQL does not support this in DATETIME columns
:default => :now

# use arbitrary SQL for databases that allow it
:default => { :expr => 'ARBITRARY_SQL' }

# same as :default => :now
:default => { :expr => :now }

# same as standard :default => 'value' behaviour
:default => { :value => 'standard default value' }
```

In MySQL there is no clear way to achieve these defaults using a DATETIME column. Perhaps support for the TIMESTAMP column could be added in the future which allows the default of CURRENT_TIMESTAMP, but this is out of the scope of this patch.