# Rake migrations with namespace (prefix)

**URL:** <https://www.ruby-forum.com/t/rake-migrations-with-namespace-prefix/175741>\
**Category:** Rails\
**Created:** [September 18, 2009, 8:40pm UTC](https://www.ruby-forum.com/t/rake-migrations-with-namespace-prefix/175741 "2009-09-18T20:40:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![catel1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/258eb7/32.png) [@catel1](https://www.ruby-forum.com/u/catel1)\
**Post date:** [September 18, 2009, 8:40pm UTC](https://www.ruby-forum.com/t/rake-migrations-with-namespace-prefix/175741/1 "2009-09-18T20:40:36Z")

</div>

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:in`execute’  
/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:in`send’  
/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:in`say\_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:in`say\_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:in`up\_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:in`migrate’  
/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:in`migrate’  
/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:in`migrate’  
/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:in`call’  
/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:in`migrate’  
/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:in`migrate’  
/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:in`migrate’  
/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:in`execute’  
/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:in`execute’  
/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:in`synchronize’  
/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:in`invoke’  
/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:in`top\_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:in`top\_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:in`top\_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:in`standard\_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:in`load’  
/opt/coolstack/bin/rake:19

* * *

Thanks!
