Frank6
Frank6

Reputation: 1203

Symfony2 - How to create a new OneToOne relation without effecting database

I have a BlogBundle and I want to add a thread to my posts (using FOSCommentBundle) but following the FOS documentation I have to provide the thread ID. The problem is that all my older posts has the thread property set to NULL, what is the best way to associate a new thread to my older posts ? If possible, I would not have to change the FOSThreadController.

/**
 * @var \ACME\CommentBundle\Thread $thread
 * 
 * @ORM\OneToOne(targetEntity="ACME\CommentBundle\Entity\Thread", cascade={"persist", "remove"})
 */
private $thread;

Upvotes: 0

Views: 192

Answers (2)

GhostRider
GhostRider

Reputation: 1

define mapping in your doctrine/ your_entity.orm.xml/yml too.

Upvotes: 0

ryabenko-pro
ryabenko-pro

Reputation: 728

You can write command to find all the posts with thread == null and create thread for it.

Upvotes: 1

Related Questions