Exemplo n.º 1
0
 /**
  * @param Schema $schema
  * @return void
  */
 public function down(Schema $schema)
 {
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
     // collect foreign keys pointing to "our" tables
     $tableNames = array('typo3_party_domain_model_abstractparty', 'typo3_party_domain_model_electronicaddress', 'typo3_party_domain_model_person', 'typo3_party_domain_model_personname');
     $foreignKeyHandlingSql = Service::getForeignKeyHandlingSql($schema, $this->platform, $tableNames, 'persistence_object_identifier', 'flow3_persistence_identifier');
     // drop FK constraints
     foreach ($foreignKeyHandlingSql['drop'] as $sql) {
         $this->addSql($sql);
     }
     // rename identifier fields
     $this->addSql("ALTER TABLE typo3_party_domain_model_abstractparty DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_party_domain_model_abstractparty CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_party_domain_model_abstractparty ADD PRIMARY KEY (flow3_persistence_identifier)");
     $this->addSql("ALTER TABLE typo3_party_domain_model_electronicaddress DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_party_domain_model_electronicaddress CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_party_domain_model_electronicaddress ADD PRIMARY KEY (flow3_persistence_identifier)");
     $this->addSql("ALTER TABLE typo3_party_domain_model_person DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_party_domain_model_person CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_party_domain_model_person ADD PRIMARY KEY (flow3_persistence_identifier)");
     $this->addSql("ALTER TABLE typo3_party_domain_model_personname DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_party_domain_model_personname CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_party_domain_model_personname ADD PRIMARY KEY (flow3_persistence_identifier)");
     // add back FK constraints
     foreach ($foreignKeyHandlingSql['add'] as $sql) {
         $this->addSql($sql);
     }
 }
 /**
  * @param Schema $schema
  * @return void
  */
 public function down(Schema $schema)
 {
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql");
     // collect foreign keys pointing to "our" tables
     $tableNames = array('typo3_flow_resource_publishing_abstractpublishingconfiguration', 'typo3_flow_resource_resource', 'typo3_flow_security_account', 'typo3_flow_security_authorization_resource_securitypublis_861cb');
     $foreignKeyHandlingSql = Service::getForeignKeyHandlingSql($schema, $this->platform, $tableNames, 'persistence_object_identifier', 'flow3_persistence_identifier');
     // drop FK constraints
     foreach ($foreignKeyHandlingSql['drop'] as $sql) {
         $this->addSql($sql);
     }
     // rename identifier fields
     $this->addSql("ALTER TABLE typo3_flow_resource_publishing_abstractpublishingconfiguration RENAME COLUMN persistence_object_identifier TO flow3_persistence_identifier");
     $this->addSql("ALTER TABLE typo3_flow_resource_resource RENAME COLUMN persistence_object_identifier TO flow3_persistence_identifier");
     $this->addSql("ALTER TABLE typo3_flow_security_account RENAME COLUMN persistence_object_identifier TO flow3_persistence_identifier");
     $this->addSql("ALTER TABLE typo3_flow_security_authorization_resource_securitypublis_861cb RENAME COLUMN persistence_object_identifier TO flow3_persistence_identifier");
     // add back FK constraints
     foreach ($foreignKeyHandlingSql['add'] as $sql) {
         $this->addSql($sql);
     }
     // rename tables
     $this->addSql("ALTER TABLE typo3_flow_mvc_routing_objectpathmapping RENAME TO typo3_flow3_mvc_routing_objectpathmapping");
     $this->addSql("ALTER TABLE typo3_flow_resource_publishing_abstractpublishingconfiguration RENAME TO typo3_flow3_resource_publishing_abstractpublishingconfiguration");
     $this->addSql("ALTER TABLE typo3_flow_resource_resource RENAME TO typo3_flow3_resource_resource");
     $this->addSql("ALTER TABLE typo3_flow_resource_resourcepointer RENAME TO typo3_flow3_resource_resourcepointer");
     $this->addSql("ALTER TABLE typo3_flow_security_account RENAME TO typo3_flow3_security_account");
     $this->addSql("ALTER TABLE typo3_flow_security_authorization_resource_securitypublis_861cb RENAME TO typo3_flow3_security_authorization_resource_securitypubli_6180a");
     $this->addSql("ALTER TABLE typo3_flow_security_policy_role RENAME TO typo3_flow3_security_policy_role");
 }
 /**
  * @param Schema $schema
  * @return void
  */
 public function down(Schema $schema)
 {
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
     // collect foreign keys pointing to "our" tables
     $tableNames = array('typo3_typo3cr_migration_domain_model_migrationstatus', 'typo3_typo3cr_domain_model_contentobjectproxy', 'typo3_typo3cr_domain_model_node', 'typo3_typo3cr_domain_model_workspace');
     $foreignKeyHandlingSql = Service::getForeignKeyHandlingSql($schema, $this->platform, $tableNames, 'persistence_object_identifier', 'flow3_persistence_identifier');
     // drop FK constraints
     foreach ($foreignKeyHandlingSql['drop'] as $sql) {
         $this->addSql($sql);
     }
     // rename identifier fields
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_contentobjectproxy DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_contentobjectproxy CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_contentobjectproxy ADD PRIMARY KEY (flow3_persistence_identifier)");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_node DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_node CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_node ADD PRIMARY KEY (flow3_persistence_identifier)");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_workspace DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_workspace CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_workspace ADD PRIMARY KEY (flow3_persistence_identifier)");
     $this->addSql("ALTER TABLE typo3_typo3cr_migration_domain_model_migrationstatus DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_typo3cr_migration_domain_model_migrationstatus CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_typo3cr_migration_domain_model_migrationstatus ADD PRIMARY KEY (flow3_persistence_identifier)");
     // add back FK constraints
     foreach ($foreignKeyHandlingSql['add'] as $sql) {
         $this->addSql($sql);
     }
 }
Exemplo n.º 4
0
 /**
  * Generate a new migration
  *
  * If $diffAgainstCurrent is TRUE (the default), it generates a migration file
  * with the diff between current DB structure and the found mapping metadata.
  *
  * Otherwise an empty migration skeleton is generated.
  *
  * Only includes tables/sequences matching the $filterExpression regexp when
  * diffing models and existing schema. Include delimiters in the expression!
  * The use of
  *
  *  --filter-expression '/^acme_com/'
  *
  * would only create a migration touching tables starting with "acme_com".
  *
  * Note: A filter-expression will overrule any filter configured through the
  * Neos.Flow.persistence.doctrine.migrations.ignoredTables setting
  *
  * @param boolean $diffAgainstCurrent Whether to base the migration on the current schema structure
  * @param string $filterExpression Only include tables/sequences matching the filter expression regexp
  * @return void
  * @see neos.flow:doctrine:migrate
  * @see neos.flow:doctrine:migrationstatus
  * @see neos.flow:doctrine:migrationexecute
  * @see neos.flow:doctrine:migrationversion
  */
 public function migrationGenerateCommand($diffAgainstCurrent = true, $filterExpression = null)
 {
     // "driver" is used only for Doctrine, thus we (mis-)use it here
     // additionally, when no host is set, skip this step, assuming no DB is needed
     if (!$this->isDatabaseConfigured()) {
         $this->outputLine('Doctrine migration generation has been SKIPPED, the driver and host backend options are not set in /Configuration/Settings.yaml.');
         $this->quit(1);
     }
     // use default filter expression from settings
     if ($filterExpression === null) {
         $ignoredTables = array_keys(array_filter($this->settings['doctrine']['migrations']['ignoredTables']));
         if ($ignoredTables !== array()) {
             $filterExpression = sprintf('/^(?!%s$).*$/xs', implode('$|', $ignoredTables));
         }
     }
     list($status, $migrationClassPathAndFilename) = $this->doctrineService->generateMigration($diffAgainstCurrent, $filterExpression);
     $this->outputLine('<info>%s</info>', [$status]);
     $this->outputLine();
     if ($migrationClassPathAndFilename) {
         $choices = ['Don\'t Move'];
         $packages = [null];
         /** @var Package $package */
         foreach ($this->packageManager->getAvailablePackages() as $package) {
             $type = $package->getComposerManifest('type');
             if ($type === null || strpos($type, 'typo3-') !== 0 && strpos($type, 'neos-') !== 0) {
                 continue;
             }
             $choices[] = $package->getPackageKey();
             $packages[] = $package;
         }
         $selectedPackageIndex = (int) $this->output->select('Do you want to move the migration to one of these packages?', $choices, 0);
         $this->outputLine();
         if ($selectedPackageIndex !== 0) {
             /** @var Package $selectedPackage */
             $selectedPackage = $packages[$selectedPackageIndex];
             $targetPathAndFilename = Files::concatenatePaths([$selectedPackage->getPackagePath(), 'Migrations', $this->doctrineService->getDatabasePlatformName(), basename($migrationClassPathAndFilename)]);
             Files::createDirectoryRecursively(dirname($targetPathAndFilename));
             rename($migrationClassPathAndFilename, $targetPathAndFilename);
             $this->outputLine('The migration was moved to: <comment>%s</comment>', [substr($targetPathAndFilename, strlen(FLOW_PATH_PACKAGES))]);
             $this->outputLine();
             $this->outputLine('Next Steps:');
         } else {
             $this->outputLine('Next Steps:');
             $this->outputLine(sprintf('- Move <comment>%s</comment> to YourPackage/<comment>Migrations/%s/</comment>', $migrationClassPathAndFilename, $this->doctrineService->getDatabasePlatformName()));
         }
         $this->outputLine('- Review and adjust the generated migration.');
         $this->outputLine('- (optional) execute the migration using <comment>%s doctrine:migrate</comment>', [$this->getFlowInvocationString()]);
     }
 }
 /**
  * @param Schema $schema
  * @return void
  */
 public function down(Schema $schema)
 {
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql");
     // collect foreign keys pointing to "our" tables
     $foreignKeyHandlingSql = Service::getForeignKeyHandlingSql($schema, $this->platform, array('typo3_media_domain_model_image'), 'persistence_object_identifier', 'flow3_persistence_identifier');
     // drop FK constraints
     foreach ($foreignKeyHandlingSql['drop'] as $sql) {
         $this->addSql($sql);
     }
     // rename identifier fields
     $this->addSql("ALTER TABLE typo3_media_domain_model_image RENAME COLUMN persistence_object_identifier TO flow3_persistence_identifier");
     // add back FK constraints
     foreach ($foreignKeyHandlingSql['add'] as $sql) {
         $this->addSql($sql);
     }
 }
 /**
  * @param Schema $schema
  * @return void
  */
 public function down(Schema $schema)
 {
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "postgresql");
     // collect foreign keys pointing to "our" tables
     $tableNames = array('typo3_typo3cr_migration_domain_model_migrationstatus', 'typo3_typo3cr_domain_model_contentobjectproxy', 'typo3_typo3cr_domain_model_node', 'typo3_typo3cr_domain_model_workspace');
     $foreignKeyHandlingSql = Service::getForeignKeyHandlingSql($schema, $this->platform, $tableNames, 'persistence_object_identifier', 'flow3_persistence_identifier');
     // drop FK constraints
     foreach ($foreignKeyHandlingSql['drop'] as $sql) {
         $this->addSql($sql);
     }
     // rename identifier fields
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_contentobjectproxy RENAME COLUMN persistence_object_identifier TO flow3_persistence_identifier");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_node RENAME COLUMN persistence_object_identifier TO flow3_persistence_identifier");
     $this->addSql("ALTER TABLE typo3_typo3cr_domain_model_workspace RENAME COLUMN persistence_object_identifier TO flow3_persistence_identifier");
     $this->addSql("ALTER TABLE typo3_typo3cr_migration_domain_model_migrationstatus RENAME COLUMN persistence_object_identifier TO flow3_persistence_identifier");
     // add back FK constraints
     foreach ($foreignKeyHandlingSql['add'] as $sql) {
         $this->addSql($sql);
     }
 }
 /**
  * @param Schema $schema
  * @return void
  */
 public function down(Schema $schema)
 {
     $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");
     // collect foreign keys pointing to "our" tables
     $tableNames = array('typo3_flow_resource_publishing_abstractpublishingconfiguration', 'typo3_flow_resource_resource', 'typo3_flow_security_account', 'typo3_flow_security_authorization_resource_securitypublis_861cb');
     $foreignKeyHandlingSql = \Neos\Flow\Persistence\Doctrine\Service::getForeignKeyHandlingSql($schema, $this->platform, $tableNames, 'persistence_object_identifier', 'flow3_persistence_identifier');
     // drop FK constraints
     foreach ($foreignKeyHandlingSql['drop'] as $sql) {
         $this->addSql($sql);
     }
     // rename identifier fields
     $this->addSql("ALTER TABLE typo3_flow_resource_publishing_abstractpublishingconfiguration DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_flow_resource_publishing_abstractpublishingconfiguration CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_flow_resource_publishing_abstractpublishingconfiguration ADD PRIMARY KEY (flow3_persistence_identifier)");
     $this->addSql("ALTER TABLE typo3_flow_resource_resource DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_flow_resource_resource CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_flow_resource_resource ADD PRIMARY KEY (flow3_persistence_identifier)");
     $this->addSql("ALTER TABLE typo3_flow_security_account DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_flow_security_account CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_flow_security_account ADD PRIMARY KEY (flow3_persistence_identifier)");
     $this->addSql("ALTER TABLE typo3_flow_security_authorization_resource_securitypublis_861cb DROP PRIMARY KEY");
     $this->addSql("ALTER TABLE typo3_flow_security_authorization_resource_securitypublis_861cb CHANGE persistence_object_identifier flow3_persistence_identifier VARCHAR(40) NOT NULL");
     $this->addSql("ALTER TABLE typo3_flow_security_authorization_resource_securitypublis_861cb ADD PRIMARY KEY (flow3_persistence_identifier)");
     // add back FK constraints
     foreach ($foreignKeyHandlingSql['add'] as $sql) {
         $this->addSql($sql);
     }
     // rename tables
     $this->addSql("RENAME TABLE typo3_flow_mvc_routing_objectpathmapping TO typo3_flow3_mvc_routing_objectpathmapping");
     $this->addSql("RENAME TABLE typo3_flow_resource_publishing_abstractpublishingconfiguration TO typo3_flow3_resource_publishing_abstractpublishingconfiguration");
     $this->addSql("RENAME TABLE typo3_flow_resource_resource TO typo3_flow3_resource_resource");
     $this->addSql("RENAME TABLE typo3_flow_resource_resourcepointer TO typo3_flow3_resource_resourcepointer");
     $this->addSql("RENAME TABLE typo3_flow_security_account TO typo3_flow3_security_account");
     $this->addSql("RENAME TABLE typo3_flow_security_authorization_resource_securitypublis_861cb TO typo3_flow3_security_authorization_resource_securitypubli_6180a");
     $this->addSql("RENAME TABLE typo3_flow_security_policy_role TO typo3_flow3_security_policy_role");
 }