From 8381c668bcb64c696444a415e9ed9fd1a10b22b2 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Fri, 25 Aug 2023 15:53:56 -0700 Subject: [PATCH] Implement roles and visibility (#128) * Add migrations to add user roles and party visibility. * Update schema.rb * Add admin check in User model * Implement rudimentary visibility of teams * Adds checks to Party model * Hides parties from collection views depending on visibility * Disallows viewing private parties if you're not the owner * Add a party's visibility to blueprint * Add admin mode The API Controller checks if the user is logged in and whether they are an admin, and checks for the X-Admin-Mode header * Implement admin mode overrides * Add admin_mode to authorize * Note to self: Implement user editing by admins * Fix syntax error with equality in SQL * Fix syntax error with method name * Fix bug in who can see restricted parties * Add privacy control to user profiles --- app/blueprints/api/v1/party_blueprint.rb | 2 +- app/controllers/api/v1/api_controller.rb | 16 +- app/controllers/api/v1/parties_controller.rb | 27 +- app/controllers/api/v1/users_controller.rb | 82 +- app/models/party.rb | 22 +- app/models/user.rb | 4 + .../20230824222028_add_role_to_users.rb | 5 + ...0230824222107_add_visibility_to_parties.rb | 5 + db/schema.rb | 962 +++++++++--------- 9 files changed, 600 insertions(+), 525 deletions(-) create mode 100644 db/migrate/20230824222028_add_role_to_users.rb create mode 100644 db/migrate/20230824222107_add_visibility_to_parties.rb diff --git a/app/blueprints/api/v1/party_blueprint.rb b/app/blueprints/api/v1/party_blueprint.rb index 9eec7d4..e6a77b5 100644 --- a/app/blueprints/api/v1/party_blueprint.rb +++ b/app/blueprints/api/v1/party_blueprint.rb @@ -35,7 +35,7 @@ module Api view :minimal do fields :name, :element, :shortcode, :favorited, :remix, :extra, :full_auto, :clear_time, :auto_guard, :auto_summon, - :created_at, :updated_at + :visibility, :created_at, :updated_at field :guidebooks do |p| { diff --git a/app/controllers/api/v1/api_controller.rb b/app/controllers/api/v1/api_controller.rb index fec9ce4..4b94c87 100644 --- a/app/controllers/api/v1/api_controller.rb +++ b/app/controllers/api/v1/api_controller.rb @@ -50,9 +50,17 @@ module Api @current_user end + def admin_mode + if current_user && current_user.admin? && request.headers['X-Admin-Mode'] + @admin_mode ||= request.headers['X-Admin-Mode'] == 'true' + end + + @admin_mode + end + def edit_key @edit_key ||= request.headers['X-Edit-Key'] if request.headers['X-Edit-Key'] - + @edit_key end @@ -96,9 +104,9 @@ module Api def render_not_found_response(object) render json: ErrorBlueprint.render(nil, error: { - message: "#{object.capitalize} could not be found", - code: 'not_found' - }), status: :not_found + message: "#{object.capitalize} could not be found", + code: 'not_found' + }), status: :not_found end def render_unauthorized_response diff --git a/app/controllers/api/v1/parties_controller.rb b/app/controllers/api/v1/parties_controller.rb index 9c25f5a..66b4dc1 100644 --- a/app/controllers/api/v1/parties_controller.rb +++ b/app/controllers/api/v1/parties_controller.rb @@ -32,6 +32,11 @@ module Api end def show + # If a party is private, check that the user is the owner or an admin + if (@party.private? && !current_user) || (@party.private? && not_owner && !admin_mode) + return render_unauthorized_response + end + return render json: PartyBlueprint.render(@party, view: :full, root: :party) if @party render_not_found_response('project') @@ -90,7 +95,7 @@ module Api conditions = build_filters conditions[:favorites] = { user_id: current_user.id } - query = build_query(conditions, true) + query = build_query(conditions, favorites: true) query = apply_includes(query, params[:includes]) if params[:includes].present? query = apply_excludes(query, params[:excludes]) if params[:excludes].present? @@ -104,7 +109,11 @@ module Api private def authorize - render_unauthorized_response if @party.user != current_user || @party.edit_key != edit_key + render_unauthorized_response if (not_owner && !admin_mode) || (@party.edit_key != edit_key && !admin_mode) + end + + def not_owner + current_user && @party.user != current_user end def build_filters @@ -152,11 +161,12 @@ module Api value.to_i unless value.blank? || value.to_i == -1 end - def build_query(conditions, favorites = false) + def build_query(conditions, favorites: false) query = Party.distinct .joins(weapons: [:object], summons: [:object], characters: [:object]) .group('parties.id') .where(conditions) + .where(privacy(favorites: favorites)) .where(name_quality) .where(user_quality) .where(original) @@ -242,6 +252,16 @@ module Api }) end + def privacy(favorites: false) + return if admin_mode + + if favorites + 'visibility < 3' + else + 'visibility = 1' + end + end + def user_quality 'user_id IS NOT NULL' unless request.params[:user_quality].blank? || request.params[:user_quality] == 'false' end @@ -329,6 +349,7 @@ module Api :description, :raid_id, :job_id, + :visibility, :accessory_id, :skill0_id, :skill1_id, diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index b1afff2..ed923bb 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -41,6 +41,8 @@ module Api render_validation_error_response(@user) end + # TODO: Allow admins to update other users + def update render json: UserBlueprint.render(@user, view: :minimal) if @user.update(user_params) end @@ -57,13 +59,14 @@ module Api conditions[:user_id] = @user.id parties = Party - .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 do |party| + .where(conditions) + .where(name_quality) + .where(user_quality) + .where(original) + .where(privacy) + .order(created_at: :desc) + .paginate(page: request.params[:page], per_page: COLLECTION_PER_PAGE) + .each do |party| party.favorited = current_user ? party.is_favorited(current_user) : false end @@ -98,7 +101,7 @@ module Api unless params['recency'].blank? start_time = (DateTime.current - params['recency'].to_i.seconds) - .to_datetime.beginning_of_day + .to_datetime.beginning_of_day end min_characters_count = params['characters_count'].blank? ? DEFAULT_MIN_CHARACTERS : params['characters_count'].to_i @@ -113,9 +116,18 @@ module Api 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 + unless params['full_auto'].blank? || params['full_auto'].to_i == -1 + hash[:full_auto] = + params['full_auto'].to_i + end + unless params['auto_guard'].blank? || params['auto_guard'].to_i == -1 + hash[:auto_guard] = + params['auto_guard'].to_i + end + unless params['charge_attack'].blank? || params['charge_attack'].to_i == -1 + hash[:charge_attack] = + params['charge_attack'].to_i + end # 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? @@ -131,38 +143,44 @@ module Api end def original - unless params.key?('original') || params['original'].blank? || params['original'] == '0' - "source_party_id IS NULL" - end + return if params.key?('original') || params['original'].blank? || params['original'] == '0' + + 'source_party_id IS NULL' end def user_quality - unless params.key?('user_quality') || params[:user_quality].nil? || params[:user_quality] == "0" - "user_id IS NOT NULL" - end + return if params.key?('user_quality') || params[:user_quality].nil? || params[:user_quality] == '0' + + 'user_id IS NOT NULL' 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(',') - unless params.key?('name_quality') || params[:name_quality].nil? || params[:name_quality] == "0" - "name NOT IN (#{joined_names})" - end + return if params.key?('name_quality') || params[:name_quality].nil? || params[:name_quality] == '0' + + "name NOT IN (#{joined_names})" + end + + def privacy + return if admin_mode + + 'visibility = 1' if current_user != @user end # Specify whitelisted properties that can be modified. diff --git a/app/models/party.rb b/app/models/party.rb index 122eeb7..0132996 100644 --- a/app/models/party.rb +++ b/app/models/party.rb @@ -105,17 +105,29 @@ class Party < ApplicationRecord end def is_remix - self.source_party != nil + !source_party.nil? end def remixes - Party.where(source_party_id: self.id) + Party.where(source_party_id: id) end def blueprint PartyBlueprint end + def public? + visibility == 1 + end + + def unlisted? + visibility == 2 + end + + def private? + visibility == 3 + end + private def set_shortcode @@ -123,9 +135,9 @@ class Party < ApplicationRecord end def set_edit_key - if !self.user - self.edit_key = Digest::SHA1.hexdigest([Time.now, rand].join) - end + return if user + + self.edit_key = Digest::SHA1.hexdigest([Time.now, rand].join) end def random_string diff --git a/app/models/user.rb b/app/models/user.rb index 215885e..48c4f5f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -43,6 +43,10 @@ class User < ApplicationRecord favorites.map(&:party) end + def admin? + role == 9 + end + def blueprint UserBlueprint end diff --git a/db/migrate/20230824222028_add_role_to_users.rb b/db/migrate/20230824222028_add_role_to_users.rb new file mode 100644 index 0000000..eeac9ca --- /dev/null +++ b/db/migrate/20230824222028_add_role_to_users.rb @@ -0,0 +1,5 @@ +class AddRoleToUsers < ActiveRecord::Migration[7.0] + def change + add_column :users, :role, :integer, default: 1, null: false + end +end diff --git a/db/migrate/20230824222107_add_visibility_to_parties.rb b/db/migrate/20230824222107_add_visibility_to_parties.rb new file mode 100644 index 0000000..8cf0159 --- /dev/null +++ b/db/migrate/20230824222107_add_visibility_to_parties.rb @@ -0,0 +1,5 @@ +class AddVisibilityToParties < ActiveRecord::Migration[7.0] + def change + add_column :parties, :visibility, :integer, default: 1, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 2036d65..8d4f9ab 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,548 +10,550 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 20_230_820_113_900) do +ActiveRecord::Schema[7.0].define(version: 2023_08_24_222107) 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 %w[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 ["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.integer "visibility", default: 1, 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 %w[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 ["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 %w[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 ["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 + t.integer "role", default: 1, 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