I am developing a system where tables have many to many relationship
with each other.
I am creating tables thru migration scripts. I wanted to use rake
migration command to auto create m tables in my oracle database.
When I give rake migration only two migration scripts out of 8 scripts
get executed and only 2 tables get created in my database. Rest of the
migration scripts are not executed. The scripts that get executed are
very simple ones like the one below
class CreateAmSoftwareCategories < ActiveRecord::Migration
def self.up
create_table :am_software_categories do |t|
t.column :software_category, :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_software_categories
end
end
But the tables that I want to have many to many relations are not
created in my oracle express edition database.
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?
--
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 post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---