diff --git a/app/models/party.rb b/app/models/party.rb index 0ad7a2a..3cb3b99 100644 --- a/app/models/party.rb +++ b/app/models/party.rb @@ -200,8 +200,13 @@ class Party < ApplicationRecord validates :button_count, numericality: { only_integer: true }, allow_nil: true validates :chain_count, numericality: { only_integer: true }, allow_nil: true validates :turn_count, numericality: { only_integer: true }, allow_nil: true + validates :summon_count, numericality: { only_integer: true }, allow_nil: true validates :ultimate_mastery, numericality: { only_integer: true }, allow_nil: true + # YouTube URL validation regex + YOUTUBE_REGEX = %r{\A(?:https?://)?(?:www\.)?(?:youtube\.com/watch\?v=|youtu\.be/)[\w-]+} + validates :video_url, format: { with: YOUTUBE_REGEX, message: 'must be a valid YouTube URL' }, allow_blank: true + # Validate visibility (allowed values: 1, 2, or 3). validates :visibility, numericality: { only_integer: true }, diff --git a/db/migrate/20251220100000_add_video_url_and_summon_count_to_parties.rb b/db/migrate/20251220100000_add_video_url_and_summon_count_to_parties.rb new file mode 100644 index 0000000..1dec836 --- /dev/null +++ b/db/migrate/20251220100000_add_video_url_and_summon_count_to_parties.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +class AddVideoUrlAndSummonCountToParties < ActiveRecord::Migration[8.0] + def change + add_column :parties, :video_url, :string, limit: 2048 + add_column :parties, :summon_count, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 137d7df..c63b95c 100644 --- a/db/schema.rb +++ b/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_20_014422) do +ActiveRecord::Schema[8.0].define(version: 2025_12_20_100000) do # These are extensions that must be enabled in order to support this database enable_extension "btree_gin" enable_extension "pg_catalog.plpgsql" @@ -135,7 +135,6 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_20_014422) do t.text "wiki_raw" t.jsonb "game_raw_en", comment: "JSON data from game (English)" t.jsonb "game_raw_jp", comment: "JSON data from game (Japanese)" - t.text "game_raw_en_backup" t.integer "season" t.integer "series", default: [], null: false, array: true t.index ["granblue_id"], name: "index_characters_on_granblue_id" @@ -637,6 +636,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_20_014422) do t.integer "preview_state", default: 0, null: false t.datetime "preview_generated_at" t.string "preview_s3_key" + t.string "video_url", limit: 2048 + t.integer "summon_count" t.index ["accessory_id"], name: "index_parties_on_accessory_id" t.index ["created_at"], name: "index_parties_on_created_at" t.index ["element"], name: "index_parties_on_element"