Deploying Mole to Production

2 views
Skip to first unread message

Eric Pugh

unread,
Aug 28, 2007, 4:27:04 PM8/28/07
to MOle Plugin
I deployed Mole into our production environment, and one of my hangups
was that I needed to use migrations to create the remote table.
Below is what I did to work under Postgres. How are other people
creating the tables for production?

Eric


class MoleTables < ActiveRecord::Migration
def self.up
create_table :mole_features do |t|
t.column "name", :string
t.column "context", :string
t.column "app_name", :string
t.column "create_at", :timestamp
t.column "update_at", :timestamp

end

create_table :mole_logs do |t|
t.column "mole_feature_id", :integer
t.column :user_id, :integer
t.column "params", :string
t.column "ip_address", :string
t.column "browser_type", :string
t.column "created_at", :timestamp
t.column "updated_at", :timestamp
end

add_index :mole_features, [:name]
end

def self.down
#remove_index :mole_features, [:name]
drop_table :mole_logs
drop_table :mole_features

end
end

Fernand Galiana

unread,
Aug 28, 2007, 4:50:46 PM8/28/07
to mole-...@googlegroups.com
Hi Eric,

You should be able to invoke the mole rake command from the root
of your application as

RAILS_ENV=production rake mole:install

To populate the mole schema in your prod env.

-Fernand

Eric Pugh

unread,
Aug 30, 2007, 10:35:04 AM8/30/07
to MOle Plugin
Ah, that would make sense. I guess I didn't really realize about the
"mole:install" task because it is buried inside of the install.rb.

At any rate, having it as a migration means we can run our "cap
deploy" task as normal and have the tables created, versus doing
something custom. Still like to see the plugin create the table for
me if it doesn't exist!

Fernand Galiana

unread,
Aug 30, 2007, 11:36:47 AM8/30/07
to mole-...@googlegroups.com
Hi Eric,

   The plugin should on install setup the mole tables by default
   in your dev environment. Was there a failure of some kind
   during the MOle install ?

   It would be difficult for the MOle to figure out the correct migration#
   and setup a migration based on your environment as it is sometime
   hard in a team environment to know what is the latest migration number.
   Hence we opted for the rake task...

   In any case you should be able to fire off the task upon capistrano deployment
   with something like assuming cap 2 and multistage-ext:

   -- Capfile

   after :migrate, :mole_migration

   desc "Setup MOle tables in the deployement database"
   task :mole_migration, :role => :db, :only => { :primary => true } do
      run "cd #{current_path}; #{rake} RAILS_ENV=#{rails_env} mole:migrate:up"
   end

-Fernand
Reply all
Reply to author
Forward
0 new messages