ぼざクリタグ広場 https://hub.nizika.monster
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

29 lines
424 B

  1. class MakeTitleNullableInPosts < ActiveRecord::Migration[7.0]
  2. def up
  3. change_column_null :posts, :title, true
  4. execute <<~SQL
  5. UPDATE
  6. posts
  7. SET
  8. title = NULL
  9. WHERE
  10. title = ''
  11. SQL
  12. end
  13. def down
  14. execute <<~SQL
  15. UPDATE
  16. posts
  17. SET
  18. title = ''
  19. WHERE
  20. title IS NULL
  21. SQL
  22. change_column_null :posts, :title, false
  23. end
  24. end