Fixes problem when trying to migrate with PostgreSQL #713

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
5 participants
Contributor

hoverlover commented Oct 23, 2011

You can read the comments in core/config/initializers/old_tables.rb to get the details of the issue this commit fixes. Basically, when running under PostgreSQL, the migrations would fail when the table names were temporarily set using .table_name = 'blah'. This is the cleanest way I could find to fix it. Let me know if you have any questions.

Owner

schof commented Oct 24, 2011

Anyone using Postgres want to comment on this. Seems weird that nobody else is complaining about this problem. Perhaps its limited to a specific version of Postgres?

Contributor

hoverlover commented Oct 25, 2011

Just so everyone has more context, here is my situation:

  • Using spree_core only, installed into existing project.
  • PostgreSQL 9.1.1
  1. rails g spree:site
  2. bundle exec rake db:migrate. Errors ensue.
Member

joneslee85 commented Nov 12, 2011

Confirmed that the fix does work for spree_core yet it breaks migration of auth and api. Can you please fix and get the full test suites passing first?

@radar radar commented on the diff Jan 2, 2012

core/config/initializers/old_tables.rb
+ set_table_name 'shipments'
+ end
+
+ Spree::Order.class_eval do
+ set_table_name 'orders'
+ end
+
+ Spree::Adjustment.class_eval do
+ set_table_name 'adjustments'
+ end
+
+ Spree::Creditcard.class_eval do
+ set_table_name 'creditcards'
+ end
+else
+ puts "NOTE: Initializer #{__FILE__} is no longer needed and can be removed"
@radar

radar Jan 2, 2012

Member

This line would indicate to me that this message would be shown every single time the application is initialized. Not just during migrations. Also, people are unable to easily remove this file as it is inside the gem.

@hoverlover

hoverlover Jan 5, 2012

Contributor

You are correct. Total oversight on my part.

@parndt

parndt Mar 5, 2012

Contributor

Above, you should use self.table_name = 'orders' etc instead of set_table_name which is deprecated.

Member

radar commented Jan 2, 2012

Could someone elaborate how it breaks PostgreSQL please? All we've been told so far is "errors", which is unhelpful.

Contributor

hoverlover commented Jan 5, 2012

@radar the details of the error are in the comments in the initializer. That's really all the information surrounding errors I have to give.

Contributor

hoverlover commented Jan 5, 2012

I'll also add that this very well may not be the best way to fix this problem. This is just what worked for me. If anyone knows of a better way to fix it, go for it.

Owner

schof commented Apr 19, 2012

Closing for now due to the age of the ticket and the fact that it can no longer be merged w/out conflict. If someone wants to resurrect this issue and provide fresh pull request, etc. we will be happy to consider.

schof closed this Apr 19, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment