git clone https://github.com/oliveira-andre/includes_states_cities.git
rails runner lib/cities_includes.rb
class CreateStates < ActiveRecord::Migration[5.2]
def change
create_table :states do |t|
t.string :description
t.timestamps
end
end
end
class CreateCities < ActiveRecord::Migration[5.2]
def change
create_table :cities do |t|
t.string :description
t.references :state, foreign_key: true
t.timestamps
end
end
end
create_table "cities", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "description"
t.bigint "state_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["state_id"], name: "index_cities_on_state_id"
end
create_table "states", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
t.string "description"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end