# Managing tables and tables columns within my rails app

**URL:** <https://www.ruby-forum.com/t/managing-tables-and-tables-columns-within-my-rails-app/69713>\
**Category:** Rails\
**Created:** [September 23, 2006, 3:44am UTC](https://www.ruby-forum.com/t/managing-tables-and-tables-columns-within-my-rails-app/69713 "2006-09-23T03:44:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdelgoulet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5f9b8f/32.png) [@jdelgoulet](https://www.ruby-forum.com/u/jdelgoulet)\
**Post date:** [September 23, 2006, 3:44am UTC](https://www.ruby-forum.com/t/managing-tables-and-tables-columns-within-my-rails-app/69713/1 "2006-09-23T03:44:50Z")

</div>

Hi all,

I’m wondering if it is possible to manage tables and tables columns in  
rails…  
Might be not very clear so here is an example :

I have an application that has specific tables for the users of my app.  
Let say, I create a database with a ‘users’ table template (first\_name,  
last\_name, email, country).  
When “joe” creates an account in my app , I want to creates a  
“joo\_users” table which is a “copy” of my template “users” table.  
Now, joe doesn’t care of, let say, the country of his customers so he  
decides to “remove” the “country” column of his “joe\_users” table …

The same thing if “joe” wants to creates a new column in a specific  
table …

What I would like to have is user be able to remove some table columns  
so his “screen” won’t be polluated with fields that he doesn’t care of.

Is it possible ?  
If so I can I do this ?

-\> do some create table stuff using SQL command within rails and pass  
to “table\_prefix” “joe” (or whatever is my client name) my “user” model  
-\> do some ALTER table stuff using SQL command within rails to remove  
unwanted table column ?

Thanks for all your answers !

---

<div class="post-metadata">

**Author:** ![jdelgoulet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5f9b8f/32.png) [@jdelgoulet](https://www.ruby-forum.com/u/jdelgoulet)\
**Post date:** [May 22, 2007, 11:55am UTC](https://www.ruby-forum.com/t/managing-tables-and-tables-columns-within-my-rails-app/69713/2 "2007-05-22T11:55:22Z")

</div>

Hey Julien

Did you find a way to do this? I have the exact same requirement.

Thanks  
p3rlhax  
Julien Delgoulet wrote:

> Hi all,
> 
> I’m wondering if it is possible to manage tables and tables columns in  
> rails…  
> Might be not very clear so here is an example :
> 
> I have an application that has specific tables for the users of my app.  
> Let say, I create a database with a ‘users’ table template (first\_name,  
> last\_name, email, country).  
> When “joe” creates an account in my app , I want to creates a  
> “joo\_users” table which is a “copy” of my template “users” table.  
> Now, joe doesn’t care of, let say, the country of his customers so he  
> decides to “remove” the “country” column of his “joe\_users” table …
> 
> The same thing if “joe” wants to creates a new column in a specific  
> table …
> 
> What I would like to have is user be able to remove some table columns  
> so his “screen” won’t be polluated with fields that he doesn’t care of.
> 
> Is it possible ?  
> If so I can I do this ?
> 
> -\> do some create table stuff using SQL command within rails and pass  
> to “table\_prefix” “joe” (or whatever is my client name) my “user” model  
> -\> do some ALTER table stuff using SQL command within rails to remove  
> unwanted table column ?
> 
> Thanks for all your answers !

---

<div class="post-metadata">

**Author:** ![jdelgoulet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/5f9b8f/32.png) [@jdelgoulet](https://www.ruby-forum.com/u/jdelgoulet)\
**Post date:** [May 22, 2007, 1:08pm UTC](https://www.ruby-forum.com/t/managing-tables-and-tables-columns-within-my-rails-app/69713/3 "2007-05-22T13:08:57Z")

</div>

On 5/22/07, p3rlhax [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hey Julien
> 
> Did you find a way to do this? I have the exact same requirement.

Hey buddy,

you do not want to alter your db schema dynamically. It may be  
possible, even using RoR/AR, but it’s never a good idea.

I suggest you pick up a good book or two on db modelling instead,  
and/or post your problem on a database oriented forum.

Sincerely,  
Isak
