How do I exclude data from local table schema_migrations from being pushed to Heroku DB?
- by Thierry Lam
I was able to push my Ruby on Rails app with MySQL(local dev) to the Heroku server along with migrating my model with the command heroku rake db:migrate. I have also read the documentation on Database Import/Export. Is that doc referring to pushing actual data from my local dev DB to whichever Heroku's DB? Do I need to modify anything in the file database.yml to make it happen?
I ran the following command:
heroku db:push
and I am getting 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 2 tables, one I create for my app and the other schema_migrations. The total number of entries among the 2 tables is 3. I'm also printing the number of entries I have in the table I have created and it's showing 0.
Any ideas what I might be missing or what I am doing wrong?
EDIT:
I figured out the above, Heroku's DB already have schema_migrations the moment I ran migrate.
New question: Does anyone know how I can exclude data from a specific table from being pushed to Heroku DB. The table to exclude in this case will be schema_migrations.
Not so good solution:
I googled around and someone else was having the same issue. He suggested naming the schema_migrations table to zschema_migrations. In this way data from the other tables will be pushed properly until it fails on the last table. It's a pretty bad solution but will do for the time being.
A better solution will be to use an existing Rails command which can reset a specific table from a database. I don't think Rake can do that.