rails/rails — pull request #16127 by Envek (2014-07-10 17:39:20+00:00)
Title: Dump PostgreSQL primary key with custom function as a default.

Fixes #16111. See it for more information.

For example, if I use pgcrypto extension in PostgreSQL 9.4 beta 1, where uuid-ossp extension isn't available for moment of writing, and thus required to use a gen_random_uuid() method as a primary key default.

In this case schema dumper wasn't able to correctly reconstruct create_table statement and lost primary key constraint on schema load.

If I create migration in PostgreSQL 9.4 beta 1 as:

```ruby
enable_extension 'pgcrypto'
create_table "pg_uuids", id: :uuid, default: "gen_random_uuid()", force: true do |t|
t.string "name"
t.uuid "other_uuid", default: "gen_random_uuid()"
end
```

Schema dumper currently dumps it as this:

```ruby
create_table "pg_uuids", id: false, force: true do |t|
t.uuid "id", default: "gen_random_uuid()", null: false
t.string "name"
t.uuid "other_uuid", default: "gen_random_uuid()"
end
```

Instead of this:

```ruby
create_table "pg_uuids", id: :uuid, default: "gen_random_uuid()", force: true do |t|
t.string "name"
t.uuid "other_uuid", default: "gen_random_uuid()"
end
```

What about to also backport it to 4-1-stable?