diff options
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb index 43d513e293..38e6d853d6 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb @@ -108,7 +108,7 @@ module ActiveRecord def native_database_types #:nodoc: { - :primary_key => "INTEGER PRIMARY KEY NOT NULL", + :primary_key => default_primary_key_type, :string => { :name => "varchar", :limit => 255 }, :text => { :name => "text" }, :integer => { :name => "integer" }, @@ -351,6 +351,14 @@ module ActiveRecord def sqlite_version @sqlite_version ||= select_value('select sqlite_version(*)') end + + def default_primary_key_type + if sqlite_version >= '3.1.0' + 'INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL'.freeze + else + 'INTEGER PRIMARY KEY NOT NULL'.freeze + end + end end class SQLite2Adapter < SQLiteAdapter # :nodoc: |