Skip to content

Commit

Permalink
add bigserial pk support
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Oct 30, 2014
1 parent f9d4b50 commit 6dc1787
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Expand Up @@ -78,6 +78,7 @@ class PostgreSQLAdapter < AbstractAdapter

NATIVE_DATABASE_TYPES = {
primary_key: "serial primary key",
bigserial: "bigserial",
string: { name: "character varying" },
text: { name: "text" },
integer: { name: "integer" },
Expand Down
2 changes: 2 additions & 0 deletions activerecord/lib/active_record/schema_dumper.rb
Expand Up @@ -118,6 +118,8 @@ def table(table, stream)
if pkcol
if pk != 'id'
tbl.print %Q(, primary_key: "#{pk}")
elsif pkcol.sql_type == 'bigint'
tbl.print ", id: :bigserial"
elsif pkcol.sql_type == 'uuid'
tbl.print ", id: :uuid"
tbl.print %Q(, default: "#{pkcol.default_function}") if pkcol.default_function
Expand Down
20 changes: 20 additions & 0 deletions activerecord/test/cases/adapters/postgresql/uuid_test.rb
Expand Up @@ -110,6 +110,26 @@ def test_uuid_formats
end
end

class PostgresqlLargeKeysTest < ActiveRecord::TestCase
include PostgresqlUUIDHelper
def setup
connection.create_table('big_serials', id: :bigserial) do |t|
t.string 'name'
end
end

def test_omg
schema = StringIO.new
ActiveRecord::SchemaDumper.dump(connection, schema)
assert_match "create_table \"big_serials\", id: :bigserial, force: true",
schema.string
end

def teardown
drop_table "big_serials"
end
end

class PostgresqlUUIDGenerationTest < ActiveRecord::TestCase
include PostgresqlUUIDHelper

Expand Down

0 comments on commit 6dc1787

Please sign in to comment.