add migrations for artifacts feature
This commit is contained in:
parent
83d065e2f9
commit
210af50477
5 changed files with 159 additions and 1 deletions
20
db/migrate/20251203184819_create_artifacts.rb
Normal file
20
db/migrate/20251203184819_create_artifacts.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateArtifacts < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :artifacts, id: :uuid do |t|
|
||||
t.string :granblue_id, null: false
|
||||
t.string :name_en, null: false
|
||||
t.string :name_jp
|
||||
t.integer :proficiency
|
||||
t.integer :rarity, null: false, default: 0
|
||||
t.date :release_date
|
||||
|
||||
# No timestamps - static reference data
|
||||
end
|
||||
|
||||
add_index :artifacts, :granblue_id, unique: true
|
||||
add_index :artifacts, :proficiency
|
||||
add_index :artifacts, :rarity
|
||||
end
|
||||
end
|
||||
26
db/migrate/20251203184919_create_collection_artifacts.rb
Normal file
26
db/migrate/20251203184919_create_collection_artifacts.rb
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateCollectionArtifacts < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :collection_artifacts, id: :uuid do |t|
|
||||
t.references :user, type: :uuid, null: false, foreign_key: true
|
||||
t.references :artifact, type: :uuid, null: false, foreign_key: true
|
||||
|
||||
t.integer :element, null: false
|
||||
t.integer :proficiency # Only for quirk artifacts (random proficiency assigned by game)
|
||||
t.integer :level, null: false, default: 1
|
||||
t.string :nickname
|
||||
|
||||
# Skills (JSONB) - each contains: { modifier: int, strength: value, level: int }
|
||||
t.jsonb :skill1, default: {}, null: false
|
||||
t.jsonb :skill2, default: {}, null: false
|
||||
t.jsonb :skill3, default: {}, null: false
|
||||
t.jsonb :skill4, default: {}, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :collection_artifacts, [:user_id, :artifact_id]
|
||||
add_index :collection_artifacts, :element
|
||||
end
|
||||
end
|
||||
23
db/migrate/20251203185443_create_grid_artifacts.rb
Normal file
23
db/migrate/20251203185443_create_grid_artifacts.rb
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateGridArtifacts < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :grid_artifacts, id: :uuid do |t|
|
||||
# One artifact per character - unique index created by references
|
||||
t.references :grid_character, type: :uuid, null: false, foreign_key: true, index: { unique: true }
|
||||
t.references :artifact, type: :uuid, null: false, foreign_key: true
|
||||
|
||||
t.integer :element, null: false
|
||||
t.integer :proficiency # Only for quirk artifacts (random proficiency assigned by game)
|
||||
t.integer :level, null: false, default: 1
|
||||
|
||||
# Skills (JSONB) - each contains: { modifier: int, strength: value, level: int }
|
||||
t.jsonb :skill1, default: {}, null: false
|
||||
t.jsonb :skill2, default: {}, null: false
|
||||
t.jsonb :skill3, default: {}, null: false
|
||||
t.jsonb :skill4, default: {}, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
24
db/migrate/20251203195857_create_artifact_skills.rb
Normal file
24
db/migrate/20251203195857_create_artifact_skills.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateArtifactSkills < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :artifact_skills, id: :uuid do |t|
|
||||
t.integer :skill_group, null: false # 1, 2, or 3
|
||||
t.integer :modifier, null: false # Skill ID within the group
|
||||
|
||||
t.string :name_en, null: false
|
||||
t.string :name_jp, null: false
|
||||
|
||||
t.jsonb :base_values, null: false, default: []
|
||||
t.decimal :growth, precision: 15, scale: 2
|
||||
t.string :suffix_en, default: ''
|
||||
t.string :suffix_jp, default: ''
|
||||
t.string :polarity, null: false, default: 'positive'
|
||||
|
||||
# No timestamps - static reference data
|
||||
end
|
||||
|
||||
add_index :artifact_skills, [:skill_group, :modifier], unique: true
|
||||
add_index :artifact_skills, :skill_group
|
||||
end
|
||||
end
|
||||
67
db/schema.rb
67
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_03_173746) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2025_12_03_195857) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "btree_gin"
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
|
|
@ -23,6 +23,32 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_03_173746) do
|
|||
t.string "version"
|
||||
end
|
||||
|
||||
create_table "artifact_skills", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.integer "skill_group", null: false
|
||||
t.integer "modifier", null: false
|
||||
t.string "name_en", null: false
|
||||
t.string "name_jp", null: false
|
||||
t.jsonb "base_values", default: [], null: false
|
||||
t.decimal "growth", precision: 15, scale: 2
|
||||
t.string "suffix_en", default: ""
|
||||
t.string "suffix_jp", default: ""
|
||||
t.string "polarity", default: "positive", null: false
|
||||
t.index ["skill_group", "modifier"], name: "index_artifact_skills_on_skill_group_and_modifier", unique: true
|
||||
t.index ["skill_group"], name: "index_artifact_skills_on_skill_group"
|
||||
end
|
||||
|
||||
create_table "artifacts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "granblue_id", null: false
|
||||
t.string "name_en", null: false
|
||||
t.string "name_jp"
|
||||
t.integer "proficiency"
|
||||
t.integer "rarity", default: 0, null: false
|
||||
t.date "release_date"
|
||||
t.index ["granblue_id"], name: "index_artifacts_on_granblue_id", unique: true
|
||||
t.index ["proficiency"], name: "index_artifacts_on_proficiency"
|
||||
t.index ["rarity"], name: "index_artifacts_on_rarity"
|
||||
end
|
||||
|
||||
create_table "awakenings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.string "name_en", null: false
|
||||
t.string "name_jp", null: false
|
||||
|
|
@ -111,6 +137,25 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_03_173746) do
|
|||
t.index ["skill_id"], name: "index_charge_attacks_on_skill_id"
|
||||
end
|
||||
|
||||
create_table "collection_artifacts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "user_id", null: false
|
||||
t.uuid "artifact_id", null: false
|
||||
t.integer "element", null: false
|
||||
t.integer "proficiency"
|
||||
t.integer "level", default: 1, null: false
|
||||
t.string "nickname"
|
||||
t.jsonb "skill1", default: {}, null: false
|
||||
t.jsonb "skill2", default: {}, null: false
|
||||
t.jsonb "skill3", default: {}, null: false
|
||||
t.jsonb "skill4", default: {}, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["artifact_id"], name: "index_collection_artifacts_on_artifact_id"
|
||||
t.index ["element"], name: "index_collection_artifacts_on_element"
|
||||
t.index ["user_id", "artifact_id"], name: "index_collection_artifacts_on_user_id_and_artifact_id"
|
||||
t.index ["user_id"], name: "index_collection_artifacts_on_user_id"
|
||||
end
|
||||
|
||||
create_table "collection_characters", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "user_id", null: false
|
||||
t.uuid "character_id", null: false
|
||||
|
|
@ -241,6 +286,22 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_03_173746) do
|
|||
t.index ["gacha_id"], name: "index_gacha_rateups_on_gacha_id"
|
||||
end
|
||||
|
||||
create_table "grid_artifacts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "grid_character_id", null: false
|
||||
t.uuid "artifact_id", null: false
|
||||
t.integer "element", null: false
|
||||
t.integer "proficiency"
|
||||
t.integer "level", default: 1, null: false
|
||||
t.jsonb "skill1", default: {}, null: false
|
||||
t.jsonb "skill2", default: {}, null: false
|
||||
t.jsonb "skill3", default: {}, null: false
|
||||
t.jsonb "skill4", default: {}, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["artifact_id"], name: "index_grid_artifacts_on_artifact_id"
|
||||
t.index ["grid_character_id"], name: "index_grid_artifacts_on_grid_character_id", unique: true
|
||||
end
|
||||
|
||||
create_table "grid_characters", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "party_id"
|
||||
t.uuid "character_id"
|
||||
|
|
@ -762,6 +823,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_03_173746) do
|
|||
add_foreign_key "character_skills", "skills", column: "alt_skill_id"
|
||||
add_foreign_key "charge_attacks", "skills"
|
||||
add_foreign_key "charge_attacks", "skills", column: "alt_skill_id"
|
||||
add_foreign_key "collection_artifacts", "artifacts"
|
||||
add_foreign_key "collection_artifacts", "users"
|
||||
add_foreign_key "collection_characters", "awakenings"
|
||||
add_foreign_key "collection_characters", "characters"
|
||||
add_foreign_key "collection_characters", "users"
|
||||
|
|
@ -779,6 +842,8 @@ ActiveRecord::Schema[8.0].define(version: 2025_12_03_173746) do
|
|||
add_foreign_key "effects", "effects", column: "effect_family_id"
|
||||
add_foreign_key "favorites", "parties"
|
||||
add_foreign_key "favorites", "users"
|
||||
add_foreign_key "grid_artifacts", "artifacts"
|
||||
add_foreign_key "grid_artifacts", "grid_characters"
|
||||
add_foreign_key "grid_characters", "awakenings"
|
||||
add_foreign_key "grid_characters", "characters"
|
||||
add_foreign_key "grid_characters", "parties"
|
||||
|
|
|
|||
Loading…
Reference in a new issue