| @@ 391-413 (lines=23) @@ | ||
| 388 | /** |
|
| 389 | * @group DBAL-2302 |
|
| 390 | */ |
|
| 391 | public function testDropNonAutoincrementColumnFromCompositePrimaryKeyWithAutoincrementColumn() |
|
| 392 | { |
|
| 393 | $table = new Table("tbl"); |
|
| 394 | $table->addColumn('id', 'integer', array('autoincrement' => true)); |
|
| 395 | $table->addColumn('foo', 'integer'); |
|
| 396 | $table->addColumn('bar', 'integer'); |
|
| 397 | $table->setPrimaryKey(array('id', 'foo')); |
|
| 398 | ||
| 399 | $comparator = new Comparator(); |
|
| 400 | $diffTable = clone $table; |
|
| 401 | ||
| 402 | $diffTable->dropPrimaryKey(); |
|
| 403 | $diffTable->setPrimaryKey(array('id')); |
|
| 404 | ||
| 405 | self::assertSame( |
|
| 406 | array( |
|
| 407 | 'ALTER TABLE tbl MODIFY id INT NOT NULL', |
|
| 408 | 'ALTER TABLE tbl DROP PRIMARY KEY', |
|
| 409 | 'ALTER TABLE tbl ADD PRIMARY KEY (id)', |
|
| 410 | ), |
|
| 411 | $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)) |
|
| 412 | ); |
|
| 413 | } |
|
| 414 | ||
| 415 | /** |
|
| 416 | * @group DBAL-2302 |
|
| @@ 418-440 (lines=23) @@ | ||
| 415 | /** |
|
| 416 | * @group DBAL-2302 |
|
| 417 | */ |
|
| 418 | public function testAddNonAutoincrementColumnToPrimaryKeyWithAutoincrementColumn() |
|
| 419 | { |
|
| 420 | $table = new Table("tbl"); |
|
| 421 | $table->addColumn('id', 'integer', array('autoincrement' => true)); |
|
| 422 | $table->addColumn('foo', 'integer'); |
|
| 423 | $table->addColumn('bar', 'integer'); |
|
| 424 | $table->setPrimaryKey(array('id')); |
|
| 425 | ||
| 426 | $comparator = new Comparator(); |
|
| 427 | $diffTable = clone $table; |
|
| 428 | ||
| 429 | $diffTable->dropPrimaryKey(); |
|
| 430 | $diffTable->setPrimaryKey(array('id', 'foo')); |
|
| 431 | ||
| 432 | self::assertSame( |
|
| 433 | array( |
|
| 434 | 'ALTER TABLE tbl MODIFY id INT NOT NULL', |
|
| 435 | 'ALTER TABLE tbl DROP PRIMARY KEY', |
|
| 436 | 'ALTER TABLE tbl ADD PRIMARY KEY (id, foo)', |
|
| 437 | ), |
|
| 438 | $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)) |
|
| 439 | ); |
|
| 440 | } |
|
| 441 | ||
| 442 | /** |
|
| 443 | * @group DBAL-586 |
|
| @@ 478-500 (lines=23) @@ | ||
| 475 | ), $sql); |
|
| 476 | } |
|
| 477 | ||
| 478 | public function testAlterPrimaryKeyWithNewColumn() |
|
| 479 | { |
|
| 480 | $table = new Table("yolo"); |
|
| 481 | $table->addColumn('pkc1', 'integer'); |
|
| 482 | $table->addColumn('col_a', 'integer'); |
|
| 483 | $table->setPrimaryKey(array('pkc1')); |
|
| 484 | ||
| 485 | $comparator = new Comparator(); |
|
| 486 | $diffTable = clone $table; |
|
| 487 | ||
| 488 | $diffTable->addColumn('pkc2', 'integer'); |
|
| 489 | $diffTable->dropPrimaryKey(); |
|
| 490 | $diffTable->setPrimaryKey(array('pkc1', 'pkc2')); |
|
| 491 | ||
| 492 | self::assertSame( |
|
| 493 | array( |
|
| 494 | 'ALTER TABLE yolo DROP PRIMARY KEY', |
|
| 495 | 'ALTER TABLE yolo ADD pkc2 INT NOT NULL', |
|
| 496 | 'ALTER TABLE yolo ADD PRIMARY KEY (pkc1, pkc2)', |
|
| 497 | ), |
|
| 498 | $this->_platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)) |
|
| 499 | ); |
|
| 500 | } |
|
| 501 | ||
| 502 | public function testInitializesDoctrineTypeMappings() |
|
| 503 | { |
|