public function down(MetadataInterface $schema) { $drop_commit_file_status = new DropTable('commit_file_status'); $this->addSql($drop_commit_file_status->getSqlString($this->adapter->getPlatform())); $drop_commit = new DropTable('commit'); $this->addSql($drop_commit->getSqlString($this->adapter->getPlatform())); }
protected function setUp() { parent::setUp(); $driverConfig = ['driver' => getenv('db_type'), 'database' => str_replace('%BASE_DIR%', __DIR__ . '/../../../', getenv('db_name')), 'username' => getenv('db_username'), 'password' => getenv('db_password'), 'hostname' => getenv('db_host'), 'port' => getenv('db_port'), 'options' => ['buffer_results' => true]]; $config = ['dir' => __DIR__ . '/../data/ApplyMigration', 'namespace' => 'ApplyMigration']; $this->adapter = $adapter = new Adapter($driverConfig); $metadata = new Metadata($adapter); $tableNames = $metadata->getTableNames(); $drop_if_exists = ['test', MigrationVersion::TABLE_NAME]; foreach ($drop_if_exists as $table) { if (in_array($table, $tableNames)) { // ensure db is in expected state $drop = new DropTable($table); $adapter->query($drop->getSqlString($adapter->getPlatform())); } } /** @var ArrayObject $version */ $version = new MigrationVersion(); $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype($version); $gateway = new TableGateway(MigrationVersion::TABLE_NAME, $adapter, null, $resultSetPrototype); $table = new MigrationVersionTable($gateway); $this->migration = new Migration($adapter, $config, $table); }
public function down(MetadataInterface $schema) { $drop_test = new DropTable('test'); $this->addSql($drop_test->getSqlString($this->adapter->getPlatform())); }
/** * @covers Zend\Db\Sql\Ddl\DropTable::getSqlString */ public function testGetSqlString() { $dt = new DropTable('foo'); $this->assertEquals('DROP TABLE "foo"', $dt->getSqlString()); }
/** * Drops a stream table * * Use this function with caution. All your events will be lost! But it can be useful in migration scenarios. * * @param StreamName $streamName * @param bool $returnSql * @return string|null Whether $returnSql is true or not function will return generated sql or execute it directly */ public function dropSchemaFor(StreamName $streamName, $returnSql = false) { $dropTable = new DropTable($this->getTable($streamName)); if ($returnSql) { return $dropTable->getSqlString($this->dbAdapter->getPlatform()); } $this->dbAdapter->getDriver()->getConnection()->execute($dropTable->getSqlString($this->dbAdapter->getPlatform())); }
public function down(MetadataInterface $schema) { $drop_repositories = new DropTable('repository'); $this->addSql($drop_repositories->getSqlString($this->adapter->getPlatform())); }
public function down(MetadataInterface $schema) { // clean up result of first statement $drop_test = new DropTable('test'); $this->addSql($drop_test->getSqlString($this->adapter->getPlatform())); }