Hi Nipra,

require 'rubygems'
> require 'data_mapper'
> require 'app/models/contact'
> require 'environment'
> DataMapper.setup(:default, Environment.get_db_conn_hash('production'))
> DataMapper.auto_upgrade! # This call doesn't return.
>

It sounds like there might be a circular reference somewhere that 
DataMapper is getting hung up on and never exiting from.

The first thing I would suggest doing is calling DataMapper.finalize before 
auto-upgrating, but after declaring your models. One convention I often use 
is DataMapper.finalize.auto_upgrade! which ensures finalization is 
performed at the last possible minute before migrating. The actual step of 
finalization ensures all the inferred properties are added to the models, 
and that the models themselves are in a "final" state where all primary and 
foreign keys are known to the system.

After you've done this, if it still never exits, we should attempt to 
isolate the model, properties and relationships to something as small as 
possible that can still reproduce the problem. I would suggest removing 
models, relationships and properties (trying to cut things down by 50% each 
time, kind of like a binary search) until you get to a small repro. It 
*looks* like you only have one model, but it's hard to know for sure from a 
few require statements, so I'm giving you instructions that would apply to 
1 or more models.

Once you have a reliable reproduction, I would suggest putting it in a 
single executable file. If you are able to share this with the list, feel 
free to post a gist to the mailing list and we can look further. If for 
some reason you can't share it in public, but you feel comfortable sharing 
it with me privately feel free to email me the code so I can try it out 
here. If neither is possible, perhaps you can try to "anonymize" the code 
with some simple domain (Blog/Article/Comment, or Customer/Order/Item for 
example) where the problem still occurs.

It can sometimes be difficult to debug DataMapper issues only because 
everyone has different domains and approaches which are not always familiar 
to me. Sometimes people post huge snippets of code and expect that I can 
pick out the 1 error in 500 lines of unfamiliar code, which is pretty much 
impossible given my time constraints. However, by minimizing the code to 
*just* what is necessary to repro it reliably can make a huge difference in 
my ability to help.

In fact I would bet that most of the time if you go through this process 
you'll be able to identify the problem on your own. Often it's something 
you've introduced, or perhaps a typo, or maybe it leads you to the area in 
DM where the bug occurs.

-- 

Thanks,

Dan

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/datamapper/-/Gp50lmlT5BIJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to