class CreateCourses < ActiveRecord::Migration[6.0]
  def change
    create_table :courses do |t|
      t.references :school, null: false, type: :integer,
        foreign_key: { to_table: :Schools, primary_key: :SchoolID },
        on_delete: :cascade
      t.references :department, type: :integer,
        foreign_key: { to_table: :Departments, primary_key: :DepartmentID },
        on_delete: :nullify

      t.string :name, limit: 56, null: false
      t.string :code, limit: 32
      t.boolean :archived, null: false, default: false

      t.timestamps
    end
  end
end
