Add JobAccessory model and add type to schema
We need type because we don't want to hardcode job ids in scripts
This commit is contained in:
parent
7de4bb6863
commit
0ff7e7a8dd
3 changed files with 44 additions and 1 deletions
37
app/models/job_accessory.rb
Normal file
37
app/models/job_accessory.rb
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class JobAccessory < ApplicationRecord
|
||||
include PgSearch::Model
|
||||
|
||||
belongs_to :job
|
||||
|
||||
pg_search_scope :en_search,
|
||||
against: :name_en,
|
||||
using: {
|
||||
tsearch: {
|
||||
prefix: true,
|
||||
dictionary: 'simple'
|
||||
}
|
||||
}
|
||||
|
||||
pg_search_scope :jp_search,
|
||||
against: :name_jp,
|
||||
using: {
|
||||
tsearch: {
|
||||
prefix: true,
|
||||
dictionary: 'simple'
|
||||
}
|
||||
}
|
||||
|
||||
def blueprint
|
||||
JobAccessoryBlueprint
|
||||
end
|
||||
|
||||
def display_resource(skill)
|
||||
skill.name_en
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
self.class == other.class && id == other.id
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
class AddAccessoryTypeToJobAccessories < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :job_accessories, :accessory_type, :integer
|
||||
end
|
||||
end
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_01_24_000252) do
|
||||
ActiveRecord::Schema[7.0].define(version: 2023_01_24_013326) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "btree_gin"
|
||||
enable_extension "pg_trgm"
|
||||
|
|
@ -121,6 +121,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_01_24_000252) do
|
|||
t.string "granblue_id", null: false
|
||||
t.integer "rarity"
|
||||
t.date "release_date"
|
||||
t.integer "accessory_type"
|
||||
t.index ["job_id"], name: "index_job_accessories_on_job_id"
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue