# One db - many rails projects -\> many schema\_migrations table

**URL:** <https://www.ruby-forum.com/t/one-db-many-rails-projects-many-schema-migrations-table/142274>\
**Category:** Rails\
**Created:** [July 5, 2008, 7:20pm UTC](https://www.ruby-forum.com/t/one-db-many-rails-projects-many-schema-migrations-table/142274 "2008-07-05T19:20:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![schaf88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@schaf88](https://www.ruby-forum.com/u/schaf88)\
**Post date:** [July 5, 2008, 7:20pm UTC](https://www.ruby-forum.com/t/one-db-many-rails-projects-many-schema-migrations-table/142274/1 "2008-07-05T19:20:31Z")

</div>

Hi all!

How can I change the name of the schema\_migrations table? I have to do  
this because I can only use one database but want to have several rails  
projects.  
I hope this is possible at all.  
greets  
flo schaf

---

<div class="post-metadata">

**Author:** ![schaf88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@schaf88](https://www.ruby-forum.com/u/schaf88)\
**Post date:** [July 5, 2008, 9:48pm UTC](https://www.ruby-forum.com/t/one-db-many-rails-projects-many-schema-migrations-table/142274/2 "2008-07-05T21:48:03Z")

</div>

Interesting! Depending on which database you are using, you can explore  
different database schemas owned by different users within the same  
physical database. I know that Oracle and MySQL use different  
terminology to achieve the same results. Mainly, though, I recommend  
that you drive this differentiation by creating different schema owner  
accounts that have visibility to the set of common tables and hide the  
schema\_migration table from other accounts.

Yet another approach can be to use updatable views, but that is  
definitely not portable and some databases may not even support it, so I  
will stick with the first approach. You may want to work with someone  
who has DBA level knowledge of the specific database that you are using.  
Bharat

Florian S. wrote:

> Hi all!
> 
> How can I change the name of the schema\_migrations table? I have to do  
> this because I can only use one database but want to have several rails  
> projects.  
> I hope this is possible at all.  
> greets  
> flo schaf

---

<div class="post-metadata">

**Author:** ![schaf88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@schaf88](https://www.ruby-forum.com/u/schaf88)\
**Post date:** [November 7, 2008, 2:47pm UTC](https://www.ruby-forum.com/t/one-db-many-rails-projects-many-schema-migrations-table/142274/3 "2008-11-07T14:47:56Z")

</div>

Florian S. wrote:  
I have the same problem.  
Did a find a solution?

JEF

---

<div class="post-metadata">

**Author:** ![schaf88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@schaf88](https://www.ruby-forum.com/u/schaf88)\
**Post date:** [November 7, 2008, 7:46pm UTC](https://www.ruby-forum.com/t/one-db-many-rails-projects-many-schema-migrations-table/142274/4 "2008-11-07T19:46:35Z")

</div>

> poking round the source I see:
> 
> ```
> def schema_migrations_table_name
> Base.table_name_prefix + 'schema_migrations' +
> 
> ```
> 
> Base.table\_name\_suffix  
> end

I need to over write this method only for one app not for all.  
Is it possible to do so into the app? If so where to over\_write the  
code?

> Have you tried just having multiple migrations and just letting the  
> migration code work it out for itself? Rails should handle  
> intermediate migrations with timestamps (I think!)

you mean the mean the timestamps that prefixe the migrations file?  
I replace it by an integer.

---

<div class="post-metadata">

**Author:** ![schaf88](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b9e5f3/32.png) [@schaf88](https://www.ruby-forum.com/u/schaf88)\
**Post date:** [November 7, 2008, 7:10pm UTC](https://www.ruby-forum.com/t/one-db-many-rails-projects-many-schema-migrations-table/142274/5 "2008-11-07T19:10:09Z")

</div>

Hi,

poking round the source I see:

```
  def schema_migrations_table_name
    Base.table_name_prefix + 'schema_migrations' +

```

Base.table\_name\_suffix  
end

in activerecord-2.1.0/lib/active\_record/migration.rb

I suppose you could override this method in that class and then call  
initialize\_schema\_migrations\_table.

Have you tried just having multiple migrations and just letting the  
migration code work it out for itself? Rails should handle  
intermediate migrations with timestamps (I think!)

Allan
