Migration errors when upgrading (gitlab-ee, mysql)

Hi,

When attempting to upgrade from ee-9.5.10 to ee-10.8.7 I got the following when running db migrations

#<ActiveRecord::StatementInvalid: Mysql2::Error: Incorrect datetime value: '2017-04-
10T12:43:19.000-07:00' for column 'authored_date' at row 1:         INSERT INTO 
merge_request_diff_commits (`message`, `authored_date`

authored_date is a timestamp

UPDATE: going from 10.2.8 to 10.3.0 is where I first get a migration error (see reply below)

Upgrading to 10.3.0 from 10.2.8 is where the first migration error happens

    == 20171106150657 IssuesUpdatedByIdForeignKey: migrating ======================rake aborted!
    StandardError: An error has occurred, all later migrations canceled:

    Mysql2::Error: You can't specify target table 'issues' for update in FROM clause: UPDATE `issues` SET `issues`.`moved_to_id` = NULL WHERE (NOT EXISTS (SELECT true FROM issues WHERE issues.id = issues.moved_to_id)) AND (moved_to_id IS NOT NULL) AND (`issues`.`id` >= 26)
    /opt/gitlab/embedded/service/gitlab-rails/config/initializers/connection_fix.rb:20:in `execute'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb:25:in `block in up'
    /opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:75:in `block in each_batch'
    /opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:56:in `step'
    /opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:56:in `each_batch'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb:24:in `up'
    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:50:in `block (3 levels) in <top (required)>'
    /opt/gitlab/embedded/bin/bundle:23:in `load'
    /opt/gitlab/embedded/bin/bundle:23:in `<main>'

    Caused by:
    ActiveRecord::StatementInvalid: Mysql2::Error: You can't specify target table 'issues' for update in FROM clause: UPDATE `issues` SET `issues`.`moved_to_id` = NULL WHERE (NOT EXISTS (SELECT true FROM issues WHERE issues.id = issues.moved_to_id)) AND (moved_to_id IS NOT NULL) AND (`issues`.`id` >= 26)
    /opt/gitlab/embedded/service/gitlab-rails/config/initializers/connection_fix.rb:20:in `execute'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb:25:in `block in up'
    /opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:75:in `block in each_batch'
    /opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:56:in `step'
    /opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:56:in `each_batch'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb:24:in `up'
    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:50:in `block (3 levels) in <top (required)>'
    /opt/gitlab/embedded/bin/bundle:23:in `load'
    /opt/gitlab/embedded/bin/bundle:23:in `<main>'

    Caused by:
    Mysql2::Error: You can't specify target table 'issues' for update in FROM clause
    /opt/gitlab/embedded/service/gitlab-rails/config/initializers/connection_fix.rb:20:in `execute'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb:25:in `block in up'
    /opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:75:in `block in each_batch'
    /opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:56:in `step'
    /opt/gitlab/embedded/service/gitlab-rails/app/models/concerns/each_batch.rb:56:in `each_batch'
    /opt/gitlab/embedded/service/gitlab-rails/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb:24:in `up'
    /opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:50:in `block (3 levels) in <top (required)>'
    /opt/gitlab/embedded/bin/bundle:23:in `load'
    /opt/gitlab/embedded/bin/bundle:23:in `<main>'
    Tasks: TOP => db:migrate
    (See full trace by running task with --trace)

possible workaround: https://stackoverflow.com/a/32528947