diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-05-12 03:59:43 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-05-12 03:59:43 +0000 |
commit | 491b4a3c84194931de51c3331b028dcfcb606074 (patch) | |
tree | 7bef62758c05ccad52e63cf9955daca2a8c81f04 /activerecord/lib/active_record/connection_adapters | |
parent | c069f361f090790b9769b349eefa260e57d4c63b (diff) | |
download | rails-491b4a3c84194931de51c3331b028dcfcb606074.tar.gz rails-491b4a3c84194931de51c3331b028dcfcb606074.tar.bz2 rails-491b4a3c84194931de51c3331b028dcfcb606074.zip |
PostgreSQL: migrations support :limit with :integer columns by mapping limit < 4 to smallint, > 4 to bigint, and anything else to integer. Closes #2900.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4335 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index c3b076fe73..a9c140f27a 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -339,6 +339,18 @@ module ActiveRecord execute "DROP INDEX #{index_name(table_name, options)}" end + def type_to_sql(type, limit = nil) #:nodoc: + return super unless type.to_s == 'integer' + + if limit.nil? || limit == 4 + 'integer' + elsif limit < 4 + 'smallint' + else + 'bigint' + end + end + private BYTEA_COLUMN_TYPE_OID = 17 TIMESTAMPOID = 1114 |