views:

22

answers:

1

I think I am close to mess up my db on heroku

I am trying to download the remote DB on heroku by heroku db:pull

I get the following message:

news_items: 100% |==========================================| Time: 00:00:01 /usr/lib/ruby/gems/1.8/gems/sequel-3.13.0/lib/sequel/adapters/mysql.rb:169:in `query': Mysql::Error: Duplicate entry '3-Portfolio' for key 'index_unique_user_plugins' (Sequel::DatabaseError)

Will a re-index solve this problem or am I in trouble? I think to understand that it's my local db (as it's mysql throwing the error, while heroku runs PostgreSQL) which is complaining, thus there seem to be some duplicate keys in some index (not sure I really know what this means)

+2  A: 

I believe the problem is PostgreSQL treats strings as case-sensitive, while MySQL treats them as case-insensitive. This applies to unique indices as well. User 3 probably has a plugin named "Portfolio" and "portfolio".

The easiest solution is to change your index on Heroku to be non-unique. You can then easily import it into MySQL. Alternately, you can massage your data a bit so it is still unique. The easiest way to access the database on Heroku is the Heroku sql conole. Lastly, and probably the best option, is to use PostgreSQL locally, so your development environment matches your production environment.

wuputah
Thanks. It is actually so: I have 3-portfolio and 3-Portfolio in my db. This is coming from a plugin so I do not know how it came about and if it's actually ok or not...
fablife
If you want all strings to be unique ignoring case going forward, add a uniqueness constraint on (i.e. change your unique index to) `LOWER(plugin)`.
wuputah