28
loading...
This website collects cookies to deliver better user experience
bundle exec rake db:create_migration NAME="create_pets"
20211206094530_create_pets.rb
class CreatePets < ActiveRecord::Migration[6.1]
def change
end
end
create_table
method:class CreatePets < ActiveRecord::Migration[6.1]
def change
create_table :pets do |t|
t.string :name
t.string :breed
t.boolean :spayed_neutered
t.integer :owner_id
t.timestamps
end
end
end
20211206094530_create_pets.rb
file, you have to run the following command in your CLI:bundle exec rake db:migrate
ActiveRecord::Schema.define(version: 2021_12_03_225736) do
create_table "pets", force: :cascade do |t|
t.string "name"
t.string "breed"
t.boolean "spayed_neutered"
t.integer "owner_id"
t.datetime "created_at"
t.datetime "updated_at
end
end
db:migrate
command, you can run bundle exec rake db:rollback
to bring yourself back one version history, edit the file, and run bundle exec db:migrate
again. create_table
method in this example, but naturally there are many more methods at your disposal. You can find them, and more information, here.