Trying to create a standalone migration file, db:migrate

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

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

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

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.