diff --git a/backend/db/migrate/20260107034300_make_title_nullable_in_posts.rb b/backend/db/migrate/20260107034300_make_title_nullable_in_posts.rb new file mode 100644 index 0000000..80e6858 --- /dev/null +++ b/backend/db/migrate/20260107034300_make_title_nullable_in_posts.rb @@ -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 + diff --git a/backend/db/schema.rb b/backend/db/schema.rb index 697bd8f..94e40d6 100644 --- a/backend/db/schema.rb +++ b/backend/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_12_30_143400) do +ActiveRecord::Schema[8.0].define(version: 2026_01_07_034300) do create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false @@ -84,7 +84,7 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_30_143400) do end create_table "posts", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| - t.string "title", null: false + t.string "title" t.string "url", limit: 2000, null: false t.string "thumbnail_base", limit: 2000 t.bigint "parent_id"