Skip to content

Instantly share code, notes, and snippets.

@gam0022
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gam0022/ee84c31e0bebb57d6ed1 to your computer and use it in GitHub Desktop.
Save gam0022/ee84c31e0bebb57d6ed1 to your computer and use it in GitHub Desktop.
change_column で 型を integer や boolean に変更すると失敗する問題の解決方法 ref: http://qiita.com/gam0022/items/a73910de5b8eb44e5b13
[~/RubymineProjects/drwallet]$ rake db:migrate
== ChangeColumnsToCreditCards: migrating =====================================
-- change_column(:credit_cards, :etc_issuance, :boolean)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::Error: ERROR: column "etc_issuance" cannot be cast automatically to type boolean
HINT: Specify a USING expression to perform the conversion.
: ALTER TABLE "credit_cards" ALTER COLUMN "etc_issuance" TYPE boolean/Users/gam0022/RubymineProjects/drwallet/db/migrate/20150206071431_change_columns_to_credit_cards.rb:3:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
-change_column :table_name, :column_name, :integer
+change_column :table_name, :column_name, 'integer USING CAST(column_name AS integer)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment