Frank
Frank

Reputation: 714

Generate migrations and migrate through browser

Are there any rails gems or engines that would allow you to add columns to a database through the browser rather than the standard way of generating migrations through the console?

Basically, something that would be similar to phpmyadmin for php, but just very simple to add and remove columns. This is for a CMS I am working on that would allow users to add custom fields. If anyone can point me in the right direction.

Edit:

I was hoping I could use something like the following in a model to add a new column, but it doesn't work:

 def add_test_column
   add_column :my_table_name, :test_column_name, :string
 end

Is it even posible to use the AR methods like add_column, add_index, etc. in my models?

Upvotes: 0

Views: 54

Answers (1)

Frank
Frank

Reputation: 714

I see now that you can add columns and handle the other migration actions within a model with:

def self.add_column(name, type, args= {})
    ActiveRecord::Migration.add_column table_name, name, type, args
end

from: similar question

Upvotes: 1

Related Questions