diff --git a/app/models/faction.rb b/app/models/faction.rb index 7a2d75c8..de5a7912 100644 --- a/app/models/faction.rb +++ b/app/models/faction.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -# TODO(plural): add a side code to faction. class Faction < ApplicationRecord + belongs_to :side has_many :cards end diff --git a/app/models/side.rb b/app/models/side.rb index e160c981..936da615 100644 --- a/app/models/side.rb +++ b/app/models/side.rb @@ -2,4 +2,5 @@ class Side < ApplicationRecord has_many :cards + has_many :factions end diff --git a/db/schema.rb b/db/schema.rb index d5b07fb2..237f84f9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -81,6 +81,7 @@ create_table "factions", id: :string, force: :cascade do |t| t.boolean "is_mini", null: false t.text "name", null: false + t.text "side_id", null: false t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false end @@ -118,6 +119,7 @@ add_foreign_key "cards", "card_types", column: "card_type_id", primary_key: "id" add_foreign_key "cards", "factions", column: "faction_id", primary_key: "id" add_foreign_key "cards", "sides", column: "side_id", primary_key: "id" + add_foreign_key "factions", "sides", column: "side_id", primary_key: "id" add_foreign_key "printings", "cards", column: "card_id", primary_key: "id" add_foreign_key "printings", "card_sets", column: "card_set_id", primary_key: "id" end diff --git a/lib/tasks/cards.rake b/lib/tasks/cards.rake index 6c8eae7f..68b7ef16 100644 --- a/lib/tasks/cards.rake +++ b/lib/tasks/cards.rake @@ -68,6 +68,7 @@ namespace :cards do factions.map! do |f| { id: f['code'], + side_id: f['side_code'], name: f['name'], is_mini: f['is_mini'] }