Navigation Menu

Skip to content

Commit

Permalink
Fixed mysql/mariadb issue (Mysql2::Error: Invalid default value for '…
Browse files Browse the repository at this point in the history
…initialized_at').
  • Loading branch information
martini authored and znuny-robo committed Oct 25, 2018
1 parent f074c0c commit dd583d7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion db/migrate/20181017000001_cti_generic_api2.rb
Expand Up @@ -6,7 +6,14 @@ def up
return if !column_exists?(:cti_logs, :initialized_at)
return if column_exists?(:cti_logs, :initialized_at_cleanup)

add_column :cti_logs, :initialized_at_cleanup, :timestamp, limit: 3, null: true
if ActiveRecord::Base.connection_config[:adapter] == 'mysql2'
# disable the MySQL strict_mode for the current connection
execute("SET sql_mode = ''")
add_column :cti_logs, :initialized_at_cleanup, :timestamp, limit: 3, null: true, default: '0000-00-00 00:00:00'
else
add_column :cti_logs, :initialized_at_cleanup, :timestamp, limit: 3, null: true
end

Cti::Log.connection.schema_cache.clear!
Cti::Log.reset_column_information

Expand Down

0 comments on commit dd583d7

Please sign in to comment.