提交 6a34ef52 编写于 作者: R Ryuta Kamizono

Fix CI failure due to invalid `up_only` for MySQL

`oldie = 'true'` to `tinyint(1)` column is invalid value for MySQL:

```
Mysql2::Error: Incorrect integer value: 'true' for column 'oldie' at row 1: update horses set oldie = 'true'
```
上级 ca68f1cf
......@@ -163,11 +163,13 @@ def change
class UpOnlyMigration < SilentMigration
def change
add_column :horses, :oldie, :boolean, default: false
up_only { execute "update horses set oldie = 'true'" }
add_column :horses, :oldie, :integer, default: 0
up_only { execute "update horses set oldie = 1" }
end
end
self.use_transactional_tests = false
setup do
@verbose_was, ActiveRecord::Migration.verbose = ActiveRecord::Migration.verbose, false
end
......@@ -389,14 +391,14 @@ def test_migrate_revert_add_index_with_name
def test_up_only
InvertibleMigration.new.migrate(:up)
horse1 = Horse.create
# populates existing horses with oldie=true but new ones have default false
# populates existing horses with oldie = 1 but new ones have default 0
UpOnlyMigration.new.migrate(:up)
Horse.reset_column_information
horse1.reload
horse2 = Horse.create
assert horse1.oldie? # created before migration
assert !horse2.oldie? # created after migration
assert 1, horse1.oldie # created before migration
assert 0, horse2.oldie # created after migration
UpOnlyMigration.new.migrate(:down) # should be no error
connection = ActiveRecord::Base.connection
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册