Skip to content

Instantly share code, notes, and snippets.

@JackHowa
Created April 12, 2017 22:23
Show Gist options
  • Save JackHowa/ed9e579859ccecae49fc42ee675df051 to your computer and use it in GitHub Desktop.
Save JackHowa/ed9e579859ccecae49fc42ee675df051 to your computer and use it in GitHub Desktop.
20170412active_records-editing
Pre-release: Set up Database with Old Schema
$ bundle install
$ bundle exec rake db:create
$ bundle exec rake db:migrate
bundle exec rake generate:migration NAME=RemoveWeightFromDogs
class RemoveWeightFromDogs < ActiveRecord::Migration
def change
remove_column :dogs, :weight
end
end
run that ... bundle exec rake db:migrate
bundle exec rake generate:migration NAME=AddBreedToDogs
add_column :breed
rails --generate migration add_breed_to_dogs breed:string
add_column :dogs, :breed, :string
add_index :dogs, :breed
has a integer column named judge_id (FAILED - 1)
no longer has a column named rater_id (FAILED - 2)
generate migration AddJudgeIdToRating judge_id:integer
lowercase id is important for constant error
bundle exec rake generate:migration NAME=DeleteRaterIDFromRatings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment