Sha256: 5de570722d261489da0a8745977914f4b381806390b8acfc4f9500b710028a09
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
desc 'see comment below for error message' task :converting_boolean_to_integer do ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 1) ExampleModel.where("boolean_column = 'f'").update_all(boolean_column: 0) end # DEPRECATION WARNING: Leaving `ActiveRecord::ConnectionAdapters::SQLite3Adapter.represent_boolean_as_integer` # set to false is deprecated. SQLite databases have used 't' and 'f' to serialize # boolean values and must have old data converted to 1 and 0 (its native boolean # serialization) before setting this flag to true. Conversion can be accomplished # by setting up a rake task which runs # ExampleModel.where("boolean_column = 't'").update_all(boolean_column: 1) # ExampleModel.where("boolean_column = 'f'").update_all(boolean_column: 0) # for all models and all boolean columns, after which the flag must be set to # true by adding the following to your application.rb file: # Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true # (called from <top (required)> at /Users/bperlik/code/bloc/whodat/spec/rails_helper.rb:31)
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
whodat-1.0.1 | lib/tasks/boolean_as_integer.rake |
whodat-1.0.0 | lib/tasks/boolean_as_integer.rake |