class CreateLibraryHoldings < ActiveRecord::Migration[6.0]
  def change
    create_table :library_holdings do |t|
      t.references :school, type: :integer, null: false, index: false,
        foreign_key: { to_table: :Schools, primary_key: :SchoolID }
      t.references :location, foreign_key: { to_table: :library_locations }
      t.references :item_condition, foreign_key: { to_table: :library_item_conditions }

      t.string :barcode
      t.string :call_number, limit: 30
      t.decimal :cost, scale: 2, precision: 20

      t.timestamps

      t.index [:school_id, :barcode], unique: true
    end
  end
end
