Beispiel #1
0
 /**
  * @dataProvider providesSchemaFiles
  * @param string $xml
  */
 public function testZeroChangeOnSchemaMigrations($xml)
 {
     $xml = str_replace('*dbprefix*', $this->testPrefix, $xml);
     $schemaFile = 'static://test_db_scheme';
     file_put_contents($schemaFile, $xml);
     // apply schema
     $this->manager->createDbFromStructure($schemaFile);
     $schemaReader = new MDB2SchemaReader($this->config, $this->connection->getDatabasePlatform());
     $endSchema = $schemaReader->loadSchemaFromFile($schemaFile);
     // get the diff
     /** @var SchemaDiff $diff */
     $migrator = $this->manager->getMigrator();
     $diff = $this->invokePrivate($migrator, 'getDiff', [$endSchema, $this->connection]);
     // no sql statement is expected
     $sqls = $diff->toSql($this->connection->getDatabasePlatform());
     $this->assertEquals([], $sqls);
 }
Beispiel #2
0
 /**
  * remove all tables defined in a database structure xml file
  *
  * @param string $file the xml file describing the tables
  */
 public function removeDBStructure($file)
 {
     $schemaReader = new MDB2SchemaReader(\OC_Config::getObject(), $this->conn->getDatabasePlatform());
     $fromSchema = $schemaReader->loadSchemaFromFile($file);
     $toSchema = clone $fromSchema;
     /** @var $table \Doctrine\DBAL\Schema\Table */
     foreach ($toSchema->getTables() as $table) {
         $toSchema->dropTable($table->getName());
     }
     $comparator = new \Doctrine\DBAL\Schema\Comparator();
     $schemaDiff = $comparator->compare($fromSchema, $toSchema);
     $this->executeSchemaChange($schemaDiff);
 }