예제 #1
0
 public function migrate()
 {
     $this->databaseModifier = $this->get('enhavo_migration.database_modifier');
     $renameTables = ['content_column' => 'grid_column', 'content_container' => 'grid_container', 'content_content' => 'grid_grid', 'content_gallery_files' => 'grid_item_gallery_files', 'content_item' => 'grid_item', 'content_item_download' => 'grid_item_download', 'content_type_cite_text' => 'grid_item_cite_text', 'content_type_gallery' => 'grid_item_gallery', 'content_type_picture' => 'grid_item_picture', 'content_type_picture_picture' => 'grid_item_picture_picture', 'content_type_text' => 'grid_item_text', 'content_type_text_picture' => 'grid_item_text_picture', 'content_type_text_text' => 'grid_item_text_text'];
     foreach ($renameTables as $source => $target) {
         $this->databaseModifier->renameTable($source, $target);
     }
     //ToDo: Rename content_id columns to grid_id columns
 }
예제 #2
0
 /**
  * Updates the enhavo database version. If the database previously had no enhavo database version, it is created.
  *
  * @param string $version The new version number
  *
  * @throws \Doctrine\DBAL\DBALException
  * @throws \Doctrine\ORM\ORMException
  * @throws \Exception
  */
 public function setVersion($version)
 {
     if (!$this->modifier->tableExists(self::VERSION_TABLE)) {
         $this->generateDatabaseVersionTable();
     }
     /** @var Version $version */
     $versions = $this->entityManager->getRepository('EnhavoMigrationBundle:Version')->findAll();
     if (empty($versions)) {
         $entityVersion = new Version();
         $this->entityManager->persist($entityVersion);
     } else {
         $entityVersion = $versions[0];
     }
     $entityVersion->setVersion($version);
     $this->entityManager->flush();
 }
예제 #3
0
 public function migrate()
 {
     $this->databaseModifier = $this->get('enhavo_migration.database_modifier');
     // Add new columns
     $this->databaseModifier->addColumnsToTableIfExists('article_article', array('picture_id'));
     $this->databaseModifier->addColumnsToTableIfExists('page_page', array('picture_id'));
     $this->databaseModifier->addColumnsToTableIfExists('category_category', array('picture_id'));
     $this->databaseModifier->addColumnsToTableIfExists('content_type_picture', array('file_id'));
     $this->databaseModifier->addColumnsToTableIfExists('content_type_text_picture', array('file_id'));
     $this->databaseModifier->addColumnsToTableIfExists('content_type_picture_picture', array('fileLeft_id', 'fileRight_id'));
     $this->databaseModifier->addColumnsToTableIfExists('content_item_download', array('file_id'));
     $this->databaseModifier->addColumnsToTableIfExists('download_download', array('file_id'));
     $this->databaseModifier->addColumnsToTableIfExists('slider_slide', array('image_id'));
     $this->databaseModifier->addColumnsToTableIfExists('calendar_appointment', array('picture_id'));
     // Copy connections
     $this->databaseModifier->copyConnectionsIfTableExists('article_article', 'id', 'picture_id', 'article_article_picture', 'article_id', 'file_id');
     $this->databaseModifier->copyConnectionsIfTableExists('page_page', 'id', 'picture_id', 'page_page_picture', 'page_id', 'file_id');
     $this->databaseModifier->copyConnectionsIfTableExists('category_category', 'id', 'picture_id', 'category_category_picture', 'category_id', 'file_id');
     $this->databaseModifier->copyConnectionsIfTableExists('content_type_picture', 'id', 'file_id', 'content_picture_files', 'picture_id', 'file_id');
     $this->databaseModifier->copyConnectionsIfTableExists('content_type_text_picture', 'id', 'file_id', 'content_textpicture_files', 'textpicture_id', 'file_id');
     $this->databaseModifier->copyConnectionsIfTableExists('content_type_picture_picture', 'id', 'fileLeft_id', 'content_pictureleft_files', 'picturepicture_id', 'file_id');
     $this->databaseModifier->copyConnectionsIfTableExists('content_type_picture_picture', 'id', 'fileRight_id', 'content_pictureright_files', 'picturepicture_id', 'file_id');
     $this->databaseModifier->copyConnectionsIfTableExists('content_item_download', 'id', 'file_id', 'content_item_download_file', 'download_id', 'file_id');
     $this->databaseModifier->copyConnectionsIfTableExists('download_download', 'id', 'file_id', 'download_download_file', 'download_id', 'file_id');
     $this->databaseModifier->copyConnectionsIfTableExists('slider_slide', 'id', 'image_id', 'slider_slide_image', 'slider_id', 'file_id');
     $this->databaseModifier->copyConnectionsIfTableExists('calendar_appointment', 'id', 'picture_id', 'calendar_appointment_picture', 'appointment_id', 'file_id');
     // Drop old join tables
     $this->databaseModifier->dropTableIfExists('article_article_picture');
     $this->databaseModifier->dropTableIfExists('page_page_picture');
     $this->databaseModifier->dropTableIfExists('category_category_picture');
     $this->databaseModifier->dropTableIfExists('content_picture_files');
     $this->databaseModifier->dropTableIfExists('content_textpicture_files');
     $this->databaseModifier->dropTableIfExists('content_pictureleft_files');
     $this->databaseModifier->dropTableIfExists('content_pictureright_files');
     $this->databaseModifier->dropTableIfExists('content_item_download_file');
     $this->databaseModifier->dropTableIfExists('download_download_file');
     $this->databaseModifier->dropTableIfExists('slider_slide_image');
     $this->databaseModifier->dropTableIfExists('calendar_appointment_picture');
 }