# 2 apps with 1 one database

**URL:** <https://www.ruby-forum.com/t/2-apps-with-1-one-database/152177>\
**Category:** Rails\
**Created:** [October 30, 2008, 9:30pm UTC](https://www.ruby-forum.com/t/2-apps-with-1-one-database/152177 "2008-10-30T21:30:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jef](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@jef](https://www.ruby-forum.com/u/jef)\
**Post date:** [October 30, 2008, 9:30pm UTC](https://www.ruby-forum.com/t/2-apps-with-1-one-database/152177/1 "2008-10-30T21:30:49Z")

</div>

Hi;

I am developping a web app and I’ve wrote some admin code (parsing web  
site, sending massmail etc…) which don’t need to be deployed.  
So I would like this code to be part of a second developement app.

But there’s a probleme regarding the schema\_migrations table. it must  
be unique.

How can I solve this problem?

Thanks  
JF

---

<div class="post-metadata">

**Author:** ![jef](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@jef](https://www.ruby-forum.com/u/jef)\
**Post date:** [October 30, 2008, 9:40pm UTC](https://www.ruby-forum.com/t/2-apps-with-1-one-database/152177/2 "2008-10-30T21:40:48Z")

</div>

Hi jef,

jef wrote:

> I am developping a web app and I’ve wrote some admin  
> code (parsing web site, sending massmail etc…) which don’t  
> need to be deployed. So I would like this code to be part of  
> a second developement app.

Interesting. What leads you to want to separate the admin functionality  
into a completely separate app?

> But there’s a probleme regarding the schema\_migrations table.  
> it must be unique.
> 
> How can I solve this problem?

The easiest way I can think of would be to simply run all your  
migrations  
from one of the apps. As long as you never run any migrations from the  
second app I can’t think of any way you’d run into conflicts. Doesn’t  
mean  
you won’t. Just that I can’t think of any off the top of my head 😉

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![jef](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@jef](https://www.ruby-forum.com/u/jef)\
**Post date:** [October 30, 2008, 9:54pm UTC](https://www.ruby-forum.com/t/2-apps-with-1-one-database/152177/3 "2008-10-30T21:54:56Z")

</div>

> Interesting. What leads you to want to separate the admin functionality  
> into a completely separate app?

I want my dev app to be equal to the production app to make  
deployement easier.

> The easiest way I can think of would be to simply run all your migrations  
> from one of the apps. As long as you never run any migrations from the  
> second app I can’t think of any way you’d run into conflicts. Doesn’t mean  
> you won’t. Just that I can’t think of any off the top of my head 😉

I need to run migrations from the admin app.

---

<div class="post-metadata">

**Author:** ![jef](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@jef](https://www.ruby-forum.com/u/jef)\
**Post date:** [October 30, 2008, 11:42pm UTC](https://www.ruby-forum.com/t/2-apps-with-1-one-database/152177/4 "2008-10-30T23:42:53Z")

</div>

On the other hand, I don’t understand why not use role based  
authorization to the admin area?

---

<div class="post-metadata">

**Author:** ![jef](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@jef](https://www.ruby-forum.com/u/jef)\
**Post date:** [October 31, 2008, 11:54am UTC](https://www.ruby-forum.com/t/2-apps-with-1-one-database/152177/5 "2008-10-31T11:54:12Z")

</div>

> On the other hand, I don’t understand why not use role based  
> authorization to the admin area?

Most of the code is used only once. Ex:  
parse the [foo.com](http://foo.com) web site and grab the email adresse.  
Send email to some users (some who have a website, some who has been  
born in july, some who have a dog, etc)

So I don’t want to deploy that code but I want to keep it in an  
appropriate place.  
That’s why I thougt about a second app using database of the main app.

---

<div class="post-metadata">

**Author:** ![jef](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@jef](https://www.ruby-forum.com/u/jef)\
**Post date:** [October 31, 2008, 11:57am UTC](https://www.ruby-forum.com/t/2-apps-with-1-one-database/152177/6 "2008-10-31T11:57:44Z")

</div>

> Like I said, it doesn’t matter which app you run your migrations from. Just  
> pick one.

My admin app will never be in production.  
It’s just a place where I store one shot code (parsing website code,  
etc …).

---

<div class="post-metadata">

**Author:** ![jef](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@jef](https://www.ruby-forum.com/u/jef)\
**Post date:** [October 31, 2008, 3:17am UTC](https://www.ruby-forum.com/t/2-apps-with-1-one-database/152177/7 "2008-10-31T03:17:38Z")

</div>

Harold wrote:

> On the other hand, I don’t understand why not use  
> role based authorization to the admin area?

Exactly.

OTOH…

> I need to run migrations from the admin app.

Like I said, it doesn’t matter which app you run your migrations from.  
Just  
pick one.

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![jef](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@jef](https://www.ruby-forum.com/u/jef)\
**Post date:** [October 31, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/2-apps-with-1-one-database/152177/8 "2008-10-31T15:59:26Z")

</div>

Well, to me it sounds like your “admin app” is just a bunch of rake  
tasks that do some bookkeeping for you. You seem to be solving a  
problem that does not exist - again, what’s the problem with the admin  
code living in the same app? Even if it makes it to production?

Be that as it may, if you insist in having two rails apps, I would  
disable the db:migrate rake task on the admin app. Make it raise an  
exception. Same with the migration generator.
