Merge pull request #31 from jedmund/db-cleanup

Database schema updates
This commit is contained in:
Justin Edmund 2023-01-02 21:47:27 -08:00 committed by GitHub
commit 6c02106c49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 195 additions and 12 deletions

View file

@ -43,6 +43,9 @@ gem 'pg_search'
# Pagination library
gem 'will_paginate', '~> 3.3'
# Migrate and update data alongside your database structure.
gem 'data_migrate'
group :doc do
gem 'apipie-rails'
gem 'sdoc'

View file

@ -80,6 +80,9 @@ GEM
byebug (11.1.3)
concurrent-ruby (1.1.9)
crass (1.0.6)
data_migrate (8.5.0)
activerecord (>= 5.0)
railties (>= 5.0)
database_cleaner (2.0.1)
database_cleaner-active_record (~> 2.0.0)
database_cleaner-active_record (2.0.1)
@ -131,12 +134,12 @@ GEM
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
mini_portile2 (2.6.1)
minitest (5.14.4)
msgpack (1.4.2)
nio4r (2.5.8)
nokogiri (1.12.5-arm64-darwin)
racc (~> 1.4)
nokogiri (1.12.5-x86_64-linux)
nokogiri (1.12.5)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
oj (3.13.9)
parallel (1.21.0)
@ -276,8 +279,7 @@ GEM
zeitwerk (2.5.1)
PLATFORMS
arm64-darwin-21
x86_64-linux
ruby
DEPENDENCIES
api_matchers
@ -288,6 +290,7 @@ DEPENDENCIES
blueprinter
bootsnap
byebug
data_migrate
database_cleaner
doorkeeper
dotenv-rails

View file

@ -0,0 +1,17 @@
# frozen_string_literal: true
class MigrateLimitToBoolean < ActiveRecord::Migration[6.1]
def up
Weapon.all.each do |weapon|
weapon.limit2 = weapon.limit > 0
end
Summon.all.each do |summon|
summon.limit2 = summon.limit > 0
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

View file

@ -0,0 +1,19 @@
# frozen_string_literal: true
class MigrateLimitValueToLimit2 < ActiveRecord::Migration[6.1]
def up
Weapon.all.each do |weapon|
weapon.limit2 = !(weapon.limit == 0)
weapon.save
end
Summon.all.each do |summon|
summon.limit2 = !(summon.limit == 0)
summon.save
end
end
def down
# raise ActiveRecord::IrreversibleMigration
end
end

View file

@ -0,0 +1,20 @@
# frozen_string_literal: true
class MigrateAxTypeToAx < ActiveRecord::Migration[6.1]
def up
Weapon.all.each do |weapon|
if weapon.ax_type > 0
weapon.ax = true
elsif weapon.ax_type == 0
weapon.ax = false
weapon.ax_type = nil
end
weapon.save
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

View file

@ -0,0 +1,21 @@
# frozen_string_literal: true
class SetFlbToFalseOnSummons < ActiveRecord::Migration[6.1]
def up
Summon.all.each do |summon|
if summon.flb.nil?
summon.flb = false
summon.save
end
if summon.ulb.nil?
summon.ulb = false
summon.save
end
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

1
db/data_schema.rb Normal file
View file

@ -0,0 +1 @@
DataMigrate::Data.define(version: 20230102235227)

View file

@ -0,0 +1,6 @@
class ChangeLimitToBoolean < ActiveRecord::Migration[6.1]
def change
add_column :weapons, :limit2, :boolean, default: false, null: false
add_column :summons, :limit2, :boolean, default: false, null: false
end
end

View file

@ -0,0 +1,5 @@
class RemoveLimitFromWeapons < ActiveRecord::Migration[6.1]
def change
remove_column :weapons, :limit, :integer
end
end

View file

@ -0,0 +1,5 @@
class RenameLimit2OnWeapon < ActiveRecord::Migration[6.1]
def change
rename_column :weapons, :limit2, :limit
end
end

View file

@ -0,0 +1,5 @@
class RemoveLimitFromSummons < ActiveRecord::Migration[6.1]
def change
remove_column :summons, :limit, :integer
end
end

View file

@ -0,0 +1,5 @@
class RenameLimit2OnSummons < ActiveRecord::Migration[6.1]
def change
rename_column :summons, :limit2, :limit
end
end

View file

@ -0,0 +1,5 @@
class RenameAxToAxTypeOnWeapons < ActiveRecord::Migration[6.1]
def change
rename_column :weapons, :ax, :ax_type
end
end

View file

@ -0,0 +1,5 @@
class AddBooleanAxToWeapons < ActiveRecord::Migration[6.1]
def change
add_column :weapons, :ax, :boolean
end
end

View file

@ -0,0 +1,6 @@
class ChangeAxAxTypeProperties < ActiveRecord::Migration[6.1]
def change
change_column :weapons, :ax, :boolean, null: false, default: false
change_column :weapons, :ax_type, :integer, null: true, default: nil
end
end

View file

@ -0,0 +1,5 @@
class AddXlbToSummons < ActiveRecord::Migration[6.1]
def change
add_column :summons, :xlb, :boolean, default: false, null: false
end
end

View file

@ -0,0 +1,7 @@
class SetDefaultsOnSummons < ActiveRecord::Migration[6.1]
def change
change_column :summons, :flb, :boolean, null: false, default: false
change_column :summons, :ulb, :boolean, null: false, default: false
change_column :summons, :max_level, :integer, null: false, default: 100
end
end

View file

@ -0,0 +1,5 @@
class AddTranscendenceStepToGridCharacters < ActiveRecord::Migration[6.1]
def change
add_column :grid_characters, :transcendence_step, :integer, default: 0, null: false
end
end

View file

@ -0,0 +1,5 @@
class AddTranscendenceStepToGridSummons < ActiveRecord::Migration[6.1]
def change
add_column :grid_summons, :transcendence_step, :integer, default: 0, null: false
end
end

View file

@ -0,0 +1,18 @@
class AddRingsEarringsToGridCharacters < ActiveRecord::Migration[6.1]
def change
add_column :grid_characters, :ring_modifier1, :integer
add_column :grid_characters, :ring_strength1, :float
add_column :grid_characters, :ring_modifier2, :integer
add_column :grid_characters, :ring_strength2, :float
add_column :grid_characters, :ring_modifier3, :integer
add_column :grid_characters, :ring_strength3, :float
add_column :grid_characters, :ring_modifier4, :integer
add_column :grid_characters, :ring_strength4, :float
add_column :grid_characters, :earring_modifier, :integer
add_column :grid_characters, :earring_strength, :float
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_12_26_054501) do
ActiveRecord::Schema.define(version: 2023_01_02_235042) do
# These are extensions that must be enabled in order to support this database
enable_extension "btree_gin"
@ -48,6 +48,9 @@ ActiveRecord::Schema.define(version: 2022_12_26_054501) do
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|
end
create_table "favorites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "user_id"
t.uuid "party_id"
@ -67,6 +70,17 @@ ActiveRecord::Schema.define(version: 2022_12_26_054501) do
t.boolean "perpetuity", default: false, null: false
t.integer "awakening_type", default: 0, null: false
t.integer "awakening_level", default: 1, null: false
t.integer "transcendence_step", default: 0, null: false
t.integer "ring_modifier1"
t.float "ring_strength1"
t.integer "ring_modifier2"
t.float "ring_strength2"
t.integer "ring_modifier3"
t.float "ring_strength3"
t.integer "ring_modifier4"
t.float "ring_strength4"
t.integer "earring_modifier"
t.float "earring_strength"
t.index ["character_id"], name: "index_grid_characters_on_character_id"
t.index ["party_id"], name: "index_grid_characters_on_party_id"
end
@ -80,6 +94,7 @@ ActiveRecord::Schema.define(version: 2022_12_26_054501) do
t.integer "position"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.integer "transcendence_step", default: 0, 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
@ -211,9 +226,9 @@ ActiveRecord::Schema.define(version: 2022_12_26_054501) do
t.integer "rarity"
t.integer "element"
t.string "series"
t.boolean "flb"
t.boolean "ulb"
t.integer "max_level"
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"
@ -223,7 +238,8 @@ ActiveRecord::Schema.define(version: 2022_12_26_054501) do
t.integer "max_atk_flb"
t.integer "max_atk_ulb"
t.boolean "subaura", default: false, null: false
t.integer "limit"
t.boolean "limit", default: false, null: false
t.boolean "xlb", default: false, null: false
t.index ["name_en"], name: "index_summons_on_name_en", opclass: :gin_trgm_ops, using: :gin
end
@ -273,9 +289,10 @@ ActiveRecord::Schema.define(version: 2022_12_26_054501) do
t.integer "max_atk_flb"
t.integer "max_atk_ulb"
t.boolean "extra", default: false, null: false
t.integer "limit"
t.integer "ax", default: 0, null: false
t.integer "ax_type"
t.boolean "awakening", default: true, null: false
t.boolean "limit", default: false, null: false
t.boolean "ax", default: false, null: false
t.index ["name_en"], name: "index_weapons_on_name_en", opclass: :gin_trgm_ops, using: :gin
end