Fred wrote:
Did you run rake befor you were finished with your migrations ? This is
easily done, and once rake has run a migration one it won’t (by itself)
run those migrations again, even if you have changed them. The easiest
thing to do is probably to blow away the contents of your database.
Fred
Hi Fred,
I created all the migrations and then I gave the command rake
migration.
I also ran rake migrate --trace
I get the following output
C:\InstantRails\InstantRails\rails_apps\asset>rake migrate --trace
(in C:/InstantRails/InstantRails/rails_apps/asset)
** Invoke migrate (first_time)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
** Execute migrate
I have 8 migration scripts but rake picks up only two of them. Few of my
other migration scripts define many to many relation. For example I have
two tables am_applications and am_developers.
For these two tables, I have two scripts.
The first 001_create_am_applications.rb is as follows
class CreateAmApplications < ActiveRecord::Migration
def self.up
create_table :am_applications do |t|
t.column :business_application_name, :string
t.column :developed_by, :string
t.column :maintained_by, :string
t.column :exposed_on_openview, :string
t.column :primary_contact, :string
t.column :backup_contact, :string
t.column :remarks, :string
t.column :created_on, :datetime
t.column :created_at, :datetime
t.column :updated_on, :datetime
t.column :updated_at, :datetime
t.column :lock_version, :integer
end
end
def self.down
drop_table :am_applications
end
end
The second one 003_create_am_developers.rb is as follows
class CreateAmDevelopers < ActiveRecord::Migration
def self.up
create_table :am_developers do |t|
t.column :name, :string
t.column :software_expertise, :string
t.column :application_expertise, :string
t.column :other_expertise, :string
t.column :remarks, :string
t.column :created_on, :datetime
t.column :created_at, :datetime
t.column :updated_on, :datetime
t.column :updated_at, :datetime
t.column :lock_version, :integer
end
create_table(“am_applications_am_developers”, :id=>false) do |t|
t.column “am_application_id”, :integer
t.column “am_developer_id”, :integer
end
end
def self.down
drop_table :am_developers
end
end
Note that I introduced the join table between application and developers
in the same class as CreateAmdeveloepers.
So when I do rake migrate the above two and other tables having same
relationship do not get migrated.
I was wondering if defining the migration scripts in above format is the
cause or there is nothing wrong with the way migration scripts are
created and there could be problems with rake?