diff --git a/app/controllers/api/v1/parties_controller.rb b/app/controllers/api/v1/parties_controller.rb index 1cc1965..ef0b048 100644 --- a/app/controllers/api/v1/parties_controller.rb +++ b/app/controllers/api/v1/parties_controller.rb @@ -60,7 +60,7 @@ module Api remix: true } - new_party.local_id = party_params[:local_id] if !party_params.nil? + new_party.local_id = party_params[:local_id] unless party_params.nil? if new_party.save render json: PartyBlueprint.render(new_party, view: :created, root: :party), @@ -71,58 +71,34 @@ module Api end def index - conditions = build_conditions + conditions = build_filters - @parties = Party.joins(:weapons) - .group('parties.id') - .having('count(distinct grid_weapons.weapon_id) > 2') - .where(conditions) - .where(name_quality) - .where(user_quality) - .where(original) - .order(created_at: :desc) - .paginate(page: request.params[:page], per_page: COLLECTION_PER_PAGE) - .each { |party| party.favorited = current_user ? party.is_favorited(current_user) : false } + query = build_query(conditions) + query = apply_includes(query, params[:includes]) if params[:includes].present? + query = apply_excludes(query, params[:excludes]) if params[:excludes].present? - count = Party.where(conditions).count - total_pages = count.to_f / COLLECTION_PER_PAGE > 1 ? (count.to_f / COLLECTION_PER_PAGE).ceil : 1 + @parties = fetch_parties(query) + count = calculate_count(query) + total_pages = calculate_total_pages(count) - render json: PartyBlueprint.render(@parties, - view: :collection, - root: :results, - meta: { - count: count, - total_pages: total_pages, - per_page: COLLECTION_PER_PAGE - }) + render_party_json(@parties, count, total_pages) end def favorites raise Api::V1::UnauthorizedError unless current_user - conditions = build_conditions + conditions = build_filters conditions[:favorites] = { user_id: current_user.id } - @parties = Party.joins(:favorites) - .where(conditions) - .where(name_quality) - .where(user_quality) - .where(original) - .order('favorites.created_at DESC') - .paginate(page: request.params[:page], per_page: COLLECTION_PER_PAGE) - .each { |party| party.favorited = party.is_favorited(current_user) } + query = build_query(conditions) + query = apply_includes(query, params[:includes]) if params[:includes].present? + query = apply_excludes(query, params[:excludes]) if params[:excludes].present? - count = Party.joins(:favorites).where(conditions).count - total_pages = count.to_f / COLLECTION_PER_PAGE > 1 ? (count.to_f / COLLECTION_PER_PAGE).ceil : 1 + @parties = fetch_parties(query) + count = calculate_count(query) + total_pages = calculate_total_pages(count) - render json: PartyBlueprint.render(@parties, - view: :collection, - root: :results, - meta: { - count: count, - total_pages: total_pages, - per_page: COLLECTION_PER_PAGE - }) + render_party_json(@parties, count, total_pages) end private @@ -131,70 +107,179 @@ module Api render_unauthorized_response if @party.user != current_user || @party.edit_key != edit_key end - def build_conditions + def build_filters params = request.params - unless params['recency'].blank? - start_time = (DateTime.current - params['recency'].to_i.seconds) - .to_datetime.beginning_of_day - end + start_time = build_start_time(params['recency']) - min_characters_count = params['characters_count'].blank? ? DEFAULT_MIN_CHARACTERS : params['characters_count'].to_i - min_summons_count = params['summons_count'].blank? ? DEFAULT_MIN_SUMMONS : params['summons_count'].to_i - min_weapons_count = params['weapons_count'].blank? ? DEFAULT_MIN_WEAPONS : params['weapons_count'].to_i - max_clear_time = params['max_clear_time'].blank? ? DEFAULT_MAX_CLEAR_TIME : params['max_clear_time'].to_i + min_characters_count = build_count(params['characters_count'], DEFAULT_MIN_CHARACTERS) + min_summons_count = build_count(params['summons_count'], DEFAULT_MIN_SUMMONS) + min_weapons_count = build_count(params['weapons_count'], DEFAULT_MIN_WEAPONS) + max_clear_time = build_max_clear_time(params['max_clear_time']) - {}.tap do |hash| - # Basic filters - hash[:element] = params['element'].to_i unless params['element'].blank? - hash[:raid] = params['raid'] unless params['raid'].blank? - hash[:created_at] = start_time..DateTime.current unless params['recency'].blank? - - # Advanced filters: Team parameters - hash[:full_auto] = params['full_auto'].to_i unless params['full_auto'].blank? || params['full_auto'].to_i == -1 - hash[:auto_guard] = params['auto_guard'].to_i unless params['auto_guard'].blank? || params['auto_guard'].to_i == -1 - hash[:charge_attack] = params['charge_attack'].to_i unless params['charge_attack'].blank? || params['charge_attack'].to_i == -1 - - # Turn count of 0 will not be displayed, so disallow on the frontend or set default to 1 - # How do we do the same for button count since that can reasonably be 1? - # hash[:turn_count] = params['turn_count'].to_i unless params['turn_count'].blank? || params['turn_count'].to_i <= 0 - # hash[:button_count] = params['button_count'].to_i unless params['button_count'].blank? - # hash[:clear_time] = 0..max_clear_time - - # Advanced filters: Object counts - hash[:characters_count] = min_characters_count..MAX_CHARACTERS - hash[:summons_count] = min_summons_count..MAX_SUMMONS - hash[:weapons_count] = min_weapons_count..MAX_WEAPONS - end + { + element: build_element(params['element']), + raid: params['raid'], + created_at: params['recency'].present? ? start_time..DateTime.current : nil, + full_auto: build_option(params['full_auto']), + auto_guard: build_option(params['auto_guard']), + charge_attack: build_option(params['charge_attack']), + characters_count: min_characters_count..MAX_CHARACTERS, + summons_count: min_summons_count..MAX_SUMMONS, + weapons_count: min_weapons_count..MAX_WEAPONS + }.delete_if { |_k, v| v.nil? } end - def original - "source_party_id IS NULL" unless request.params['original'].blank? || request.params['original'] == "false" + def build_start_time(recency) + return unless recency.present? + + (DateTime.current - recency.to_i.seconds).to_datetime.beginning_of_day + end + + def build_count(value, default) + value.blank? ? default : value.to_i + end + + def build_max_clear_time(value) + value.blank? ? DEFAULT_MAX_CLEAR_TIME : value.to_i + end + + def build_element(element) + element.to_i unless element.blank? + end + + def build_option(value) + value.to_i unless value.blank? || value.to_i == -1 + end + + def build_query(conditions) + Party.distinct + .joins(weapons: [:object], summons: [:object], characters: [:object]) + .group('parties.id') + .where(conditions) + .where(name_quality) + .where(user_quality) + .where(original) + end + + def includes(id) + "(\"#{id_to_table(id)}\".\"granblue_id\" = '#{id}')" + end + + def excludes(id) + "(\"#{id_to_table(id)}\".\"granblue_id\" != '#{id}')" + end + + def apply_includes(query, includes) + included = includes.split(',') + includes_condition = included.map { |id| includes(id) }.join(' AND ') + query.where(includes_condition) + end + + def apply_excludes(query, _excludes) + characters_subquery = excluded_characters.select(1).arel + summons_subquery = excluded_summons.select(1).arel + weapons_subquery = excluded_weapons.select(1).arel + + query.where(characters_subquery.exists.not) + .where(weapons_subquery.exists.not) + .where(summons_subquery.exists.not) + end + + def excluded_characters + return unless params[:excludes] + + excluded = params[:excludes].split(',').filter { |id| id[0] == '3' } + GridCharacter.joins(:object) + .where(characters: { granblue_id: excluded }) + .where('grid_characters.party_id = parties.id') + end + + def excluded_summons + return unless params[:excludes] + + excluded = params[:excludes].split(',').filter { |id| id[0] == '2' } + GridSummon.joins(:object) + .where(summons: { granblue_id: excluded }) + .where('grid_summons.party_id = parties.id') + end + + def excluded_weapons + return unless params[:excludes] + + excluded = params[:excludes].split(',').filter { |id| id[0] == '1' } + GridWeapon.joins(:object) + .where(weapons: { granblue_id: excluded }) + .where('grid_weapons.party_id = parties.id') + end + + def fetch_parties(query) + query.order(created_at: :desc) + .paginate(page: request.params[:page], per_page: COLLECTION_PER_PAGE) + .each { |party| party.favorited = current_user ? party.is_favorited(current_user) : false } + end + + def calculate_count(query) + query.count.values.sum + end + + def calculate_total_pages(count) + count.to_f / COLLECTION_PER_PAGE > 1 ? (count.to_f / COLLECTION_PER_PAGE).ceil : 1 + end + + def render_party_json(parties, count, total_pages) + render json: PartyBlueprint.render(parties, + view: :collection, + root: :results, + meta: { + count: count, + total_pages: total_pages, + per_page: COLLECTION_PER_PAGE + }) end def user_quality - "user_id IS NOT NULL" unless request.params[:user_quality].blank? || request.params[:user_quality] == "false" + 'user_id IS NOT NULL' unless request.params[:user_quality].blank? || request.params[:user_quality] == 'false' end def name_quality low_quality = [ - "Untitled", - "Remix of Untitled", - "Remix of Remix of Untitled", - "Remix of Remix of Remix of Untitled", - "Remix of Remix of Remix of Remix of Untitled", - "Remix of Remix of Remix of Remix of Remix of Untitled", - "無題", - "無題のリミックス", - "無題のリミックスのリミックス", - "無題のリミックスのリミックスのリミックス", - "無題のリミックスのリミックスのリミックスのリミックス", - "無題のリミックスのリミックスのリミックスのリミックスのリミックス" + 'Untitled', + 'Remix of Untitled', + 'Remix of Remix of Untitled', + 'Remix of Remix of Remix of Untitled', + 'Remix of Remix of Remix of Remix of Untitled', + 'Remix of Remix of Remix of Remix of Remix of Untitled', + '無題', + '無題のリミックス', + '無題のリミックスのリミックス', + '無題のリミックスのリミックスのリミックス', + '無題のリミックスのリミックスのリミックスのリミックス', + '無題のリミックスのリミックスのリミックスのリミックスのリミックス' ] joined_names = low_quality.map { |name| "'#{name}'" }.join(',') - "name NOT IN (#{joined_names})" unless request.params[:name_quality].blank? || request.params[:name_quality] == "false" + return if request.params[:name_quality].blank? || request.params[:name_quality] == 'false' + + "name NOT IN (#{joined_names})" + end + + def original + 'source_party_id IS NULL' unless request.params['original'].blank? || request.params['original'] == 'false' + end + + def id_to_table(id) + case id[0] + when '3' + table = 'characters' + when '2' + table = 'summons' + when '1' + table = 'weapons' + end + + table end def remixed_name(name) diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index 37731bd..9ab81f3 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -30,20 +30,26 @@ module Api end def search_all_en - PgSearch.multisearch_options = { using: TRIGRAM } - results = PgSearch.multisearch(search_params[:query]).limit(10) + query = search_params[:query] + exclude = search_params[:exclude] - if (results.length < 5) && (search_params[:query].length >= 2) + PgSearch.multisearch_options = { using: TRIGRAM } + results = PgSearch.multisearch(query).where.not(granblue_id: exclude).limit(10) + + if (results.length < 5) && (query.length >= 2) PgSearch.multisearch_options = { using: TSEARCH_WITH_PREFIX } - results = PgSearch.multisearch(search_params[:query]).limit(10) + results = PgSearch.multisearch(query).where.not(granblue_id: exclude).limit(10) end results end def search_all_ja + query = search_params[:query] + exclude = search_params[:exclude] + PgSearch.multisearch_options = { using: TSEARCH_WITH_PREFIX } - PgSearch.multisearch(search_params[:query]).limit(10) + PgSearch.multisearch(query).where.not(granblue_id: exclude).limit(10) end def characters diff --git a/app/models/character.rb b/app/models/character.rb index c2000a8..29a72df 100644 --- a/app/models/character.rb +++ b/app/models/character.rb @@ -8,6 +8,8 @@ class Character < ApplicationRecord { name_en: character.name_en, name_jp: character.name_jp, + nicknames_en: character.nicknames_en, + nicknames_jp: character.nicknames_jp, granblue_id: character.granblue_id, element: character.element } diff --git a/app/models/grid_character.rb b/app/models/grid_character.rb index 09d6e8d..6fc5783 100644 --- a/app/models/grid_character.rb +++ b/app/models/grid_character.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class GridCharacter < ApplicationRecord + has_one :object, class_name: 'Character', foreign_key: :id, primary_key: :character_id + belongs_to :awakening, optional: true belongs_to :party, counter_cache: :characters_count, @@ -87,9 +89,9 @@ class GridCharacter < ApplicationRecord private def add_awakening - if self.awakening.nil? - self.awakening = Awakening.where(slug: "character-balanced").sole - end + return unless awakening.nil? + + self.awakening = Awakening.where(slug: 'character-balanced').sole end def check_value(property, type) diff --git a/app/models/grid_summon.rb b/app/models/grid_summon.rb index c62a33b..f2a1afc 100644 --- a/app/models/grid_summon.rb +++ b/app/models/grid_summon.rb @@ -5,6 +5,7 @@ class GridSummon < ApplicationRecord counter_cache: :summons_count, inverse_of: :summons validates_presence_of :party + has_one :object, class_name: 'Summon', foreign_key: :id, primary_key: :summon_id validate :compatible_with_position, on: :create validate :no_conflicts, on: :create @@ -23,6 +24,7 @@ class GridSummon < ApplicationRecord party.summons.find do |grid_summon| return unless grid_summon.id + grid_summon if summon.id == grid_summon.summon.id end end diff --git a/app/models/grid_weapon.rb b/app/models/grid_weapon.rb index 459e450..ab8e3fd 100644 --- a/app/models/grid_weapon.rb +++ b/app/models/grid_weapon.rb @@ -6,6 +6,8 @@ class GridWeapon < ApplicationRecord inverse_of: :weapons validates_presence_of :party + has_one :object, class_name: 'Weapon', foreign_key: :id, primary_key: :weapon_id + belongs_to :weapon_key1, class_name: 'WeaponKey', foreign_key: :weapon_key1_id, optional: true belongs_to :weapon_key2, class_name: 'WeaponKey', foreign_key: :weapon_key2_id, optional: true belongs_to :weapon_key3, class_name: 'WeaponKey', foreign_key: :weapon_key3_id, optional: true @@ -78,10 +80,6 @@ class GridWeapon < ApplicationRecord # Checks if the weapon should be a mainhand before saving the model def is_mainhand - if self.position == -1 - self.mainhand = true - else - self.mainhand = false - end + self.mainhand = position == -1 end end diff --git a/app/models/summon.rb b/app/models/summon.rb index 5989216..ee56a9d 100644 --- a/app/models/summon.rb +++ b/app/models/summon.rb @@ -8,6 +8,8 @@ class Summon < ApplicationRecord { name_en: summon.name_en, name_jp: summon.name_jp, + nicknames_en: summon.nicknames_en, + nicknames_jp: summon.nicknames_jp, granblue_id: summon.granblue_id, element: summon.element } diff --git a/app/models/weapon.rb b/app/models/weapon.rb index ac0c6b7..8b330b1 100644 --- a/app/models/weapon.rb +++ b/app/models/weapon.rb @@ -8,6 +8,8 @@ class Weapon < ApplicationRecord { name_en: weapon.name_en, name_jp: weapon.name_jp, + nicknames_en: weapon.nicknames_en, + nicknames_jp: weapon.nicknames_jp, granblue_id: weapon.granblue_id, element: weapon.element } diff --git a/db/schema.rb b/db/schema.rb index a078f2a..2036d65 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,548 +10,548 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_08_20_113900) do +ActiveRecord::Schema[7.0].define(version: 20_230_820_113_900) do # These are extensions that must be enabled in order to support this database - enable_extension "btree_gin" - enable_extension "pg_trgm" - enable_extension "pgcrypto" - enable_extension "plpgsql" + enable_extension 'btree_gin' + enable_extension 'pg_trgm' + enable_extension 'pgcrypto' + enable_extension 'plpgsql' - create_table "app_updates", primary_key: "updated_at", id: :datetime, force: :cascade do |t| - t.string "update_type", null: false - t.string "version" + create_table 'app_updates', primary_key: 'updated_at', id: :datetime, force: :cascade do |t| + t.string 'update_type', null: false + t.string 'version' 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 - t.string "slug", null: false - t.string "object_type", null: false - t.integer "order", default: 0, null: false + 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 + t.string 'slug', null: false + t.string 'object_type', null: false + t.integer 'order', default: 0, null: false end - create_table "character_charge_attacks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "character_id" - t.string "name_en", null: false - t.string "name_jp", null: false - t.string "description_en", null: false - t.string "description_jp", null: false - t.integer "order", null: false - t.string "form" - t.uuid "effects", array: true - t.index ["character_id"], name: "index_character_charge_attacks_on_character_id" + create_table 'character_charge_attacks', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'character_id' + t.string 'name_en', null: false + t.string 'name_jp', null: false + t.string 'description_en', null: false + t.string 'description_jp', null: false + t.integer 'order', null: false + t.string 'form' + t.uuid 'effects', array: true + t.index ['character_id'], name: 'index_character_charge_attacks_on_character_id' end - create_table "character_skills", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "character_id" - t.string "name_en", null: false - t.string "name_jp", null: false - t.string "description_en", null: false - t.string "description_jp", null: false - t.integer "type", null: false - t.integer "position", null: false - t.string "form" - t.integer "cooldown", default: 0, null: false - t.integer "lockout", default: 0, null: false - t.integer "duration", array: true - t.boolean "recast", default: false, null: false - t.integer "obtained_at", default: 1, null: false - t.uuid "effects", array: true - t.index ["character_id"], name: "index_character_skills_on_character_id" + create_table 'character_skills', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'character_id' + t.string 'name_en', null: false + t.string 'name_jp', null: false + t.string 'description_en', null: false + t.string 'description_jp', null: false + t.integer 'type', null: false + t.integer 'position', null: false + t.string 'form' + t.integer 'cooldown', default: 0, null: false + t.integer 'lockout', default: 0, null: false + t.integer 'duration', array: true + t.boolean 'recast', default: false, null: false + t.integer 'obtained_at', default: 1, null: false + t.uuid 'effects', array: true + t.index ['character_id'], name: 'index_character_skills_on_character_id' end - create_table "character_support_skills", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "character_id" - t.string "name_en", null: false - t.string "name_jp", null: false - t.string "description_en", null: false - t.string "description_jp", null: false - t.integer "position", null: false - t.integer "obtained_at" - t.boolean "emp", default: false, null: false - t.boolean "transcendence", default: false, null: false - t.uuid "effects", array: true - t.index ["character_id"], name: "index_character_support_skills_on_character_id" + create_table 'character_support_skills', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'character_id' + t.string 'name_en', null: false + t.string 'name_jp', null: false + t.string 'description_en', null: false + t.string 'description_jp', null: false + t.integer 'position', null: false + t.integer 'obtained_at' + t.boolean 'emp', default: false, null: false + t.boolean 'transcendence', default: false, null: false + t.uuid 'effects', array: true + t.index ['character_id'], name: 'index_character_support_skills_on_character_id' end - create_table "characters", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "name_en" - t.string "name_jp" - t.string "granblue_id" - t.integer "rarity" - t.integer "element" - t.integer "proficiency1" - t.integer "proficiency2" - t.integer "gender" - t.integer "race1" - t.integer "race2" - t.boolean "flb", default: false, null: false - t.integer "min_hp" - t.integer "max_hp" - t.integer "max_hp_flb" - t.integer "min_atk" - t.integer "max_atk" - t.integer "max_atk_flb" - t.integer "base_da" - t.integer "base_ta" - t.float "ougi_ratio" - t.float "ougi_ratio_flb" - t.boolean "special", default: false, null: false - t.boolean "ulb", default: false, null: false - t.integer "max_hp_ulb" - t.integer "max_atk_ulb" - t.integer "character_id", default: [], null: false, array: true - t.string "nicknames_en", default: [], null: false, array: true - t.string "nicknames_jp", default: [], null: false, array: true - t.string "wiki_en", default: "", null: false - t.date "release_date" - t.date "flb_date" - t.date "ulb_date" - t.string "wiki_ja", default: "", null: false - t.string "gamewith", default: "", null: false - t.string "kamigame", default: "", null: false - t.index ["name_en"], name: "index_characters_on_name_en", opclass: :gin_trgm_ops, using: :gin + create_table 'characters', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'name_en' + t.string 'name_jp' + t.string 'granblue_id' + t.integer 'rarity' + t.integer 'element' + t.integer 'proficiency1' + t.integer 'proficiency2' + t.integer 'gender' + t.integer 'race1' + t.integer 'race2' + t.boolean 'flb', default: false, null: false + t.integer 'min_hp' + t.integer 'max_hp' + t.integer 'max_hp_flb' + t.integer 'min_atk' + t.integer 'max_atk' + t.integer 'max_atk_flb' + t.integer 'base_da' + t.integer 'base_ta' + t.float 'ougi_ratio' + t.float 'ougi_ratio_flb' + t.boolean 'special', default: false, null: false + t.boolean 'ulb', default: false, null: false + t.integer 'max_hp_ulb' + t.integer 'max_atk_ulb' + t.integer 'character_id', default: [], null: false, array: true + t.string 'nicknames_en', default: [], null: false, array: true + t.string 'nicknames_jp', default: [], null: false, array: true + t.string 'wiki_en', default: '', null: false + t.date 'release_date' + t.date 'flb_date' + t.date 'ulb_date' + t.string 'wiki_ja', default: '', null: false + t.string 'gamewith', default: '', null: false + t.string 'kamigame', default: '', null: false + t.index ['name_en'], name: 'index_characters_on_name_en', opclass: :gin_trgm_ops, using: :gin end - create_table "data_migrations", primary_key: "version", id: :string, force: :cascade do |t| + create_table 'data_migrations', primary_key: 'version', id: :string, force: :cascade do |t| end - create_table "effects", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "name_en", null: false - t.string "name_jp", null: false - t.string "description_en", null: false - t.string "description_jp", null: false - t.integer "accuracy_value" - t.string "accuracy_suffix" - t.string "accuracy_comparator" - t.jsonb "strength", array: true - t.integer "healing_cap" - t.boolean "duration_indefinite", default: false, null: false - t.integer "duration_value" - t.string "duration_unit" - t.string "notes_en" - t.string "notes_jp" + create_table 'effects', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'name_en', null: false + t.string 'name_jp', null: false + t.string 'description_en', null: false + t.string 'description_jp', null: false + t.integer 'accuracy_value' + t.string 'accuracy_suffix' + t.string 'accuracy_comparator' + t.jsonb 'strength', array: true + t.integer 'healing_cap' + t.boolean 'duration_indefinite', default: false, null: false + t.integer 'duration_value' + t.string 'duration_unit' + t.string 'notes_en' + t.string 'notes_jp' end - create_table "favorites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "user_id" - t.uuid "party_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["party_id"], name: "index_favorites_on_party_id" - t.index ["user_id"], name: "index_favorites_on_user_id" + create_table 'favorites', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'user_id' + t.uuid 'party_id' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index ['party_id'], name: 'index_favorites_on_party_id' + t.index ['user_id'], name: 'index_favorites_on_user_id' end - create_table "gacha", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.boolean "premium" - t.boolean "classic" - t.boolean "flash" - t.boolean "legend" - t.boolean "valentines" - t.boolean "summer" - t.boolean "halloween" - t.boolean "holiday" - t.string "drawable_type" - t.uuid "drawable_id" - t.index ["drawable_id"], name: "index_gacha_on_drawable_id", unique: true - t.index ["drawable_type", "drawable_id"], name: "index_gacha_on_drawable" + create_table 'gacha', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.boolean 'premium' + t.boolean 'classic' + t.boolean 'flash' + t.boolean 'legend' + t.boolean 'valentines' + t.boolean 'summer' + t.boolean 'halloween' + t.boolean 'holiday' + t.string 'drawable_type' + t.uuid 'drawable_id' + t.index ['drawable_id'], name: 'index_gacha_on_drawable_id', unique: true + t.index %w[drawable_type drawable_id], name: 'index_gacha_on_drawable' end - create_table "gacha_rateups", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "gacha_id" - t.string "user_id" - t.decimal "rate" - t.datetime "created_at", default: -> { "CURRENT_TIMESTAMP" }, null: false - t.index ["gacha_id"], name: "index_gacha_rateups_on_gacha_id" + create_table 'gacha_rateups', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'gacha_id' + t.string 'user_id' + t.decimal 'rate' + t.datetime 'created_at', default: -> { 'CURRENT_TIMESTAMP' }, null: false + t.index ['gacha_id'], name: 'index_gacha_rateups_on_gacha_id' end - create_table "grid_characters", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "party_id" - t.uuid "character_id" - t.integer "uncap_level" - t.integer "position" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.boolean "perpetuity", default: false, null: false - t.integer "transcendence_step", default: 0, null: false - t.jsonb "ring1", default: {"modifier"=>nil, "strength"=>nil}, null: false - t.jsonb "ring2", default: {"modifier"=>nil, "strength"=>nil}, null: false - t.jsonb "ring3", default: {"modifier"=>nil, "strength"=>nil}, null: false - t.jsonb "ring4", default: {"modifier"=>nil, "strength"=>nil}, null: false - t.jsonb "earring", default: {"modifier"=>nil, "strength"=>nil}, null: false - t.boolean "skill0_enabled", default: true, null: false - t.boolean "skill1_enabled", default: true, null: false - t.boolean "skill2_enabled", default: true, null: false - t.boolean "skill3_enabled", default: true, null: false - t.uuid "awakening_id" - t.integer "awakening_level", default: 1 - t.index ["awakening_id"], name: "index_grid_characters_on_awakening_id" - t.index ["character_id"], name: "index_grid_characters_on_character_id" - t.index ["party_id"], name: "index_grid_characters_on_party_id" + create_table 'grid_characters', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'party_id' + t.uuid 'character_id' + t.integer 'uncap_level' + t.integer 'position' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.boolean 'perpetuity', default: false, null: false + t.integer 'transcendence_step', default: 0, null: false + t.jsonb 'ring1', default: { 'modifier' => nil, 'strength' => nil }, null: false + t.jsonb 'ring2', default: { 'modifier' => nil, 'strength' => nil }, null: false + t.jsonb 'ring3', default: { 'modifier' => nil, 'strength' => nil }, null: false + t.jsonb 'ring4', default: { 'modifier' => nil, 'strength' => nil }, null: false + t.jsonb 'earring', default: { 'modifier' => nil, 'strength' => nil }, null: false + t.boolean 'skill0_enabled', default: true, null: false + t.boolean 'skill1_enabled', default: true, null: false + t.boolean 'skill2_enabled', default: true, null: false + t.boolean 'skill3_enabled', default: true, null: false + t.uuid 'awakening_id' + t.integer 'awakening_level', default: 1 + t.index ['awakening_id'], name: 'index_grid_characters_on_awakening_id' + t.index ['character_id'], name: 'index_grid_characters_on_character_id' + t.index ['party_id'], name: 'index_grid_characters_on_party_id' end - create_table "grid_summons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "party_id" - t.uuid "summon_id" - t.integer "uncap_level" - t.boolean "main" - t.boolean "friend" - t.integer "position" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "transcendence_step", default: 0, null: false - t.boolean "quick_summon", default: false, null: false - t.index ["party_id"], name: "index_grid_summons_on_party_id" - t.index ["summon_id"], name: "index_grid_summons_on_summon_id" + create_table 'grid_summons', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'party_id' + t.uuid 'summon_id' + t.integer 'uncap_level' + t.boolean 'main' + t.boolean 'friend' + t.integer 'position' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.integer 'transcendence_step', default: 0, null: false + t.boolean 'quick_summon', default: false, null: false + t.index ['party_id'], name: 'index_grid_summons_on_party_id' + t.index ['summon_id'], name: 'index_grid_summons_on_summon_id' end - create_table "grid_weapons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "party_id" - t.uuid "weapon_id" - t.uuid "weapon_key1_id" - t.uuid "weapon_key2_id" - t.integer "uncap_level" - t.boolean "mainhand" - t.integer "position" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.uuid "weapon_key3_id" - t.integer "ax_modifier1" - t.float "ax_strength1" - t.integer "ax_modifier2" - t.float "ax_strength2" - t.integer "element" - t.integer "awakening_level", default: 1, null: false - t.uuid "awakening_id" - t.index ["awakening_id"], name: "index_grid_weapons_on_awakening_id" - t.index ["party_id"], name: "index_grid_weapons_on_party_id" - t.index ["weapon_id"], name: "index_grid_weapons_on_weapon_id" - t.index ["weapon_key1_id"], name: "index_grid_weapons_on_weapon_key1_id" - t.index ["weapon_key2_id"], name: "index_grid_weapons_on_weapon_key2_id" - t.index ["weapon_key3_id"], name: "index_grid_weapons_on_weapon_key3_id" + create_table 'grid_weapons', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'party_id' + t.uuid 'weapon_id' + t.uuid 'weapon_key1_id' + t.uuid 'weapon_key2_id' + t.integer 'uncap_level' + t.boolean 'mainhand' + t.integer 'position' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.uuid 'weapon_key3_id' + t.integer 'ax_modifier1' + t.float 'ax_strength1' + t.integer 'ax_modifier2' + t.float 'ax_strength2' + t.integer 'element' + t.integer 'awakening_level', default: 1, null: false + t.uuid 'awakening_id' + t.index ['awakening_id'], name: 'index_grid_weapons_on_awakening_id' + t.index ['party_id'], name: 'index_grid_weapons_on_party_id' + t.index ['weapon_id'], name: 'index_grid_weapons_on_weapon_id' + t.index ['weapon_key1_id'], name: 'index_grid_weapons_on_weapon_key1_id' + t.index ['weapon_key2_id'], name: 'index_grid_weapons_on_weapon_key2_id' + t.index ['weapon_key3_id'], name: 'index_grid_weapons_on_weapon_key3_id' end - create_table "guidebooks", 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", null: false - t.string "description_en", null: false - t.string "description_jp", null: false - t.datetime "created_at", default: -> { "CURRENT_TIMESTAMP" }, null: false + create_table 'guidebooks', 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', null: false + t.string 'description_en', null: false + t.string 'description_jp', null: false + t.datetime 'created_at', default: -> { 'CURRENT_TIMESTAMP' }, null: false end - create_table "job_accessories", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "job_id" - t.string "name_en", null: false - t.string "name_jp", null: false - 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" + create_table 'job_accessories', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'job_id' + t.string 'name_en', null: false + t.string 'name_jp', null: false + 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 - create_table "job_skills", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "job_id" - t.string "name_en", null: false - t.string "name_jp", null: false - t.string "slug", null: false - t.integer "color", null: false - t.boolean "main", default: false - t.boolean "sub", default: false - t.boolean "emp", default: false - t.integer "order" - t.boolean "base", default: false - t.index ["job_id"], name: "index_job_skills_on_job_id" + create_table 'job_skills', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'job_id' + t.string 'name_en', null: false + t.string 'name_jp', null: false + t.string 'slug', null: false + t.integer 'color', null: false + t.boolean 'main', default: false + t.boolean 'sub', default: false + t.boolean 'emp', default: false + t.integer 'order' + t.boolean 'base', default: false + t.index ['job_id'], name: 'index_job_skills_on_job_id' end - create_table "jobs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "name_en" - t.string "name_jp" - t.integer "proficiency1" - t.integer "proficiency2" - t.string "row" - t.boolean "master_level", default: false, null: false - t.integer "order" - t.uuid "base_job_id" - t.string "granblue_id" - t.boolean "accessory", default: false - t.integer "accessory_type", default: 0 - t.boolean "ultimate_mastery", default: false, null: false - t.index ["base_job_id"], name: "index_jobs_on_base_job_id" + create_table 'jobs', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'name_en' + t.string 'name_jp' + t.integer 'proficiency1' + t.integer 'proficiency2' + t.string 'row' + t.boolean 'master_level', default: false, null: false + t.integer 'order' + t.uuid 'base_job_id' + t.string 'granblue_id' + t.boolean 'accessory', default: false + t.integer 'accessory_type', default: 0 + t.boolean 'ultimate_mastery', default: false, null: false + t.index ['base_job_id'], name: 'index_jobs_on_base_job_id' end - create_table "oauth_access_grants", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "resource_owner_id", null: false - t.uuid "application_id", null: false - t.string "token", null: false - t.integer "expires_in", null: false - t.text "redirect_uri", null: false - t.datetime "created_at", precision: nil, null: false - t.datetime "revoked_at", precision: nil - t.string "scopes" - t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true + create_table 'oauth_access_grants', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'resource_owner_id', null: false + t.uuid 'application_id', null: false + t.string 'token', null: false + t.integer 'expires_in', null: false + t.text 'redirect_uri', null: false + t.datetime 'created_at', precision: nil, null: false + t.datetime 'revoked_at', precision: nil + t.string 'scopes' + t.index ['token'], name: 'index_oauth_access_grants_on_token', unique: true end - create_table "oauth_access_tokens", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "resource_owner_id" - t.uuid "application_id" - t.string "token", null: false - t.string "refresh_token" - t.integer "expires_in" - t.datetime "revoked_at", precision: nil - t.datetime "created_at", precision: nil, null: false - t.string "scopes" - t.string "previous_refresh_token", default: "" - t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true - t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id" - t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true + create_table 'oauth_access_tokens', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'resource_owner_id' + t.uuid 'application_id' + t.string 'token', null: false + t.string 'refresh_token' + t.integer 'expires_in' + t.datetime 'revoked_at', precision: nil + t.datetime 'created_at', precision: nil, null: false + t.string 'scopes' + t.string 'previous_refresh_token', default: '' + t.index ['refresh_token'], name: 'index_oauth_access_tokens_on_refresh_token', unique: true + t.index ['resource_owner_id'], name: 'index_oauth_access_tokens_on_resource_owner_id' + t.index ['token'], name: 'index_oauth_access_tokens_on_token', unique: true end - create_table "oauth_applications", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "name", null: false - t.string "uid", null: false - t.string "secret", null: false - t.text "redirect_uri", null: false - t.string "scopes", default: "", null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true + create_table 'oauth_applications', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'name', null: false + t.string 'uid', null: false + t.string 'secret', null: false + t.text 'redirect_uri', null: false + t.string 'scopes', default: '', null: false + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index ['uid'], name: 'index_oauth_applications_on_uid', unique: true end - create_table "parties", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "user_id" - t.string "shortcode" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.boolean "extra", default: false, null: false - t.string "name" - t.text "description" - t.uuid "raid_id" - t.integer "element" - t.integer "weapons_count", default: 0 - t.uuid "job_id" - t.integer "master_level" - t.uuid "skill1_id" - t.uuid "skill2_id" - t.uuid "skill3_id" - t.uuid "skill0_id" - t.boolean "full_auto", default: false, null: false - t.boolean "auto_guard", default: false, null: false - t.boolean "charge_attack", default: true, null: false - t.integer "clear_time", default: 0, null: false - t.integer "button_count" - t.integer "chain_count" - t.integer "turn_count" - t.uuid "source_party_id" - t.uuid "accessory_id" - t.integer "characters_count", default: 0 - t.integer "summons_count", default: 0 - t.string "edit_key" - t.uuid "local_id" - t.integer "ultimate_mastery" - t.uuid "guidebook3_id" - t.uuid "guidebook1_id" - t.uuid "guidebook2_id" - t.boolean "auto_summon", default: false, null: false - t.boolean "remix", default: false, null: false - t.index ["accessory_id"], name: "index_parties_on_accessory_id" - t.index ["guidebook1_id"], name: "index_parties_on_guidebook1_id" - t.index ["guidebook2_id"], name: "index_parties_on_guidebook2_id" - t.index ["guidebook3_id"], name: "index_parties_on_guidebook3_id" - t.index ["job_id"], name: "index_parties_on_job_id" - t.index ["skill0_id"], name: "index_parties_on_skill0_id" - t.index ["skill1_id"], name: "index_parties_on_skill1_id" - t.index ["skill2_id"], name: "index_parties_on_skill2_id" - t.index ["skill3_id"], name: "index_parties_on_skill3_id" - t.index ["source_party_id"], name: "index_parties_on_source_party_id" - t.index ["user_id"], name: "index_parties_on_user_id" + create_table 'parties', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'user_id' + t.string 'shortcode' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.boolean 'extra', default: false, null: false + t.string 'name' + t.text 'description' + t.uuid 'raid_id' + t.integer 'element' + t.integer 'weapons_count', default: 0 + t.uuid 'job_id' + t.integer 'master_level' + t.uuid 'skill1_id' + t.uuid 'skill2_id' + t.uuid 'skill3_id' + t.uuid 'skill0_id' + t.boolean 'full_auto', default: false, null: false + t.boolean 'auto_guard', default: false, null: false + t.boolean 'charge_attack', default: true, null: false + t.integer 'clear_time', default: 0, null: false + t.integer 'button_count' + t.integer 'chain_count' + t.integer 'turn_count' + t.uuid 'source_party_id' + t.uuid 'accessory_id' + t.integer 'characters_count', default: 0 + t.integer 'summons_count', default: 0 + t.string 'edit_key' + t.uuid 'local_id' + t.integer 'ultimate_mastery' + t.uuid 'guidebook3_id' + t.uuid 'guidebook1_id' + t.uuid 'guidebook2_id' + t.boolean 'auto_summon', default: false, null: false + t.boolean 'remix', default: false, null: false + t.index ['accessory_id'], name: 'index_parties_on_accessory_id' + t.index ['guidebook1_id'], name: 'index_parties_on_guidebook1_id' + t.index ['guidebook2_id'], name: 'index_parties_on_guidebook2_id' + t.index ['guidebook3_id'], name: 'index_parties_on_guidebook3_id' + t.index ['job_id'], name: 'index_parties_on_job_id' + t.index ['skill0_id'], name: 'index_parties_on_skill0_id' + t.index ['skill1_id'], name: 'index_parties_on_skill1_id' + t.index ['skill2_id'], name: 'index_parties_on_skill2_id' + t.index ['skill3_id'], name: 'index_parties_on_skill3_id' + t.index ['source_party_id'], name: 'index_parties_on_source_party_id' + t.index ['user_id'], name: 'index_parties_on_user_id' end - create_table "pg_search_documents", force: :cascade do |t| - t.text "content" - t.string "granblue_id" - t.string "name_en" - t.string "name_jp" - t.integer "element" - t.string "searchable_type" - t.uuid "searchable_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["searchable_type", "searchable_id"], name: "index_pg_search_documents_on_searchable" + create_table 'pg_search_documents', force: :cascade do |t| + t.text 'content' + t.string 'granblue_id' + t.string 'name_en' + t.string 'name_jp' + t.integer 'element' + t.string 'searchable_type' + t.uuid 'searchable_id' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.index %w[searchable_type searchable_id], name: 'index_pg_search_documents_on_searchable' end - create_table "raid_groups", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "name_en", null: false - t.string "name_jp", null: false - t.integer "difficulty" - t.integer "order", null: false - t.integer "section", default: 1, null: false - t.boolean "extra", default: false, null: false - t.boolean "hl", default: true, null: false - t.boolean "guidebooks", default: false, null: false + create_table 'raid_groups', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'name_en', null: false + t.string 'name_jp', null: false + t.integer 'difficulty' + t.integer 'order', null: false + t.integer 'section', default: 1, null: false + t.boolean 'extra', default: false, null: false + t.boolean 'hl', default: true, null: false + t.boolean 'guidebooks', default: false, null: false end - create_table "raids", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "name_en" - t.string "name_jp" - t.integer "level" - t.integer "element" - t.string "slug" - t.uuid "group_id" - t.index ["group_id"], name: "index_raids_on_group_id" + create_table 'raids', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'name_en' + t.string 'name_jp' + t.integer 'level' + t.integer 'element' + t.string 'slug' + t.uuid 'group_id' + t.index ['group_id'], name: 'index_raids_on_group_id' end - create_table "sparks", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "user_id", null: false - t.string "guild_ids", null: false, array: true - t.integer "crystals", default: 0 - t.integer "tickets", default: 0 - t.integer "ten_tickets", default: 0 - t.string "target_type" - t.bigint "target_id" - t.datetime "updated_at", default: -> { "CURRENT_TIMESTAMP" }, null: false - t.string "target_memo" - t.index ["target_type", "target_id"], name: "index_sparks_on_target" - t.index ["user_id"], name: "index_sparks_on_user_id", unique: true + create_table 'sparks', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'user_id', null: false + t.string 'guild_ids', null: false, array: true + t.integer 'crystals', default: 0 + t.integer 'tickets', default: 0 + t.integer 'ten_tickets', default: 0 + t.string 'target_type' + t.bigint 'target_id' + t.datetime 'updated_at', default: -> { 'CURRENT_TIMESTAMP' }, null: false + t.string 'target_memo' + t.index %w[target_type target_id], name: 'index_sparks_on_target' + t.index ['user_id'], name: 'index_sparks_on_user_id', unique: true end - create_table "summons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "name_en" - t.string "name_jp" - t.string "granblue_id" - t.integer "rarity" - t.integer "element" - t.string "series" - t.boolean "flb", default: false, null: false - t.boolean "ulb", default: false, null: false - t.integer "max_level", default: 100, null: false - t.integer "min_hp" - t.integer "max_hp" - t.integer "max_hp_flb" - t.integer "max_hp_ulb" - t.integer "min_atk" - t.integer "max_atk" - t.integer "max_atk_flb" - t.integer "max_atk_ulb" - t.boolean "subaura", default: false, null: false - t.boolean "limit", default: false, null: false - t.boolean "xlb", default: false, null: false - t.integer "max_atk_xlb" - t.integer "max_hp_xlb" - t.string "nicknames_en", default: [], null: false, array: true - t.string "nicknames_jp", default: [], null: false, array: true - t.integer "summon_id" - t.date "release_date" - t.date "flb_date" - t.date "ulb_date" - t.string "wiki_en", default: "" - t.string "wiki_ja", default: "" - t.string "gamewith", default: "" - t.string "kamigame", default: "" - t.date "xlb_date" - t.index ["name_en"], name: "index_summons_on_name_en", opclass: :gin_trgm_ops, using: :gin + create_table 'summons', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'name_en' + t.string 'name_jp' + t.string 'granblue_id' + t.integer 'rarity' + t.integer 'element' + t.string 'series' + t.boolean 'flb', default: false, null: false + t.boolean 'ulb', default: false, null: false + t.integer 'max_level', default: 100, null: false + t.integer 'min_hp' + t.integer 'max_hp' + t.integer 'max_hp_flb' + t.integer 'max_hp_ulb' + t.integer 'min_atk' + t.integer 'max_atk' + t.integer 'max_atk_flb' + t.integer 'max_atk_ulb' + t.boolean 'subaura', default: false, null: false + t.boolean 'limit', default: false, null: false + t.boolean 'xlb', default: false, null: false + t.integer 'max_atk_xlb' + t.integer 'max_hp_xlb' + t.string 'nicknames_en', default: [], null: false, array: true + t.string 'nicknames_jp', default: [], null: false, array: true + t.integer 'summon_id' + t.date 'release_date' + t.date 'flb_date' + t.date 'ulb_date' + t.string 'wiki_en', default: '' + t.string 'wiki_ja', default: '' + t.string 'gamewith', default: '' + t.string 'kamigame', default: '' + t.date 'xlb_date' + t.index ['name_en'], name: 'index_summons_on_name_en', opclass: :gin_trgm_ops, using: :gin end - create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "email" - t.string "password_digest" - t.string "username" - t.integer "granblue_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "picture", default: "gran" - t.string "language", default: "en", null: false - t.boolean "private", default: false, null: false - t.string "element", default: "water", null: false - t.integer "gender", default: 0, null: false - t.string "theme", default: "system", null: false + create_table 'users', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'email' + t.string 'password_digest' + t.string 'username' + t.integer 'granblue_id' + t.datetime 'created_at', null: false + t.datetime 'updated_at', null: false + t.string 'picture', default: 'gran' + t.string 'language', default: 'en', null: false + t.boolean 'private', default: false, null: false + t.string 'element', default: 'water', null: false + t.integer 'gender', default: 0, null: false + t.string 'theme', default: 'system', null: false end - create_table "weapon_awakenings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.uuid "weapon_id", null: false - t.uuid "awakening_id", null: false - t.index ["awakening_id"], name: "index_weapon_awakenings_on_awakening_id" - t.index ["weapon_id"], name: "index_weapon_awakenings_on_weapon_id" + create_table 'weapon_awakenings', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.uuid 'weapon_id', null: false + t.uuid 'awakening_id', null: false + t.index ['awakening_id'], name: 'index_weapon_awakenings_on_awakening_id' + t.index ['weapon_id'], name: 'index_weapon_awakenings_on_weapon_id' end - create_table "weapon_keys", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "name_en" - t.string "name_jp" - t.integer "series" - t.integer "slot" - t.integer "group" - t.integer "order" - t.string "slug" - t.integer "granblue_id" + create_table 'weapon_keys', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'name_en' + t.string 'name_jp' + t.integer 'series' + t.integer 'slot' + t.integer 'group' + t.integer 'order' + t.string 'slug' + t.integer 'granblue_id' end - create_table "weapons", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| - t.string "name_en" - t.string "name_jp" - t.string "granblue_id" - t.integer "rarity" - t.integer "element" - t.integer "proficiency" - t.integer "series", default: -1, null: false - t.boolean "flb", default: false, null: false - t.boolean "ulb", default: false, null: false - t.integer "max_level", default: 100, null: false - t.integer "max_skill_level", default: 10, null: false - t.integer "min_hp" - t.integer "max_hp" - t.integer "max_hp_flb" - t.integer "max_hp_ulb" - t.integer "min_atk" - t.integer "max_atk" - t.integer "max_atk_flb" - t.integer "max_atk_ulb" - t.boolean "extra", default: false, null: false - t.integer "ax_type" - t.boolean "limit", default: false, null: false - t.boolean "ax", default: false, null: false - t.string "nicknames_en", default: [], null: false, array: true - t.string "nicknames_jp", default: [], null: false, array: true - t.uuid "recruits_id" - t.integer "max_awakening_level" - t.date "release_date" - t.date "flb_date" - t.date "ulb_date" - t.string "wiki_en", default: "" - t.string "wiki_ja", default: "" - t.string "gamewith", default: "" - t.string "kamigame", default: "" - t.index ["name_en"], name: "index_weapons_on_name_en", opclass: :gin_trgm_ops, using: :gin - t.index ["recruits_id"], name: "index_weapons_on_recruits_id" + create_table 'weapons', id: :uuid, default: -> { 'gen_random_uuid()' }, force: :cascade do |t| + t.string 'name_en' + t.string 'name_jp' + t.string 'granblue_id' + t.integer 'rarity' + t.integer 'element' + t.integer 'proficiency' + t.integer 'series', default: -1, null: false + t.boolean 'flb', default: false, null: false + t.boolean 'ulb', default: false, null: false + t.integer 'max_level', default: 100, null: false + t.integer 'max_skill_level', default: 10, null: false + t.integer 'min_hp' + t.integer 'max_hp' + t.integer 'max_hp_flb' + t.integer 'max_hp_ulb' + t.integer 'min_atk' + t.integer 'max_atk' + t.integer 'max_atk_flb' + t.integer 'max_atk_ulb' + t.boolean 'extra', default: false, null: false + t.integer 'ax_type' + t.boolean 'limit', default: false, null: false + t.boolean 'ax', default: false, null: false + t.string 'nicknames_en', default: [], null: false, array: true + t.string 'nicknames_jp', default: [], null: false, array: true + t.uuid 'recruits_id' + t.integer 'max_awakening_level' + t.date 'release_date' + t.date 'flb_date' + t.date 'ulb_date' + t.string 'wiki_en', default: '' + t.string 'wiki_ja', default: '' + t.string 'gamewith', default: '' + t.string 'kamigame', default: '' + t.index ['name_en'], name: 'index_weapons_on_name_en', opclass: :gin_trgm_ops, using: :gin + t.index ['recruits_id'], name: 'index_weapons_on_recruits_id' end - add_foreign_key "favorites", "parties" - add_foreign_key "favorites", "users" - add_foreign_key "grid_characters", "awakenings" - add_foreign_key "grid_characters", "characters" - add_foreign_key "grid_characters", "parties" - add_foreign_key "grid_summons", "parties" - add_foreign_key "grid_summons", "summons" - add_foreign_key "grid_weapons", "awakenings" - add_foreign_key "grid_weapons", "parties" - add_foreign_key "grid_weapons", "weapon_keys", column: "weapon_key3_id" - add_foreign_key "grid_weapons", "weapons" - add_foreign_key "jobs", "jobs", column: "base_job_id" - add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id" - add_foreign_key "oauth_access_tokens", "oauth_applications", column: "application_id" - add_foreign_key "parties", "guidebooks", column: "guidebook1_id" - add_foreign_key "parties", "guidebooks", column: "guidebook2_id" - add_foreign_key "parties", "guidebooks", column: "guidebook3_id" - add_foreign_key "parties", "job_accessories", column: "accessory_id" - add_foreign_key "parties", "job_skills", column: "skill0_id" - add_foreign_key "parties", "job_skills", column: "skill1_id" - add_foreign_key "parties", "job_skills", column: "skill2_id" - add_foreign_key "parties", "job_skills", column: "skill3_id" - add_foreign_key "parties", "jobs" - add_foreign_key "parties", "parties", column: "source_party_id" - add_foreign_key "parties", "raids" - add_foreign_key "parties", "users" - add_foreign_key "raids", "raid_groups", column: "group_id" - add_foreign_key "weapon_awakenings", "awakenings" - add_foreign_key "weapon_awakenings", "weapons" + add_foreign_key 'favorites', 'parties' + add_foreign_key 'favorites', 'users' + add_foreign_key 'grid_characters', 'awakenings' + add_foreign_key 'grid_characters', 'characters' + add_foreign_key 'grid_characters', 'parties' + add_foreign_key 'grid_summons', 'parties' + add_foreign_key 'grid_summons', 'summons' + add_foreign_key 'grid_weapons', 'awakenings' + add_foreign_key 'grid_weapons', 'parties' + add_foreign_key 'grid_weapons', 'weapon_keys', column: 'weapon_key3_id' + add_foreign_key 'grid_weapons', 'weapons' + add_foreign_key 'jobs', 'jobs', column: 'base_job_id' + add_foreign_key 'oauth_access_grants', 'oauth_applications', column: 'application_id' + add_foreign_key 'oauth_access_tokens', 'oauth_applications', column: 'application_id' + add_foreign_key 'parties', 'guidebooks', column: 'guidebook1_id' + add_foreign_key 'parties', 'guidebooks', column: 'guidebook2_id' + add_foreign_key 'parties', 'guidebooks', column: 'guidebook3_id' + add_foreign_key 'parties', 'job_accessories', column: 'accessory_id' + add_foreign_key 'parties', 'job_skills', column: 'skill0_id' + add_foreign_key 'parties', 'job_skills', column: 'skill1_id' + add_foreign_key 'parties', 'job_skills', column: 'skill2_id' + add_foreign_key 'parties', 'job_skills', column: 'skill3_id' + add_foreign_key 'parties', 'jobs' + add_foreign_key 'parties', 'parties', column: 'source_party_id' + add_foreign_key 'parties', 'raids' + add_foreign_key 'parties', 'users' + add_foreign_key 'raids', 'raid_groups', column: 'group_id' + add_foreign_key 'weapon_awakenings', 'awakenings' + add_foreign_key 'weapon_awakenings', 'weapons' end