public function preUp(Schema $schema)
    {
        /** @var ManagerRegistry $doctrine */
        $doctrine = $this->container->get('doctrine');
        $em = $doctrine->getManager();

        // Get all Campaigns.
        $campaigns = $em->getRepository('CampaignChain\CoreBundle\Entity\Campaign')
            ->findAll();

        if($campaigns){
            try {
                $em->getConnection()->beginTransaction();

                /** @var Campaign $campaign */
                foreach($campaigns as $campaign){
                    /** @var Action $firstAction */
                    $firstAction = $em->getRepository('CampaignChain\CoreBundle\Entity\Campaign')
                        ->getFirstAction($campaign);
                    if($firstAction && $firstAction->getStartDate() < $campaign->getStartDate()){
                        $campaign->setStartDate($firstAction->getStartDate());
                        $em->persist($campaign);

                        $this->write(
                            'Changed start date of campaign "'.
                            $campaign->getName().'" ('.$campaign->getId().') '.
                            'to date "'.
                            $campaign->getStartDate()->format(\DateTime::ISO8601)
                        );
                    } else {
                        $this->write(
                            'No changes to campaign "'.
                            $campaign->getName().'" ('.$campaign->getId().').'
                        );
                    }
                }

                $em->flush();

                $em->getConnection()->commit();
            } catch (\Exception $e) {
                $em->getConnection()->rollback();
                $this->write($e->getMessage());
            }
        }
    }