How can I exclude data from local schema_migrations tables that have been migrated to Heroku database?
I was able to get my Ruby on Rails application running with MySQL (local dev) to Heroku server and also migrate my model using the command heroku rake db:migrate
. I also read the documentation on Database Import / Export . Is this document a link to direct the actual data from my local DB detector to some Heroku DB? Do I need to change anything in the file database.yml
for this to happen?
I ran the following command:
heroku db:push
and I get the error:
Sending data
2 tables, 3 records
!!! Caught Server Exception | ETA: --:--:--
Taps Server Error: PGError ERROR: duplicate key value violates unique constraint
"unique_schema_migrations"
I have two tables, one I am creating for my application and the other schema_migrations
. The total number of records among the two tables is 3. I also print the number of records I have in the created table and it shows 0.
Any ideas what I might be missing or what I am doing wrong?
EDIT:
I figured out above, Heroku DB already has a schema_migrations
point where I was running to migrate.
New question: Does anyone know how I can exclude data from a specific table due to the fact that it was migrated to Heroku database. The exclusion table in this case will be schema_migrations
.
Not a good solution : I googled around and someone else had the same problem. He offered to name the table schema_migrations
zschema_migrations
. This way, data from other tables will be inserted correctly until the last table ends. This is a pretty bad decision, but will do it for now.
A better solution would be to use an existing Rails command that can reset point to a specific table from the database. I don't think I Rake
can do it.
source to share
Two possible options:
-
The heroku gem and the taps gem (which it uses to sync the databases) are open-source - you can fork them, modify the client APIs to support excluding tables from pushing, and then modify heroku's hero to use this new option.
-
You can write a shell script that uses pgdump to back up the schema_migrations table, drops that table,
heroku push
with the database, then reloads the table.
source to share
I just deployed a hero Rails 3 beta app on my new bamboo server. Now I can load data from my local development machine into the heroku database by following these steps:
heroku rake db:fixtures:load test/fixtures/my_model.yml
The data is then properly propagated to the Heroku database. Even though I have specified a specific data file, it automatically pushes data from other yaml files. This is probably due to my relationship model.
source to share
To push / pull from certain tables
heroku db: pull -tables logs, tags
http://blog.heroku.com/archives/2010/4/21/supporting_big_data_part_1
source to share