Data migration with Doctrine2
A project that I'm working on right now required me to migrate data from the existing database to the new database and database structure. Since the application is built on top of Symfony2, I decided to write a Command that would take care of the migration. I ran into an issue though: Doctrine2 insisted on creating new IDs where I wanted to keep the old one. The solution turned out to be really simple.
As it turns out, the cause of the problem is the fact that when you specify strategy="AUTO" for your ID-field, Doctrine2 will ignore any existing ID you've set in the entity. It will generate one because, well, you've specified it should be doing this. And usually, this is correct behaviour, but with the migration of existing data, to retain correct relations etc, it is much easier to keep the old IDs.
The solution is easy and, as usual, I found it thanks to StackOverflow. In your migrationscript, for each of the entities you're migrating, you just temporarily turn off the strategy:
As soon as I had added the above snippet for all the entities I'm migrating, it kept the old IDs and migration all of a sudden went flawlessly.
Update: The above method assumes you have a way of setting the ID in the entity, for instance a setId() method.
July 25, 2012 - tags: php, symfony, symfony2, doctrine2, data migration
: koss ktxpro1 titanium portable headphones with volume control. i should start off by saying that i'm a total newbie to the do-it-yourself electronics scene. logitech's sports headphones are designed especially for active types, with a lightweight frame that won't weigh your head down (cos those normal ones leave your head lolling about uncontrollably, right
: at any given time the car itself would consume as much as half of that to power all of its systems. bansko quickly developed into a more modern winter holiday resort with an explosion of hotels and apartment blocks. the main advantages of using wi-fi technology is the lack of wires. only our minds and logic will get us off this island." person 4: born while jupiter moved through capricorn says, "i believe in tradition. firstly he points out that if the trade with arabia was all-important, a site actually on the coast, or at least closer to the eastern edge of the plateau, with consequently shorter routing, would have been far more appropriate than aksum itself.
: I will say thanks to you for sharing informative news.
help with marketing paper writing
: Your fabulous article Data migration with Doctrine2 has provided me the information that i was looking for recognition for the blog... its tremendous
: you could start a new tradition and get him a phone cover. replacement - tube guitar output (1750 series). try not to pop your gum, slurp your coffee or make loud exclamations or noises that show displeasure over a task or interaction. watching videos or movie clips is fairly decent except for a couple of seconds for some videos to buffer. the quality of the reception is mediocre, but it allows me to answer phone calls in the car, which is nice.
microscope parts body tube
: compound light microscope diagram worksheet - web - pemonitorhosted. a later comprehensive polymorphism screen is to find as many forms as possible in order to exhaustively cover the intellectual property space. lois and jim show up start arguing with clark. this is closely related to number 3.
glutathione and sod liposomal cream
: children with autism are taking in a lot of information all the time; this means that at some stage, they have to sort through this information to see what they really need. the richest sources of phytonutrients are fruits and vegetables. essential fatty acids. glutamax reduced glutathione works inside our body while glutamax lightening soap works on the outside. despite the cancer prevention roles, researches have in fact found that beta-carotene tends to increase the risks of lung cancer in smokers and alcoholics.
Toyota Hilux For Sale
: Thanks to this blog I finally managed to find the information matching my criteria and for this I would like to thank the author for sharing this blog with us. Looking forward for more.Toyota Hilux For Sale
appointment setting companies
: I have been reading your post for years. And I must say that your ideas seems fresh every time.
: This is really wonderful information and I will regret you.
: alkaline water ionizer companies fol people to buy their costly products which harm the human body more than they benefit them actually.
glutathione recycler apex
: digesting your food properly, helps your system to distribute the nutrients throughout your body's other organs accordingly. dr drew and the mirror effect: fame without foundation we still have this year and her senior year to go, but hopefully she will make it a full year this year and be able to graduate next year. you can find prices cheaper than walmart, bestbuy or target deals with free shipping on over $25 and discount prices guarantee everyday sale. max international, maxone, maxgxl, max n-fuze, max4u, maxatp, visible solutions, max
Sample Interview Thank You Letter After Rejection
: as its a relatively new type of service, you may not be familiar with what it is, exactly. this catheter is the profession of cardiac cath lab nurse is in vogue these days among the nurse community. there are many parents that want to be a part of their baby's care, and therefore you as a nurse are going to be there to help them. your prospective employer just wants to know that you have a focus on safety and using standard precautions.
mp3 players ipod nano
: the aquapac mp3 case is designed to protect the apple ipod as well as mp3 players from creative zen, iriver, microsoft zune and the sony walkman. it's being used because it's very difficult to see the cd mechanism components in a slot-loading cd player that's used in a car audio cd mechanism. creative muvo mix 256 mb mp3 player its boombox-style design is sure to make your jamming sessions even more fun.
Cl And Phentermine
: which then results in contraction. as a result, vegetation growing in a more large garden salad topped with grilled salmon. stay educated with information on phentermine medication while you go ahead with usage of this medication for attaining optimistic weight loss results.
microscope vector graphic
: uncle kerry's yeast movie drive-in, featuring microscopes for kids. in stealth mode, you are undetectable because none of the infrared leds light up. free shipping carson z-pix 34-168x digital zoom microscope @ amazon.com.
Government Jobs Corpus Christi Tx
: modeling and acting career advice connect with key people, share information and effective practices, and optimize resources. ace network conferences, forums and learning events ensure that participants/members are kept up to date with the latest thinking and trends in the career education and development field. these are ten job ideas that provide variety and do not involve a significant amount of time in an office. for more career advice, please read "jobs that pay $50,000 to over $100,000 a year" and "jobs that pay well over a million dollars a year." you might also check out "dangerous jobs that pay well over $50,000 a year without a college degree" and "jobs that pay a lot more than you think." sales & service specialist and bank teller
cd player to mp3
: see our collection of in car stereos and other in car stereo related products, available from some of the best uk motoring shops online. titan sound usb turntable with stereo speakers for recording vinyl albums onto pcs in mp3 format ($19.99; $180 value). hard drives and the various technologies which power them. also, the players offer a battery life of 50 hrs for playing audio files and 10hrs video playback.