/**
  * @param $name
  *
  * @return Filesystem
  */
 public function create($name)
 {
     switch ($name) {
         case 'local':
             $adapter = new Adapter\Local($this->getParameter('local', 'folder'), $this->getParameter('local', 'create'));
             break;
         case 'sftp_phpseclib':
             $sftp = new \phpseclib\Net\SFTP($this->getParameter('sftp', 'host'), $this->getParameter('sftp', 'port'));
             $sftp->login($this->getParameter('sftp', 'login'), $this->getParameter('sftp', 'password'));
             $adapter = new Adapter\PhpseclibSftp($sftp, $this->getParameter('sftp', 'folder'), true);
             break;
         case 'sftp':
             $configuration = new Ssh\Configuration($this->getParameter('sftp', 'host'), $this->getParameter('sftp', 'port'));
             $authentication = new Ssh\Authentication\Password($this->getParameter('sftp', 'login'), $this->getParameter('sftp', 'password'));
             // for other options, check php-ssh docs
             $session = new Ssh\Session($configuration, $authentication);
             $adapter = new Adapter\Sftp($session->getSftp());
             break;
         case 's3':
             $service = new \Aws\S3\S3Client(array('credentials' => ['key' => $this->getParameter('s3', 'key'), 'secret' => $this->getParameter('s3', 'secret')], 'endpoint' => $this->getParameter('s3', 'endpoint'), 'bucket_endpoint' => $this->getParameter('s3', 'bucket_endpoint'), 'region' => $this->getParameter('s3', 'region'), 'version' => $this->getParameter('s3', 'version')));
             $adapter = new Adapter\AwsS3($service, $this->getParameter('s3', 'bucket'));
             break;
         case 'ftp':
             $adapter = new Adapter\Ftp('/', $this->getParameter('ftp', 'host'), array('username' => $this->getParameter('ftp', 'username'), 'password' => $this->getParameter('ftp', 'password'), 'passive' => $this->getParameter('ftp', 'passive'), 'port' => $this->getParameter('ftp', 'port')));
             break;
         case 'gridfs':
             $client = new MongoClient(sprintf('mongodb://%s:%s', $this->getParameter('gridfs', 'host'), $this->getParameter('gridfs', 'port')));
             $db = $client->selectDB($this->getParameter('gridfs', 'db'));
             $adapter = new Adapter\GridFS(new MongoGridFS($db));
             break;
         case 'mogilefs':
             $adapter = new Adapter\MogileFS('http://*****:*****@%s/%s', $this->getParameter('mysql', 'user'), $this->getParameter('mysql', 'password'), $this->getParameter('mysql', 'host'), $this->getParameter('mysql', 'db'))]);
             $sm = $connection->getSchemaManager();
             $table = new \Doctrine\DBAL\Schema\Table('files');
             if (!$sm->tablesExist(['files'])) {
                 $table = new \Doctrine\DBAL\Schema\Table('files');
                 $table->addColumn('key', 'string');
                 $table->addColumn('content', 'text');
                 $table->addColumn('mtime', 'string');
                 $table->addColumn('checksum', 'string');
                 $sm->createTable($table);
             }
             $adapter = new Adapter\DoctrineDbal($connection, $table->getName());
             break;
         default:
             throw new \RuntimeException(sprintf('Unknown adapter %s', $name));
     }
     return new Filesystem($adapter);
 }
예제 #2
0
 public function testGenerateMixedCaseTableCreate()
 {
     $table = new \Doctrine\DBAL\Schema\Table("Foo");
     $table->addColumn("Bar", "integer");
     $sql = $this->_platform->getCreateTableSQL($table);
     $this->assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) ENGINE = InnoDB', array_shift($sql));
 }
 public function testGenerateTableWithAutoincrement()
 {
     $table = new \Doctrine\DBAL\Schema\Table('autoinc_table');
     $column = $table->addColumn('id', 'integer');
     $column->setAutoincrement(true);
     $this->assertEquals(array('CREATE TABLE autoinc_table (id SERIAL NOT NULL)'), $this->_platform->getCreateTableSQL($table));
 }
 public function testCreateFederatedOnTable()
 {
     $table = new \Doctrine\DBAL\Schema\Table("tbl");
     $table->addColumn("id", "integer");
     $table->addOption('azure.federatedOnDistributionName', 'TblId');
     $table->addOption('azure.federatedOnColumnName', 'id');
     $this->assertEquals(array('CREATE TABLE tbl (id INT NOT NULL) FEDERATED ON (TblId = id)'), $this->platform->getCreateTableSQL($table));
 }
 public function testGenerateTableWithMultiColumnUniqueIndex()
 {
     $table = new \Doctrine\DBAL\Schema\Table('test');
     $table->addColumn('foo', 'string', array('notnull' => false, 'length' => 255));
     $table->addColumn('bar', 'string', array('notnull' => false, 'length' => 255));
     $table->addUniqueIndex(array("foo", "bar"));
     $sql = $this->_platform->getCreateTableSQL($table);
     $this->assertEquals($this->getGenerateTableWithMultiColumnUniqueIndexSql(), $sql);
 }
예제 #6
0
 public function testStrictMapTableCreationWithSchemaManager()
 {
     $platform = $this->_conn->getDatabasePlatform();
     $table = new \Doctrine\DBAL\Schema\Table('items');
     $objDefinition = array('type' => \Crate\DBAL\Types\MapType::STRICT, 'fields' => array(new \Doctrine\DBAL\Schema\Column('id', \Doctrine\DBAL\Types\Type::getType('integer'), array()), new \Doctrine\DBAL\Schema\Column('name', \Doctrine\DBAL\Types\Type::getType('string'), array())));
     $table->addColumn('object_column', \Crate\DBAL\Types\MapType::NAME, array('platformOptions' => $objDefinition));
     $createFlags = CratePlatform::CREATE_INDEXES | CratePlatform::CREATE_FOREIGNKEYS;
     $sql = $platform->getCreateTableSQL($table, $createFlags);
     $this->assertEquals(array('CREATE TABLE items (object_column OBJECT ( strict ) AS ( id INTEGER, name STRING ))'), $sql);
 }
예제 #7
0
 protected function createQueryTestTable()
 {
     $table = new \Doctrine\DBAL\Schema\Table('query_test');
     $table->addColumn('id', 'integer');
     $table->addColumn('val1', 'string');
     $table->addColumn('val2', 'integer');
     try {
         $this->connection->getSchemaManager()->createTable($table);
     } catch (DBALException $e) {
     }
 }
예제 #8
0
 /**
  * @group DDC-2387
  */
 public function testCompositeAssociationKeyDetection()
 {
     $product = new \Doctrine\DBAL\Schema\Table('ddc2387_product');
     $product->addColumn('id', 'integer');
     $product->setPrimaryKey(array('id'));
     $attributes = new \Doctrine\DBAL\Schema\Table('ddc2387_attributes');
     $attributes->addColumn('product_id', 'integer');
     $attributes->addColumn('attribute_name', 'string');
     $attributes->setPrimaryKey(array('product_id', 'attribute_name'));
     $attributes->addForeignKeyConstraint('ddc2387_product', array('product_id'), array('product_id'));
     $metadata = $this->convertToClassMetadata(array($product, $attributes), array());
     $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_NONE, $metadata['Ddc2387Attributes']->generatorType);
     $this->assertEquals(ClassMetadataInfo::GENERATOR_TYPE_AUTO, $metadata['Ddc2387Product']->generatorType);
 }
예제 #9
0
 public function setUp()
 {
     parent::setUp();
     try {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("fetch_table");
         $table->addColumn('test_int', 'integer');
         $table->addColumn('test_string', 'string');
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
         $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo'));
     } catch (\Exception $e) {
     }
 }
예제 #10
0
 public function setUp()
 {
     parent::setUp();
     try {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("write_table");
         $table->addColumn('test_int', 'integer');
         $table->addColumn('test_string', 'string', array('notnull' => false));
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
     } catch (\Exception $e) {
     }
     $this->_conn->executeUpdate('DELETE FROM write_table');
 }
예제 #11
0
 protected function setUp()
 {
     parent::setUp();
     if ($this->_conn->getDatabasePlatform()->getName() != 'oracle') {
         $this->markTestSkipped('OCI8 only test');
     }
     if ($this->_conn->getSchemaManager()->tablesExist('DBAL202')) {
         $this->_conn->executeQuery('DELETE FROM DBAL202');
     } else {
         $table = new \Doctrine\DBAL\Schema\Table('DBAL202');
         $table->addColumn('id', 'integer');
         $table->setPrimaryKey(array('id'));
         $this->_conn->getSchemaManager()->createTable($table);
     }
 }
예제 #12
0
 public function setUp()
 {
     parent::setUp();
     try {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("write_table");
         $table->addColumn('test_int', 'integer');
         $table->addColumn('test_string', 'string', array('notnull' => false));
         $table->setPrimaryKey(array('test_int'));
         foreach ($this->_conn->getDatabasePlatform()->getCreateTableSQL($table) as $sql) {
             $this->_conn->executeQuery($sql);
         }
     } catch (\Exception $e) {
     }
     $this->_conn->executeUpdate('DELETE FROM write_table');
 }
 public function setUp()
 {
     parent::setUp();
     if ($this->_conn->getDatabasePlatform()->getName() == "sqlite") {
         $this->markTestSkipped('Test does not work on sqlite.');
     }
     try {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("master_slave_table");
         $table->addColumn('test_int', 'integer');
         $table->setPrimaryKey(array('test_int'));
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
         $this->_conn->insert('master_slave_table', array('test_int' => 1));
     } catch (\Exception $e) {
     }
 }
 public function setUp()
 {
     parent::setUp();
     if (!self::$tableCreated) {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("modify_limit_table");
         $table->addColumn('test_int', 'integer');
         $table2 = new \Doctrine\DBAL\Schema\Table("modify_limit_table2");
         $table2->addColumn('test_int', 'integer');
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
         $sm->createTable($table2);
         self::$tableCreated = true;
     }
     $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table'));
     $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2'));
 }
 /**
  * @group DBAL-37
  */
 public function testAlterTableAutoIncrementDrop()
 {
     $tableFrom = new \Doctrine\DBAL\Schema\Table('autoinc_table_drop');
     $column = $tableFrom->addColumn('id', 'integer');
     $column->setAutoincrement(true);
     $this->_sm->createTable($tableFrom);
     $tableFrom = $this->_sm->listTableDetails('autoinc_table_drop');
     $this->assertTrue($tableFrom->getColumn('id')->getAutoincrement());
     $tableTo = new \Doctrine\DBAL\Schema\Table('autoinc_table_drop');
     $column = $tableTo->addColumn('id', 'integer');
     $c = new \Doctrine\DBAL\Schema\Comparator();
     $diff = $c->diffTable($tableFrom, $tableTo);
     $this->assertType('Doctrine\\DBAL\\Schema\\TableDiff', $diff, "There should be a difference and not false being returned from the table comparison");
     $this->assertEquals(array("ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT"), $this->_conn->getDatabasePlatform()->getAlterTableSQL($diff));
     $this->_sm->alterTable($diff);
     $tableFinal = $this->_sm->listTableDetails('autoinc_table_drop');
     $this->assertFalse($tableFinal->getColumn('id')->getAutoincrement());
 }
예제 #16
0
 /**
  * @group DDC-1845
  */
 public function testGenerateTableSqlShouldNotAutoQuotePrimaryKey()
 {
     $table = new \Doctrine\DBAL\Schema\Table('test');
     $table->addColumn('"like"', 'integer', array('notnull' => true, 'autoincrement' => true));
     $table->setPrimaryKey(array('"like"'));
     $createTableSQL = $this->_platform->getCreateTableSQL($table);
     $this->assertEquals('CREATE TABLE test ("like" INTEGER NOT NULL, PRIMARY KEY("like"))', $createTableSQL[0]);
     $this->assertEquals('ALTER TABLE test ADD PRIMARY KEY ("like")', $this->_platform->getCreatePrimaryKeySQL($table->getIndex('primary'), 'test'));
 }
예제 #17
0
 public function setUp()
 {
     parent::setUp();
     if (!self::$tableCreated) {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("modify_limit_table");
         $table->addColumn('test_int', 'integer');
         $table->setPrimaryKey(array('test_int'));
         $table2 = new \Doctrine\DBAL\Schema\Table("modify_limit_table2");
         $table2->addColumn('id', 'integer', array('autoincrement' => true));
         $table2->addColumn('test_int', 'integer');
         $table2->setPrimaryKey(array('id'));
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
         $sm->createTable($table2);
         self::$tableCreated = true;
     }
 }
 public function setUp()
 {
     parent::setUp();
     $platformName = $this->_conn->getDatabasePlatform()->getName();
     // This is a MySQL specific test, skip other vendors.
     if ($platformName != 'mysql') {
         $this->markTestSkipped(sprintf('Test does not work on %s.', $platformName));
     }
     try {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("master_slave_table");
         $table->addColumn('test_int', 'integer');
         $table->setPrimaryKey(array('test_int'));
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
     } catch (\Exception $e) {
     }
     $this->_conn->executeUpdate('DELETE FROM master_slave_table');
     $this->_conn->insert('master_slave_table', array('test_int' => 1));
 }
 public function setUp()
 {
     parent::setUp();
     try {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("caching");
         $table->addColumn('test_int', 'integer');
         $table->addColumn('test_string', 'string', array('notnull' => false));
         $table->setPrimaryKey(array('test_int'));
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
     } catch (\Exception $e) {
     }
     $this->_conn->executeUpdate('DELETE FROM caching');
     foreach ($this->expectedResult as $row) {
         $this->_conn->insert('caching', $row);
     }
     $config = $this->_conn->getConfiguration();
     $config->setSQLLogger($this->sqlLogger = new \Doctrine\DBAL\Logging\DebugStack());
     $cache = new \Doctrine\Common\Cache\ArrayCache();
     $config->setResultCacheImpl($cache);
 }
 private function getPortableConnection($portabilityMode = \Doctrine\DBAL\Portability\Connection::PORTABILITY_ALL, $case = \PDO::CASE_LOWER)
 {
     if (!$this->portableConnection) {
         $params = $this->_conn->getParams();
         $params['wrapperClass'] = 'Doctrine\\DBAL\\Portability\\Connection';
         $params['portability'] = $portabilityMode;
         $params['fetch_case'] = $case;
         $this->portableConnection = DriverManager::getConnection($params, $this->_conn->getConfiguration(), $this->_conn->getEventManager());
         try {
             /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
             $table = new \Doctrine\DBAL\Schema\Table("portability_table");
             $table->addColumn('Test_Int', 'integer');
             $table->addColumn('Test_String', 'string', array('fixed' => true, 'length' => 32));
             $table->addColumn('Test_Null', 'string', array('notnull' => false));
             $sm = $this->portableConnection->getSchemaManager();
             $sm->createTable($table);
             $this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo', 'Test_Null' => ''));
             $this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo  ', 'Test_Null' => null));
         } catch (\Exception $e) {
         }
     }
     return $this->portableConnection;
 }
예제 #21
0
 public function setUp()
 {
     parent::setUp();
     if (self::$generated === false) {
         self::$generated = true;
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $sm = $this->_conn->getSchemaManager();
         $table = new \Doctrine\DBAL\Schema\Table("fetch_table");
         $table->addColumn('test_int', 'integer');
         $table->addColumn('test_string', 'string');
         $table->addColumn('test_datetime', 'timestamp', array('notnull' => false));
         $table->addColumn('test_array', 'array', array('columnDefinition' => 'ARRAY(STRING)'));
         $platformOptions = array('type' => MapType::STRICT, 'fields' => array(new Column('id', Type::getType('integer'), array()), new Column('name', Type::getType('string'), array()), new Column('value', Type::getType('float'), array())));
         $table->addColumn('test_object', MapType::NAME, array('platformOptions' => $platformOptions));
         $table->setPrimaryKey(array('test_int'));
         $sm->createTable($table);
         $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo', 'test_datetime' => new \DateTime('2010-01-01 10:10:10'), 'test_array' => array('foo', 'bar'), 'test_object' => array('id' => 1, 'name' => 'foo', 'value' => 1.234)), array('integer', 'string', 'timestamp', 'array', 'map'));
         $this->refresh('fetch_table');
     }
 }
예제 #22
0
 public function setUp()
 {
     parent::setUp();
     if (self::$generated === false) {
         self::$generated = true;
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("write_table");
         $table->addColumn('test_int', 'integer');
         $table->addColumn('test_string', 'string');
         $table->addColumn('test_float', 'float');
         $table->addColumn('test_array', 'array', array('columnDefinition' => 'ARRAY(STRING)'));
         $platformOptions = array('type' => MapType::STRICT, 'fields' => array(new Column('id', Type::getType('integer'), array()), new Column('name', Type::getType('string'), array()), new Column('value', Type::getType('float'), array())));
         $table->addColumn('test_obj', MapType::NAME, array('platformOptions' => $platformOptions));
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
     }
 }
예제 #23
0
 public function testDomainsTable()
 {
     if ($this->_conn->getDatabasePlatform()->getName() != "postgresql") {
         $this->markTestSkipped('PostgreSQL only test');
     }
     $table = new \Doctrine\DBAL\Schema\Table("domains");
     $table->addColumn('id', 'integer');
     $table->addColumn('parent_id', 'integer');
     $table->setPrimaryKey(array('id'));
     $table->addForeignKeyConstraint('domains', array('parent_id'), array('id'));
     $this->_conn->getSchemaManager()->createTable($table);
     $table = $this->_conn->getSchemaManager()->listTableDetails('domains');
     $this->assertEquals('domains', $table->getName());
 }
예제 #24
0
 public function testListTableWithBinary()
 {
     $tableName = 'test_binary_table';
     $table = new \Doctrine\DBAL\Schema\Table($tableName);
     $table->addColumn('id', 'integer');
     $table->addColumn('column_varbinary', 'binary', array());
     $table->addColumn('column_binary', 'binary', array('fixed' => true));
     $table->setPrimaryKey(array('id'));
     $this->_sm->createTable($table);
     $table = $this->_sm->listTableDetails($tableName);
     $this->assertInstanceOf('Doctrine\\DBAL\\Types\\BinaryType', $table->getColumn('column_varbinary')->getType());
     $this->assertFalse($table->getColumn('column_varbinary')->getFixed());
     $this->assertInstanceOf('Doctrine\\DBAL\\Types\\BinaryType', $table->getColumn('column_binary')->getType());
     $this->assertFalse($table->getColumn('column_binary')->getFixed());
 }
 public function createTable()
 {
     $schema = $this->db->getSchemaManager();
     if ($schema->tablesExist($this->entityTable)) {
         $schema->dropTable($this->entityTable);
     }
     if (!$schema->tablesExist($this->entityTable)) {
         $table = new \Doctrine\DBAL\Schema\Table($this->entityTable);
         $id = $table->addColumn('id', 'integer', array('unsigned' => true, 'autoincrement' => true, 'notnull' => false, 'customSchemaOptions' => array('unique' => true)));
         $id->setAutoincrement(true);
         $id->setNotnull(false);
         $table->setPrimaryKey(array('id'));
         $table->addColumn('uri', 'string', array('length' => 255, 'customSchemaOptions' => array('unique' => true)));
         $table->addColumn('hash', 'string', array('length' => 255));
         $table->addColumn('lmt', 'string', array('length' => 32));
         $table->addColumn('compromised', 'boolean', array('notnull' => false, 'default' => 0));
         //            $table->addColumn('rand' . rand(), 'boolean');
         //            \Symfony\Component\VarDumper\VarDumper::dump($table, 11, 1);
         $schema->createTable($table);
     }
 }
 public function setUp()
 {
     parent::setUp();
     if (self::$generated === false) {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("fetch_table");
         $table->addColumn('test_int', 'integer');
         $table->addColumn('test_string', 'string');
         $table->addColumn('test_datetime', 'datetime', array('notnull' => false));
         $table->setPrimaryKey(array('test_int'));
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
         $this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo', 'test_datetime' => '2010-01-01 10:10:10'));
         self::$generated = true;
     }
 }
예제 #27
0
 public function setUp()
 {
     parent::setUp();
     try {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("blob_table");
         $table->addColumn('id', 'integer');
         $table->addColumn('clobfield', 'text');
         $table->addColumn('blobfield', 'blob');
         $table->setPrimaryKey(array('id'));
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
     } catch (\Exception $e) {
     }
     $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('blob_table'));
 }
예제 #28
0
 protected function setUp()
 {
     parent::setUp();
     if ($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\PDOSqlsrv\Driver) {
         $this->markTestSkipped('This test does not work on pdo_sqlsrv driver due to a bug. See: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/5a755bdd-41e9-45cb-9166-c9da4475bb94/how-to-set-null-for-varbinarymax-using-bindvalue-using-pdosqlsrv?forum=sqldriverforphp');
     }
     try {
         /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
         $table = new \Doctrine\DBAL\Schema\Table("blob_table");
         $table->addColumn('id', 'integer');
         $table->addColumn('clobfield', 'text');
         $table->addColumn('blobfield', 'blob');
         $table->addColumn('binaryfield', 'binary', array('length' => 50));
         $table->setPrimaryKey(array('id'));
         $sm = $this->_conn->getSchemaManager();
         $sm->createTable($table);
     } catch (\Exception $e) {
     }
     $this->_conn->exec($this->_conn->getDatabasePlatform()->getTruncateTableSQL('blob_table'));
 }
 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     if (!class_exists($suite->getName())) {
         return;
     }
     if (!self::$booted && self::$logSQL) {
         self::$booted = true;
         $app = new \Alchemy\Phrasea\Application(\Alchemy\Phrasea\Application::ENV_TEST);
         self::$conn = $app['dbal.provider']($app['db.info']($app['db.appbox.info']));
         unset($app);
         self::$conn->connect();
         $schema = self::$conn->getSchemaManager();
         $tableTest = new \Doctrine\DBAL\Schema\Table("tests");
         /* Add some columns to the table */
         $tableTest->addColumn("id", "integer", array("unsigned" => true, "autoincrement" => true));
         $tableTest->addColumn("test", "string", array("length" => 256));
         $tableTest->addColumn("name", "string", array("length" => 256));
         $tableTest->addColumn("status", "string", array("length" => 16));
         $tableTest->addColumn("duration", "float");
         /* Add a primary key */
         $tableTest->setPrimaryKey(array("id"));
         $schema->dropAndCreateTable($tableTest);
     }
 }
예제 #30
0
 /**
  * Return Current Migration Status of the database.
  *
  * @return MigrationStatus
  */
 public function getCurrentStatus()
 {
     $schemaManager = $this->connection->getSchemaManager();
     $tables = $schemaManager->listTableNames();
     if (!in_array('changelog', $tables)) {
         $table = new \Doctrine\DBAL\Schema\Table('changelog');
         $table->addColumn('change_number', 'integer');
         $table->addColumn('complete_dt', 'datetime', array('columnDefinition' => 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
         $table->addColumn('applied_by', 'string', array('length' => 100));
         $table->addcolumn('description', 'string', array('length' => 500));
         $table->setPrimaryKey(array('change_number'));
         $schemaManager->createTable($table);
     }
     $allMigrations = $this->getAllMigrations($this->schemaDirectory);
     $appliedMigrations = $this->getAppliedMigrations();
     $applyMigrations = array();
     foreach ($allMigrations as $revision => $data) {
         if (!isset($appliedMigrations[$revision])) {
             $applyMigrations[$revision] = $data;
         }
     }
     return new MigrationStatus($allMigrations, $appliedMigrations, $applyMigrations);
 }