Fix. db:migrate is failed on MySQL 8

```
StandardError: An error has occurred, all later migrations canceled:

Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'system = true AND note LIKE '\_%\_'' at line 1: UPDATE notes SET note = trim(both '_' from note) WHERE system = true AND note LIKE '\_%\_'
```
This commit is contained in:
sue445 2019-05-16 17:19:17 +09:00
parent e8fe08fca2
commit 9618141dc7
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
title: Fix. `db:migrate` is failed on MySQL 8
merge_request: 28351
author: sue445
type: fixed

View file

@ -7,7 +7,8 @@
# mentioned in 54f7727c850972f0401c1312a7c4a6a380de5666
class ConvertLegacyReferenceNotes < ActiveRecord::Migration[4.2]
def up
execute %q{UPDATE notes SET note = trim(both '_' from note) WHERE system = true AND note LIKE '\_%\_'}
quoted_column_name = ActiveRecord::Base.connection.quote_column_name('system')
execute %Q{UPDATE notes SET note = trim(both '_' from note) WHERE #{quoted_column_name} = true AND note LIKE '\_%\_'}
end
def down