Rails initializers are running while migrating database
If your initializer depends on the creaton of a specific table, one alternative is to check using ActiveRecord::Base.connection.table_exists? :mytable
.
Here is a solution how to prevent an initializer from running in Rake task:
unless ( File.basename($0) == 'rake')
# Initializer code
end