[2.0] Refactored Doctrine\DBAL\Schema API a bit Table::createColumn() was inconsistent with all the other methods being add*
This commit is contained in:
parent
b7de1ed115
commit
946fa6d7ca
@ -263,7 +263,7 @@ class Table extends AbstractAsset
|
||||
* @param array $options
|
||||
* @return Column
|
||||
*/
|
||||
public function createColumn($columnName, $typeName, array $options=array())
|
||||
public function addColumn($columnName, $typeName, array $options=array())
|
||||
{
|
||||
$column = new Column($columnName, Type::getType($typeName), $options);
|
||||
|
||||
|
@ -244,7 +244,7 @@ class SchemaTool
|
||||
$discrColumn['length'] = 255;
|
||||
}
|
||||
|
||||
$table->createColumn(
|
||||
$table->addColumn(
|
||||
$class->getQuotedDiscriminatorColumnName($this->_platform),
|
||||
$discrColumn['type'],
|
||||
array('length' => $discrColumn['length'], 'notnull' => true)
|
||||
@ -324,7 +324,7 @@ class SchemaTool
|
||||
// required in some inheritence scenarios
|
||||
$table->changeColumn($columnName, $options);
|
||||
} else {
|
||||
$table->createColumn($columnName, $columnType, $options);
|
||||
$table->addColumn($columnName, $columnType, $options);
|
||||
}
|
||||
|
||||
$isUnique = isset($mapping['unique']) ? $mapping['unique'] : false;
|
||||
@ -433,7 +433,7 @@ class SchemaTool
|
||||
$columnOptions['notnull'] = !$joinColumn['nullable'];
|
||||
}
|
||||
|
||||
$theJoinTable->createColumn(
|
||||
$theJoinTable->addColumn(
|
||||
$columnName, $class->getTypeOfColumn($joinColumn['referencedColumnName']), $columnOptions
|
||||
);
|
||||
}
|
||||
|
@ -91,13 +91,13 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
|
||||
public function testListTableColumns()
|
||||
{
|
||||
$table = new \Doctrine\DBAL\Schema\Table('list_table_columns');
|
||||
$table->createColumn('id', 'integer', array('notnull' => true));
|
||||
$table->createColumn('test', 'string', array('length' => 255, 'notnull' => false));
|
||||
$table->createColumn('foo', 'text', array('notnull' => true));
|
||||
$table->createColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false));
|
||||
$table->createColumn('baz1', 'datetime');
|
||||
$table->createColumn('baz2', 'time');
|
||||
$table->createColumn('baz3', 'date');
|
||||
$table->addColumn('id', 'integer', array('notnull' => true));
|
||||
$table->addColumn('test', 'string', array('length' => 255, 'notnull' => false));
|
||||
$table->addColumn('foo', 'text', array('notnull' => true));
|
||||
$table->addColumn('bar', 'decimal', array('precision' => 10, 'scale' => 4, 'notnull' => false));
|
||||
$table->addColumn('baz1', 'datetime');
|
||||
$table->addColumn('baz2', 'time');
|
||||
$table->addColumn('baz3', 'date');
|
||||
|
||||
$this->_sm->dropAndCreateTable($table);
|
||||
|
||||
@ -370,10 +370,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
|
||||
$table = new \Doctrine\DBAL\Schema\Table($name, array(), array(), array(), \Doctrine\DBAL\Schema\Table::ID_NONE, $options);
|
||||
$table->setSchemaConfig($this->_sm->createSchemaConfig());
|
||||
$table->setIdGeneratorType(\Doctrine\DBAL\Schema\Table::ID_IDENTITY);
|
||||
$table->createColumn('id', 'integer', array('notnull' => true));
|
||||
$table->addColumn('id', 'integer', array('notnull' => true));
|
||||
$table->setPrimaryKey(array('id'));
|
||||
$table->createColumn('test', 'string', array('length' => 255));
|
||||
$table->createColumn('foreign_key_test', 'integer');
|
||||
$table->addColumn('test', 'string', array('length' => 255));
|
||||
$table->addColumn('foreign_key_test', 'integer');
|
||||
return $table;
|
||||
}
|
||||
|
||||
|
@ -27,8 +27,8 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
|
||||
public function testGeneratesTableCreationSql()
|
||||
{
|
||||
$table = new \Doctrine\DBAL\Schema\Table('test');
|
||||
$table->createColumn('id', 'integer', array('notnull' => true));
|
||||
$table->createColumn('test', 'string', array('notnull' => false, 'length' => 255));
|
||||
$table->addColumn('id', 'integer', array('notnull' => true));
|
||||
$table->addColumn('test', 'string', array('notnull' => false, 'length' => 255));
|
||||
$table->setPrimaryKey(array('id'));
|
||||
$table->setIdGeneratorType(\Doctrine\DBAL\Schema\Table::ID_IDENTITY);
|
||||
|
||||
@ -41,8 +41,8 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
|
||||
public function testGenerateTableWithMultiColumnUniqueIndex()
|
||||
{
|
||||
$table = new \Doctrine\DBAL\Schema\Table('test');
|
||||
$table->createColumn('foo', 'string', array('notnull' => false, 'length' => 255));
|
||||
$table->createColumn('bar', 'string', array('notnull' => false, 'length' => 255));
|
||||
$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);
|
||||
|
@ -17,7 +17,7 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
|
||||
public function testGenerateMixedCaseTableCreate()
|
||||
{
|
||||
$table = new \Doctrine\DBAL\Schema\Table("Foo");
|
||||
$table->createColumn("Bar", "integer");
|
||||
$table->addColumn("Bar", "integer");
|
||||
|
||||
$sql = $this->_platform->getCreateTableSql($table);
|
||||
$this->assertEquals('CREATE TABLE Foo (Bar INT NOT NULL) ENGINE = InnoDB', array_shift($sql));
|
||||
|
@ -404,13 +404,13 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function testTableAddForeignKey()
|
||||
{
|
||||
$tableForeign = new Table("bar");
|
||||
$tableForeign->createColumn('id', 'integer');
|
||||
$tableForeign->addColumn('id', 'integer');
|
||||
|
||||
$table1 = new Table("foo");
|
||||
$table1->createColumn('fk', 'integer');
|
||||
$table1->addColumn('fk', 'integer');
|
||||
|
||||
$table2 = new Table("foo");
|
||||
$table2->createColumn('fk', 'integer');
|
||||
$table2->addColumn('fk', 'integer');
|
||||
$table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
|
||||
|
||||
$c = new Comparator();
|
||||
@ -423,13 +423,13 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function testTableRemoveForeignKey()
|
||||
{
|
||||
$tableForeign = new Table("bar");
|
||||
$tableForeign->createColumn('id', 'integer');
|
||||
$tableForeign->addColumn('id', 'integer');
|
||||
|
||||
$table1 = new Table("foo");
|
||||
$table1->createColumn('fk', 'integer');
|
||||
$table1->addColumn('fk', 'integer');
|
||||
|
||||
$table2 = new Table("foo");
|
||||
$table2->createColumn('fk', 'integer');
|
||||
$table2->addColumn('fk', 'integer');
|
||||
$table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
|
||||
|
||||
$c = new Comparator();
|
||||
@ -442,14 +442,14 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function testTableUpdateForeignKey()
|
||||
{
|
||||
$tableForeign = new Table("bar");
|
||||
$tableForeign->createColumn('id', 'integer');
|
||||
$tableForeign->addColumn('id', 'integer');
|
||||
|
||||
$table1 = new Table("foo");
|
||||
$table1->createColumn('fk', 'integer');
|
||||
$table1->addColumn('fk', 'integer');
|
||||
$table1->addForeignKeyConstraint($tableForeign, array('fk'), array('id'));
|
||||
|
||||
$table2 = new Table("foo");
|
||||
$table2->createColumn('fk', 'integer');
|
||||
$table2->addColumn('fk', 'integer');
|
||||
$table2->addForeignKeyConstraint($tableForeign, array('fk'), array('id'), array('onUpdate' => 'CASCADE'));
|
||||
|
||||
$c = new Comparator();
|
||||
@ -502,10 +502,10 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function testCompareColumnCompareCaseInsensitive()
|
||||
{
|
||||
$tableA = new Table("foo");
|
||||
$tableA->createColumn('id', 'integer');
|
||||
$tableA->addColumn('id', 'integer');
|
||||
|
||||
$tableB = new Table("foo");
|
||||
$tableB->createColumn('ID', 'integer');
|
||||
$tableB->addColumn('ID', 'integer');
|
||||
|
||||
$c = new Comparator();
|
||||
$tableDiff = $c->diffTable($tableA, $tableB);
|
||||
@ -516,11 +516,11 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function testCompareIndexBasedOnPropertiesNotName()
|
||||
{
|
||||
$tableA = new Table("foo");
|
||||
$tableA->createColumn('id', 'integer');
|
||||
$tableA->addColumn('id', 'integer');
|
||||
$tableA->addIndex(array("id"), "foo_bar_idx");
|
||||
|
||||
$tableB = new Table("foo");
|
||||
$tableB->createColumn('ID', 'integer');
|
||||
$tableB->addColumn('ID', 'integer');
|
||||
$tableB->addIndex(array("id"), "bar_foo_idx");
|
||||
|
||||
$c = new Comparator();
|
||||
@ -532,11 +532,11 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function testCompareForeignKeyBasedOnPropertiesNotName()
|
||||
{
|
||||
$tableA = new Table("foo");
|
||||
$tableA->createColumn('id', 'integer');
|
||||
$tableA->addColumn('id', 'integer');
|
||||
$tableA->addNamedForeignKeyConstraint('foo_constraint', 'bar', array('id'), array('id'));
|
||||
|
||||
$tableB = new Table("foo");
|
||||
$tableB->createColumn('ID', 'integer');
|
||||
$tableB->addColumn('ID', 'integer');
|
||||
$tableB->addNamedForeignKeyConstraint('bar_constraint', 'bar', array('id'), array('id'));
|
||||
|
||||
$c = new Comparator();
|
||||
@ -548,10 +548,10 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
|
||||
public function testDetectRenameColumn()
|
||||
{
|
||||
$tableA = new Table("foo");
|
||||
$tableA->createColumn('foo', 'integer');
|
||||
$tableA->addColumn('foo', 'integer');
|
||||
|
||||
$tableB = new Table("foo");
|
||||
$tableB->createColumn('bar', 'integer');
|
||||
$tableB->addColumn('bar', 'integer');
|
||||
|
||||
$c = new Comparator();
|
||||
$tableDiff = $c->diffTable($tableA, $tableB);
|
||||
|
@ -171,11 +171,11 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$schema = new Schema();
|
||||
$tableA = $schema->createTable('foo');
|
||||
$tableA->createColumn('id', 'integer');
|
||||
$tableA->addColumn('id', 'integer');
|
||||
|
||||
$tableB = $schema->createTable('bar');
|
||||
$tableB->createColumn('id', 'integer');
|
||||
$tableB->createcolumn('foo_id', 'integer');
|
||||
$tableB->addColumn('id', 'integer');
|
||||
$tableB->addColumn('foo_id', 'integer');
|
||||
$tableB->addForeignKeyConstraint($tableA, array('foo_id'), array('id'));
|
||||
|
||||
$this->assertEquals(0, count($tableB->getIndexes()));
|
||||
@ -207,7 +207,7 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$schema = new Schema(array(), array(), array(), array(), $schemaConfig);
|
||||
$table = $schema->createTable("smalltable");
|
||||
$table->createColumn('long_id', 'integer');
|
||||
$table->addColumn('long_id', 'integer');
|
||||
$table->addIndex(array('long_id'));
|
||||
|
||||
$this->assertTrue($table->hasIndex('le_id_idx'));
|
||||
@ -219,11 +219,11 @@ class SchemaTest extends \PHPUnit_Framework_TestCase
|
||||
$sequence = $schema->createSequence('baz');
|
||||
|
||||
$tableA = $schema->createTable('foo');
|
||||
$tableA->createColumn('id', 'integer');
|
||||
$tableA->addColumn('id', 'integer');
|
||||
|
||||
$tableB = $schema->createTable('bar');
|
||||
$tableB->createColumn('id', 'integer');
|
||||
$tableB->createcolumn('foo_id', 'integer');
|
||||
$tableB->addColumn('id', 'integer');
|
||||
$tableB->addColumn('foo_id', 'integer');
|
||||
$tableB->addForeignKeyConstraint($tableA, array('foo_id'), array('id'));
|
||||
|
||||
$schemaNew = clone $schema;
|
||||
|
@ -47,7 +47,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
public function testColumnsCaseInsensitive()
|
||||
{
|
||||
$table = new Table("foo");
|
||||
$column = $table->createColumn('Foo', 'integer');
|
||||
$column = $table->addColumn('Foo', 'integer');
|
||||
|
||||
$this->assertTrue($table->hasColumn('Foo'));
|
||||
$this->assertTrue($table->hasColumn('foo'));
|
||||
@ -65,7 +65,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
$table = new Table("foo");
|
||||
|
||||
$this->assertFalse($table->hasColumn("bar"));
|
||||
$table->createColumn("bar", 'integer');
|
||||
$table->addColumn("bar", 'integer');
|
||||
$this->assertTrue($table->hasColumn("bar"));
|
||||
$this->assertSame($type, $table->getColumn("bar")->getType());
|
||||
}
|
||||
@ -223,7 +223,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$table = new Table("foo");
|
||||
|
||||
$table->createColumn("bar", 'integer');
|
||||
$table->addColumn("bar", 'integer');
|
||||
$table->setPrimaryKey(array("bar"));
|
||||
|
||||
$this->assertTrue($table->hasIndex("primary"));
|
||||
@ -236,7 +236,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$table = new Table("foo");
|
||||
|
||||
$table->createColumn("bar", 'integer');
|
||||
$table->addColumn("bar", 'integer');
|
||||
$table->addUniqueIndex(array("bar"), "my_idx");
|
||||
|
||||
$this->assertTrue($table->hasIndex("my_idx"));
|
||||
@ -248,7 +248,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$table = new Table("foo");
|
||||
|
||||
$table->createColumn("bar", 'integer');
|
||||
$table->addColumn("bar", 'integer');
|
||||
$table->addIndex(array("bar"), "my_idx");
|
||||
|
||||
$this->assertTrue($table->hasIndex("my_idx"));
|
||||
@ -261,7 +261,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
$this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
|
||||
|
||||
$table = new Table("foo");
|
||||
$table->createColumn("bar",'integer');
|
||||
$table->addColumn("bar",'integer');
|
||||
$table->addIndex(array("bar"), "invalid name %&/");
|
||||
}
|
||||
|
||||
@ -297,10 +297,10 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
$this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
|
||||
|
||||
$table = new Table("foo");
|
||||
$table->createColumn("id", 'int');
|
||||
$table->addColumn("id", 'int');
|
||||
|
||||
$foreignTable = new Table("bar");
|
||||
$foreignTable->createColumn("id", 'int');
|
||||
$foreignTable->addColumn("id", 'int');
|
||||
|
||||
$table->addForeignKeyConstraint($foreignTable, array("foo"), array("id"));
|
||||
}
|
||||
@ -310,10 +310,10 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
$this->setExpectedException("Doctrine\DBAL\Schema\SchemaException");
|
||||
|
||||
$table = new Table("foo");
|
||||
$table->createColumn("id", 'integer');
|
||||
$table->addColumn("id", 'integer');
|
||||
|
||||
$foreignTable = new Table("bar");
|
||||
$foreignTable->createColumn("id", 'integer');
|
||||
$foreignTable->addColumn("id", 'integer');
|
||||
|
||||
$table->addForeignKeyConstraint($foreignTable, array("id"), array("foo"));
|
||||
}
|
||||
@ -321,10 +321,10 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
public function testAddForeignKeyConstraint()
|
||||
{
|
||||
$table = new Table("foo");
|
||||
$table->createColumn("id", 'integer');
|
||||
$table->addColumn("id", 'integer');
|
||||
|
||||
$foreignTable = new Table("bar");
|
||||
$foreignTable->createColumn("id", 'integer');
|
||||
$foreignTable->addColumn("id", 'integer');
|
||||
|
||||
$table->addForeignKeyConstraint($foreignTable, array("id"), array("id"), array("foo" => "bar"));
|
||||
|
||||
@ -340,7 +340,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
public function testAddIndexWithCaseSensitiveColumnProblem()
|
||||
{
|
||||
$table = new Table("foo");
|
||||
$table->createColumn("id", 'integer');
|
||||
$table->addColumn("id", 'integer');
|
||||
|
||||
$table->addIndex(array("ID"), "my_idx");
|
||||
|
||||
@ -351,7 +351,7 @@ class TableTest extends \PHPUnit_Framework_TestCase
|
||||
public function testAddPrimaryKey_ColumnsAreExplicitlySetToNotNull()
|
||||
{
|
||||
$table = new Table("foo");
|
||||
$column = $table->createColumn("id", 'integer', array('notnull' => false));
|
||||
$column = $table->addColumn("id", 'integer', array('notnull' => false));
|
||||
|
||||
$this->assertFalse($column->getNotnull());
|
||||
|
||||
|
@ -63,15 +63,15 @@ class SchemaSqlCollectorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$schema = new Schema();
|
||||
$tableA = $schema->createTable("foo");
|
||||
$tableA->createColumn("id", 'integer');
|
||||
$tableA->createColumn("bar", 'string', array('length' => 255));
|
||||
$tableA->addColumn("id", 'integer');
|
||||
$tableA->addColumn("bar", 'string', array('length' => 255));
|
||||
$tableA->setPrimaryKey(array("id"));
|
||||
$tableA->setIdGeneratorType(Table::ID_SEQUENCE);
|
||||
|
||||
$schema->createSequence("foo_seq");
|
||||
|
||||
$tableB = $schema->createTable("bar");
|
||||
$tableB->createColumn("id", 'integer');
|
||||
$tableB->addColumn("id", 'integer');
|
||||
$tableB->setPrimaryKey(array("id"));
|
||||
|
||||
$tableA->addForeignKeyConstraint($tableB, array("bar"), array("id"));
|
||||
|
@ -27,9 +27,9 @@ class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
}
|
||||
|
||||
$table = new \Doctrine\DBAL\Schema\Table("dbdriver_foo");
|
||||
$table->createColumn('id', 'integer');
|
||||
$table->addColumn('id', 'integer');
|
||||
$table->setPrimaryKey(array('id'));
|
||||
$table->createColumn('bar', 'string', array('length' => 200));
|
||||
$table->addColumn('bar', 'string', array('length' => 200));
|
||||
|
||||
$this->_sm->dropAndCreateTable($table);
|
||||
|
||||
@ -56,15 +56,15 @@ class DatabaseDriverTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
}
|
||||
|
||||
$tableB = new \Doctrine\DBAL\Schema\Table("dbdriver_bar");
|
||||
$tableB->createColumn('id', 'integer');
|
||||
$tableB->addColumn('id', 'integer');
|
||||
$tableB->setPrimaryKey(array('id'));
|
||||
|
||||
$this->_sm->dropAndCreateTable($tableB);
|
||||
|
||||
$tableA = new \Doctrine\DBAL\Schema\Table("dbdriver_baz");
|
||||
$tableA->createColumn('id', 'integer');
|
||||
$tableA->addColumn('id', 'integer');
|
||||
$tableA->setPrimaryKey(array('id'));
|
||||
$tableA->createColumn('bar_id', 'integer');
|
||||
$tableA->addColumn('bar_id', 'integer');
|
||||
$tableA->addForeignKeyConstraint('dbdriver_bar', array('bar_id'), array('id'));
|
||||
|
||||
$this->_sm->dropAndCreateTable($tableA);
|
||||
|
Loading…
Reference in New Issue
Block a user