diff --git a/app/models/message.rb b/app/models/message.rb index b058bad..62c9b30 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -63,6 +63,8 @@ def from_mail(mail, list, list_seq) end end + self.yyyymm = self.published_at.strftime('%Y%m') + self end diff --git a/db/migrate/20251220051221_add_yyyymm_to_messages.rb b/db/migrate/20251220051221_add_yyyymm_to_messages.rb new file mode 100644 index 0000000..dc10ecf --- /dev/null +++ b/db/migrate/20251220051221_add_yyyymm_to_messages.rb @@ -0,0 +1,5 @@ +class AddYyyymmToMessages < ActiveRecord::Migration[8.1] + def change + add_column :messages, :yyyymm, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index fe9c61d..9acb8f4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,37 +10,37 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_10_22_024234) do +ActiveRecord::Schema[8.1].define(version: 2025_12_20_051221) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" enable_extension "pg_trgm" create_table "active_storage_attachments", force: :cascade do |t| - t.string "name", null: false - t.string "record_type", null: false - t.bigint "record_id", null: false t.bigint "blob_id", null: false t.datetime "created_at", null: false + t.string "name", null: false + t.bigint "record_id", null: false + t.string "record_type", null: false t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true end create_table "active_storage_blobs", force: :cascade do |t| - t.string "key", null: false - t.string "filename", null: false - t.string "content_type" - t.text "metadata" - t.string "service_name", null: false t.bigint "byte_size", null: false t.string "checksum" + t.string "content_type" t.datetime "created_at", null: false + t.string "filename", null: false + t.string "key", null: false + t.text "metadata" + t.string "service_name", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end create_table "active_storage_file_blobs", force: :cascade do |t| - t.string "key" - t.binary "data" t.datetime "created_at", null: false + t.binary "data" + t.string "key" t.datetime "updated_at", null: false t.index ["key"], name: "index_active_storage_file_blobs_on_key", unique: true end @@ -52,17 +52,18 @@ end create_table "messages", force: :cascade do |t| - t.string "subject" - t.string "from" t.text "body" t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "from" + t.text "html_body" t.integer "list_id" t.integer "list_seq" - t.timestamptz "published_at" t.string "message_id_header" t.integer "parent_id" - t.text "html_body" + t.timestamptz "published_at" + t.string "subject" + t.datetime "updated_at", null: false + t.integer "yyyymm" t.index ["body"], name: "index_messages_on_body", opclass: :gin_trgm_ops, using: :gin t.index ["list_id", "list_seq"], name: "index_messages_on_list_id_and_list_seq", unique: true t.index ["message_id_header"], name: "index_messages_on_message_id_header"