LoginSignup
0
0

More than 5 years have passed since last update.

【Rails】 DBのcolumnをstringからintegerにする方法

Last updated at Posted at 2019-02-22

Railsでchange_columnを使用し、string→integerにする時につまったのでメモ

...
  def up
    change_column :table_name, :column_name, 'integer USING CAST(column_name AS integer)'
  end

  def down
    change_column :table_name, :column_name, :string
  end
...
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0