From 491b4a3c84194931de51c3331b028dcfcb606074 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Fri, 12 May 2006 03:59:43 +0000 Subject: 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 --- .../active_record/connection_adapters/postgresql_adapter.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'activerecord/lib') 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 -- cgit v1.2.3