News for hackers. Stuff that matters.
Re:Speeding Up PostgreSQL with Partial Indexes by sanderjd on Wednesday December 10, 2014 @05:30PM (#8732133)
There's a simple solution to this:

    config.active_record.schema_format = :sql
In my opinion, this should be the default. I'm really not sure what advantage the schema DSL in schema.rb has over the ability to express the full schema in its native tongue.

Edit: Just saw your edit. This[0] may have been the problem you had with using :sql as the schema format. The counter-intuitive workaround is to output ruby in production. It seems weird, but doesn't hurt anything.

[0]: http://stackoverflow.com/questions/17300341/migrate-not-work...

Re:Speeding Up PostgreSQL with Partial Indexes by ikawe on Wednesday December 10, 2014 @05:58PM (#8732248)
> I'm really not sure what advantage the schema DSL in schema.rb has over the ability to express the full schema in its native tongue.

I always end up using the sql format, because sooner or later I do something remotely non-trivial in postgres. But I'll try to answer your implicit question...

schema.rb works just fine for sufficiently simple schema, it's easier to make sense of in version control, and it's backend agnostic, so if someone wants to develop the app on sqlite - that's just fine.

Of course, all these things become a downside when your setup is sufficiently complex - but if you are not using any interesting database features it's fine. In particular, I would almost never recommend developing against a different DB than you are deploying on. Sooner or later you'll be bit by a behavioral difference.

Re:Speeding Up PostgreSQL with Partial Indexes by andrewvc on Wednesday December 10, 2014 @07:16PM (#8732517)
To add to this, the schema.rb or structure.sql files rails makes are never 'accurate'. By which I mean, they simply record the state of the database at the time of the last migration. If you are switching between branches, for instance, it will have columns from both branches.

We gitignore schema.rb because it is really useless. It's a performance optimization that causes more trouble than its worth.