Hello, Leigh. My company needed to do the same thing. Here is what we
did. There may be better way, but this gets the job done.

As you may have guessed, the best approach is to use the heroku gem's
rake argument to pass rake commands to your heroku instance. If you
install the yaml_db plugin, you can use its data loading methods by
placing them in custom rake tasks that read specific YAML files and
load them into the database. If the update process only updates the
records, not the table structure, then it's fairly straightforward:
the YAML records will replace the exiting records (the table is
truncated first). Only the tables named in the YAML file will be
affected.

So one process that should work is:
A) Make changes to static / reference data.
B) Export affected table(s) to YAML file, e.g. static.yml, in a
predefined project dir, like db
C) Push YAML file to heroku environments
D) Run custom rake task for deploying YAML data to table(s), e.g.
heroku db:data:static:load --app <app name>

You can also alter the db:data:load task that the yaml_db plugin
defines to allow you to specify a YAML file by name. E.g.

namespace :db do
        namespace :data do
                desc "Load contents of YAML file in db directory into database
(defaults to db/data.yml)"
                task(:load, :partial_file, :needs => :environment) do |t, args|
                  if args.partial_file
                    YamlDb.load "#{RAILS_ROOT}/db/#{args.partial_file}.yml"
                    puts "loaded #{args.partial_file}"
                  else
                    YamlDb.load db_dump_data_file
                  end
                end
        end
end

For a file static.yml, call this with:
heroku db:data:load[static] --app <app name>
or
heroku db:data:load partial_file=static --app <app name>

You can test this locally before pushing the plugin and custom rake
tasks to heroku to use the gem. In fact, I strongly recommend this.
:-)

Cheers,
Michael


On Tue, Feb 23, 2010 at 7:43 PM, leigh <theschm...@gmail.com> wrote:
> We were wondering if there is a way to export a single table from a
> local schema to our heroku instance.
>
> We have a single machine that is the master for all our static/
> reference data. We have tools set up on this machine for producers/
> editors to edit the data. When they save new data, we need to push the
> affected static/reference tables out to all our other environments,
> including production.  However, it does not appear that the heroku gem
> supports that. Is there a workaround or something I'm missing?
>
> Thanks,
> Leigh
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Heroku" group.
> To post to this group, send email to her...@googlegroups.com.
> To unsubscribe from this group, send email to 
> heroku+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/heroku?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to her...@googlegroups.com.
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to