This commit is contained in:
2026-01-07 03:52:09 +09:00
parent 5160aacc53
commit 65b1af17c9
2 changed files with 30 additions and 2 deletions
@@ -0,0 +1,28 @@
class MakeTitleNullableInPosts < ActiveRecord::Migration[7.0]
def up
change_column_null :posts, :title, true
execute <<~SQL
UPDATE
posts
SET
title = NULL
WHERE
title = ''
SQL
end
def down
execute <<~SQL
UPDATE
posts
SET
title = ''
WHERE
title IS NULL
SQL
change_column_null :posts, :title, false
end
end