Trying to create a standalone migration file, db:migrate

51 views
Skip to first unread message

Dmoneyzzz Darko

unread,
Nov 28, 2014, 4:44:20 PM11/28/14
to rubyonra...@googlegroups.com
I have this code placed in my project's bin/rails directory:

#!/usr/bin/env ruby.exe
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'

generate migration add_physician_id_to_appointment

and I then I ran a db:migrate.

I don't think my code is placed correctly to generate a new migration
file for my database. I am trying to create a standalone migration with
the code below:

class Appointment < ActiveRecord::Migration
def change
add_column :physician_id, :integer
end
end

I am using this resource:
http://guides.rubyonrails.org/migrations.html#creating-a-standalone-migration

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Nov 28, 2014, 5:01:17 PM11/28/14
to rubyonra...@googlegroups.com
I don't understand why you have made a file in bin/rails. There is no
need to do that. You must first generate the migration using the
command
rails generate migration ...
from the command line. That will generate the migration file in
db/migrate, then you have a look there to make sure it is correct and
then run
rake db:migrate
to apply the migration.

I suspect you are just starting with rails, in which case I recommend
working right through a good tutorial such as railstutorial.org (which
is free to use online). That will show you the basics of rails,
including how to use migrations.

Colin

>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f6d0d58cebaf05d310bc194cd9c8ee6b%40ruby-forum.com.
> For more options, visit https://groups.google.com/d/optout.

Dmoneyzzz Darko

unread,
Nov 28, 2014, 5:23:14 PM11/28/14
to rubyonra...@googlegroups.com
Colin Law wrote in post #1163577:
> rails generate migration ...
> from the command line. That will generate the migration file in
> db/migrate, then you have a look there to make sure it is correct and
> then run
> rake db:migrate
> to apply the migration.
>
> I recommend working right through a good tutorial such as
> railstutorial.org (which is free to use online). That will show you
> the basics of rails, including how to use migrations.
>
> Colin

Thanks Colin for the resource and help!

My problem is resolved.
Reply all
Reply to author
Forward
0 new messages