diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20250112025207_widen_blog_body_column.rb | 5 | ||||
-rw-r--r-- | db/migrate/20250512181245_add_latest_post_at_to_stream.rb | 21 | ||||
-rw-r--r-- | db/schema.rb | 5 |
3 files changed, 29 insertions, 2 deletions
diff --git a/db/migrate/20250112025207_widen_blog_body_column.rb b/db/migrate/20250112025207_widen_blog_body_column.rb new file mode 100644 index 0000000..f65aaea --- /dev/null +++ b/db/migrate/20250112025207_widen_blog_body_column.rb | |||
@@ -0,0 +1,5 @@ | |||
1 | class WidenBlogBodyColumn < ActiveRecord::Migration[7.1] | ||
2 | def change | ||
3 | change_column :blogs, :body, :text, limit: 16.megabytes - 1 | ||
4 | end | ||
5 | end | ||
diff --git a/db/migrate/20250512181245_add_latest_post_at_to_stream.rb b/db/migrate/20250512181245_add_latest_post_at_to_stream.rb new file mode 100644 index 0000000..9d753e3 --- /dev/null +++ b/db/migrate/20250512181245_add_latest_post_at_to_stream.rb | |||
@@ -0,0 +1,21 @@ | |||
1 | class AddLatestPostAtToStream < ActiveRecord::Migration[7.1] | ||
2 | def up | ||
3 | add_column :streams, :latest_post_at, :datetime | ||
4 | |||
5 | Stream.all.each do |stream| | ||
6 | if stream.updates.empty? | ||
7 | stream.latest_post_at = stream.created_at | ||
8 | else | ||
9 | stream.latest_post_at = stream.updates.order(created_at: :desc).first.created_at | ||
10 | end | ||
11 | |||
12 | stream.save! | ||
13 | end | ||
14 | |||
15 | change_column_null :streams, :latest_post_at, false | ||
16 | end | ||
17 | |||
18 | def down | ||
19 | remove_column :streams, :latest_post_at, :datetime | ||
20 | end | ||
21 | end | ||
diff --git a/db/schema.rb b/db/schema.rb index b01ed43..76e9ad8 100644 --- a/db/schema.rb +++ b/db/schema.rb | |||
@@ -10,7 +10,7 @@ | |||
10 | # | 10 | # |
11 | # It's strongly recommended that you check this file into your version control system. | 11 | # It's strongly recommended that you check this file into your version control system. |
12 | 12 | ||
13 | ActiveRecord::Schema[7.1].define(version: 2024_12_07_200746) do | 13 | ActiveRecord::Schema[7.1].define(version: 2025_05_12_181245) do |
14 | create_table "active_storage_attachments", force: :cascade do |t| | 14 | create_table "active_storage_attachments", force: :cascade do |t| |
15 | t.string "name", null: false | 15 | t.string "name", null: false |
16 | t.string "record_type", null: false | 16 | t.string "record_type", null: false |
@@ -63,7 +63,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_12_07_200746) do | |||
63 | 63 | ||
64 | create_table "blogs", force: :cascade do |t| | 64 | create_table "blogs", force: :cascade do |t| |
65 | t.string "title" | 65 | t.string "title" |
66 | t.text "body" | 66 | t.text "body", limit: 16777215 |
67 | t.string "slug" | 67 | t.string "slug" |
68 | t.datetime "created_at", precision: nil, null: false | 68 | t.datetime "created_at", precision: nil, null: false |
69 | t.datetime "updated_at", precision: nil, null: false | 69 | t.datetime "updated_at", precision: nil, null: false |
@@ -358,6 +358,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_12_07_200746) do | |||
358 | t.string "slug" | 358 | t.string "slug" |
359 | t.datetime "created_at", precision: nil, null: false | 359 | t.datetime "created_at", precision: nil, null: false |
360 | t.datetime "updated_at", precision: nil, null: false | 360 | t.datetime "updated_at", precision: nil, null: false |
361 | t.datetime "latest_post_at", null: false | ||
361 | end | 362 | end |
362 | 363 | ||
363 | create_table "taggings", force: :cascade do |t| | 364 | create_table "taggings", force: :cascade do |t| |