Rake migrations with namespace (prefix)

I have access to a shared database. So, I wanted to create my
application tables with a prefix “cmro_”. So, I did this:

  1. I edited config/environment.rb and added this line:
    config.active_record.table_name_prefix = ‘cmro_’
  2. I ran rake db:migrate. But I kept getting errors (pasted below).
    Any suggestions on how to fix these?
  3. I am also not sure how to clean the database again. Is there some
    sort of rake db:destroy to clean-up all the tables that rake created?

*FIRST ATTEMPT
bash-3.00$ rake db:migrate
(in /work/storage/ror1-workdir/cmro)
== CreateTemplates: migrating

– create_table(:config_templates)
-> 0.8753s
== CreateTemplates: migrated (0.8757s)

== CreateVariables: migrating

– create_table(:variables)
-> 0.2370s
== CreateVariables: migrated (0.2374s)

== CustomSectionNames: migrating

– add_column(:config_templates, :xml_1_name, :string)
-> 0.0143s
-> 0 rows
– add_column(:config_templates, :xml_2_name, :string)
-> 0.0327s
-> 0 rows
– add_column(:config_templates, :xml_3_name, :string)
-> 0.0332s
-> 0 rows
– add_column(:config_templates, :xml_4_name, :string)
-> 0.0333s
-> 0 rows
– add_column(:config_templates, :xml_5_name, :string)
-> 0.0329s
-> 0 rows
== CustomSectionNames: migrated (0.1950s)

== CreateBuilds: migrating

– create_table(:builds)
-> 1.1915s
== CreateBuilds: migrated (1.1918s)

== AddPathFieldToBuilds: migrating

– add_column(:builds, :path_id, :integer)
-> 0.0175s
-> 0 rows
– execute(“TRUNCATE TABLE builds”)
rake aborted!
An error has occurred, all later migrations canceled:

OCIError: ORA-00942: table or view does not exist: TRUNCATE TABLE
builds

(See full trace by running task with --trace)

SECOND ATTEMPT****
bash-3.00$ rake db:migrate --trace
(in /work/storage/ror1-workdir/cmro)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
== AddPathFieldToBuilds: migrating

– add_column(:builds, :path_id, :integer)
rake aborted!
An error has occurred, all later migrations canceled:

OCIError: ORA-01430: column being added already exists in table: ALTER
TABLE cmro_builds ADD path_id NUMBER(38)
/opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/connection_adapters/abstract_adapter.rb:219:in log' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced- adapter-1.2.1/lib/active_record/connection_adapters/ oracle_enhanced_adapter.rb:460:inexecute’
/opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-
adapter-1.2.1/lib/active_record/connection_adapters/
oracle_enhanced_adapter.rb:765:in add_column' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:352:insend’
/opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/migration.rb:352:in method_missing' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:328:insay_with_time’
/opt/coolstack/lib/ruby/1.8/benchmark.rb:293:in measure' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:328:insay_with_time’
/opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/migration.rb:348:in method_missing' ./db/migrate//20090724110935_add_path_field_to_builds.rb:3:inup_without_benchmarks’
/opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/migration.rb:282:in send' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:282:inmigrate’
/opt/coolstack/lib/ruby/1.8/benchmark.rb:293:in measure' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:282:inmigrate’
/opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/migration.rb:365:in __send__' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:365:inmigrate’
/opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/migration.rb:486:in migrate' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:562:incall’
/opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/migration.rb:562:in ddl_transaction' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:485:inmigrate’
/opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/migration.rb:472:in each' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:472:inmigrate’
/opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/migration.rb:400:in up' /opt/coolstack/lib/ruby/gems/1.8/gems/activerecord-2.3.4/lib/ active_record/migration.rb:383:inmigrate’
/opt/coolstack/lib/ruby/gems/1.8/gems/rails-2.3.4/lib/tasks/
databases.rake:116
/opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
call' /opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute’
/opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
each' /opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute’
/opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
invoke_with_call_chain' /opt/coolstack/lib/ruby/1.8/monitor.rb:242:insynchronize’
/opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
invoke_with_call_chain' /opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke’
/opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
invoke_task' /opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level’
/opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
each' /opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level’
/opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exception_handling' /opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:intop_level’
/opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in
run' /opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling’
/opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in
run' /opt/coolstack/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31 /opt/coolstack/bin/rake:19:inload’
/opt/coolstack/bin/rake:19


Thanks!