|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace RDV\Bundle\MigrationBundle\Migration\Schema; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\DBAL\DBALException; |
|
6
|
|
|
use Doctrine\DBAL\Schema\SchemaConfig; |
|
7
|
|
|
use Doctrine\DBAL\Schema\Sequence; |
|
8
|
|
|
use RDV\Bundle\MigrationBundle\Tools\DbIdentifierNameGenerator; |
|
9
|
|
|
|
|
10
|
|
|
class SchemaWithNameGenerator extends Schema |
|
11
|
|
|
{ |
|
12
|
|
|
const TABLE_CLASS = 'RDV\Bundle\MigrationBundle\Migration\Schema\TableWithNameGenerator'; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @var DbIdentifierNameGenerator |
|
16
|
|
|
*/ |
|
17
|
|
|
protected $nameGenerator; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @param DbIdentifierNameGenerator $nameGenerator |
|
21
|
|
|
* @param Table[] $tables |
|
22
|
|
|
* @param Sequence[] $sequences |
|
23
|
|
|
* @param SchemaConfig $schemaConfig |
|
24
|
|
|
*/ |
|
25
|
|
|
public function __construct( |
|
26
|
|
|
DbIdentifierNameGenerator $nameGenerator, |
|
27
|
|
|
array $tables = [], |
|
28
|
|
|
array $sequences = [], |
|
29
|
|
|
SchemaConfig $schemaConfig = null |
|
30
|
|
|
) { |
|
31
|
|
|
$this->nameGenerator = $nameGenerator; |
|
32
|
|
|
|
|
33
|
|
|
parent::__construct($tables, $sequences, $schemaConfig); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* {@inheritdoc} |
|
38
|
|
|
*/ |
|
39
|
|
|
protected function createTableObject(array $args) |
|
40
|
|
|
{ |
|
41
|
|
|
$args['nameGenerator'] = $this->nameGenerator; |
|
42
|
|
|
|
|
43
|
|
|
return parent::createTableObject($args); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* {@inheritdoc} |
|
48
|
|
|
*/ |
|
49
|
|
|
public function renameTable($oldTableName, $newTableName) |
|
50
|
|
|
{ |
|
51
|
|
|
throw new DBALException( |
|
52
|
|
|
"Schema#renameTable() was removed, because it drops and recreates " . |
|
53
|
|
|
"the table instead. There is no fix available, because a schema diff cannot reliably detect if a " . |
|
54
|
|
|
"table was renamed or one table was created and another one dropped." |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|