【发布时间】:2018-02-07 09:26:33
【问题描述】:
我想通过迁移更改字符串列的大小。
我试过了
Sequel.migration do
up do
alter_table(:users) do
set_column_type :car_model, :string, size: 30
end
end
down do
end
end
但这给了我一个 SQL 语法错误迁移:
Sequel::DatabaseError: 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 'String(30) NULL' at line 1
有什么办法吗? 所以目前该字段是一个大小为 20 的字符串,我想将其设为大小为 30 的字符串。
提前致谢!
更新 我也试过了
set_column_type :car_model, char(30)
然而,这导致我得到一个String :car_model, :size=>255 列:/
【问题讨论】:
-
您需要保存任何数据吗?
-
这样最好:)
-
您可以随时编写原始 sql 来修改该列