1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
namespace TheCodingMachine\TDBM\Schema; |
5
|
|
|
|
6
|
|
|
use Doctrine\DBAL\Connection; |
7
|
|
|
use Doctrine\DBAL\Platforms\AbstractPlatform; |
8
|
|
|
use Doctrine\DBAL\Schema\AbstractSchemaManager; |
9
|
|
|
use Doctrine\DBAL\Schema\Column; |
10
|
|
|
use Doctrine\DBAL\Schema\Constraint; |
11
|
|
|
use Doctrine\DBAL\Schema\ForeignKeyConstraint; |
12
|
|
|
use Doctrine\DBAL\Schema\Index; |
13
|
|
|
use Doctrine\DBAL\Schema\Sequence; |
14
|
|
|
use Doctrine\DBAL\Schema\Table; |
15
|
|
|
use Doctrine\DBAL\Schema\TableDiff; |
16
|
|
|
use Doctrine\DBAL\Schema\View; |
17
|
|
|
use TheCodingMachine\TDBM\SchemaLockFileDumper; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* A DBAL SchemaManager that reads the schema from the lock file instead of reading it from the database. |
21
|
|
|
* Useful to avoid costly introspection queries at runtime. |
22
|
|
|
* |
23
|
|
|
* Acts as an adapter on top of an existing schema manager. |
24
|
|
|
*/ |
25
|
|
|
class LockFileSchemaManager extends AbstractSchemaManager |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var AbstractSchemaManager |
29
|
|
|
*/ |
30
|
|
|
private $schemaManager; |
31
|
|
|
/** |
32
|
|
|
* @var SchemaLockFileDumper |
33
|
|
|
*/ |
34
|
|
|
private $schemaLockFileDumper; |
35
|
|
|
|
36
|
|
|
public function __construct(AbstractSchemaManager $schemaManager, SchemaLockFileDumper $schemaLockFileDumper) |
37
|
|
|
{ |
38
|
|
|
$this->schemaManager = $schemaManager; |
39
|
|
|
$this->schemaLockFileDumper = $schemaLockFileDumper; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function getDatabasePlatform() |
43
|
|
|
{ |
44
|
|
|
return $this->schemaManager->getDatabasePlatform(); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function tryMethod() |
48
|
|
|
{ |
49
|
|
|
return $this->schemaManager->tryMethod(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
public function listDatabases() |
53
|
|
|
{ |
54
|
|
|
return $this->schemaManager->listDatabases(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function listNamespaceNames() |
58
|
|
|
{ |
59
|
|
|
return $this->schemaManager->listNamespaceNames(); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function listSequences($database = null) |
63
|
|
|
{ |
64
|
|
|
return $this->schemaManager->listSequences($database); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function listTableColumns($table, $database = null) |
68
|
|
|
{ |
69
|
|
|
return $this->schemaManager->listTableColumns($table, $database); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function listTableIndexes($table) |
73
|
|
|
{ |
74
|
|
|
return $this->schemaManager->listTableIndexes($table); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
public function tablesExist($tableNames) |
78
|
|
|
{ |
79
|
|
|
return $this->schemaManager->tablesExist($tableNames); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function listTableNames() |
83
|
|
|
{ |
84
|
|
|
return $this->schemaManager->listTableNames(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
protected function filterAssetNames($assetNames) |
88
|
|
|
{ |
89
|
|
|
return $this->schemaManager->filterAssetNames($assetNames); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
protected function getFilterSchemaAssetsExpression() |
93
|
|
|
{ |
94
|
|
|
return $this->schemaManager->getFilterSchemaAssetsExpression(); |
|
|
|
|
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function listTables() |
98
|
|
|
{ |
99
|
|
|
return $this->schemaManager->listTables(); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function listTableDetails($tableName) |
103
|
|
|
{ |
104
|
|
|
return $this->schemaManager->listTableDetails($tableName); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function listViews() |
108
|
|
|
{ |
109
|
|
|
return $this->schemaManager->listViews(); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function listTableForeignKeys($table, $database = null) |
113
|
|
|
{ |
114
|
|
|
return $this->schemaManager->listTableForeignKeys($table, $database); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function dropDatabase($database) |
118
|
|
|
{ |
119
|
|
|
$this->schemaManager->dropDatabase($database); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function dropTable($tableName) |
123
|
|
|
{ |
124
|
|
|
$this->schemaManager->dropTable($tableName); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function dropIndex($index, $table) |
128
|
|
|
{ |
129
|
|
|
$this->schemaManager->dropIndex($index, $table); |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function dropConstraint(Constraint $constraint, $table) |
133
|
|
|
{ |
134
|
|
|
$this->schemaManager->dropConstraint($constraint, $table); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
public function dropForeignKey($foreignKey, $table) |
138
|
|
|
{ |
139
|
|
|
$this->schemaManager->dropForeignKey($foreignKey, $table); |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function dropSequence($name) |
143
|
|
|
{ |
144
|
|
|
$this->schemaManager->dropSequence($name); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
public function dropView($name) |
148
|
|
|
{ |
149
|
|
|
$this->schemaManager->dropView($name); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function createDatabase($database) |
153
|
|
|
{ |
154
|
|
|
$this->schemaManager->createDatabase($database); |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
public function createTable(Table $table) |
158
|
|
|
{ |
159
|
|
|
$this->schemaManager->createTable($table); |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function createSequence($sequence) |
163
|
|
|
{ |
164
|
|
|
$this->schemaManager->createSequence($sequence); |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
public function createConstraint(Constraint $constraint, $table) |
168
|
|
|
{ |
169
|
|
|
$this->schemaManager->createConstraint($constraint, $table); |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
public function createIndex(Index $index, $table) |
173
|
|
|
{ |
174
|
|
|
$this->schemaManager->createIndex($index, $table); |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
public function createForeignKey(ForeignKeyConstraint $foreignKey, $table) |
178
|
|
|
{ |
179
|
|
|
$this->schemaManager->createForeignKey($foreignKey, $table); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function createView(View $view) |
183
|
|
|
{ |
184
|
|
|
$this->schemaManager->createView($view); |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
public function dropAndCreateConstraint(Constraint $constraint, $table) |
188
|
|
|
{ |
189
|
|
|
$this->schemaManager->dropAndCreateConstraint($constraint, $table); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public function dropAndCreateIndex(Index $index, $table) |
193
|
|
|
{ |
194
|
|
|
$this->schemaManager->dropAndCreateIndex($index, $table); |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
public function dropAndCreateForeignKey(ForeignKeyConstraint $foreignKey, $table) |
198
|
|
|
{ |
199
|
|
|
$this->schemaManager->dropAndCreateForeignKey($foreignKey, $table); |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
public function dropAndCreateSequence(Sequence $sequence) |
203
|
|
|
{ |
204
|
|
|
$this->schemaManager->dropAndCreateSequence($sequence); |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
public function dropAndCreateTable(Table $table) |
208
|
|
|
{ |
209
|
|
|
$this->schemaManager->dropAndCreateTable($table); |
210
|
|
|
} |
211
|
|
|
|
212
|
|
|
public function dropAndCreateDatabase($database) |
213
|
|
|
{ |
214
|
|
|
$this->schemaManager->dropAndCreateDatabase($database); |
215
|
|
|
} |
216
|
|
|
|
217
|
|
|
public function dropAndCreateView(View $view) |
218
|
|
|
{ |
219
|
|
|
$this->schemaManager->dropAndCreateView($view); |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
public function alterTable(TableDiff $tableDiff) |
223
|
|
|
{ |
224
|
|
|
$this->schemaManager->alterTable($tableDiff); |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
public function renameTable($name, $newName) |
228
|
|
|
{ |
229
|
|
|
$this->schemaManager->renameTable($name, $newName); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
protected function _getPortableDatabasesList($databases) |
233
|
|
|
{ |
234
|
|
|
return $this->schemaManager->_getPortableDatabasesList($databases); |
235
|
|
|
} |
236
|
|
|
|
237
|
|
|
protected function getPortableNamespacesList(array $namespaces) |
238
|
|
|
{ |
239
|
|
|
return $this->schemaManager->getPortableNamespacesList($namespaces); |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
protected function _getPortableDatabaseDefinition($database) |
243
|
|
|
{ |
244
|
|
|
return $this->schemaManager->_getPortableDatabaseDefinition($database); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
protected function getPortableNamespaceDefinition(array $namespace) |
248
|
|
|
{ |
249
|
|
|
return $this->schemaManager->getPortableNamespaceDefinition($namespace); |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
protected function _getPortableFunctionsList($functions) |
253
|
|
|
{ |
254
|
|
|
return $this->schemaManager->_getPortableFunctionsList($functions); |
|
|
|
|
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
protected function _getPortableFunctionDefinition($function) |
258
|
|
|
{ |
259
|
|
|
return $this->schemaManager->_getPortableFunctionDefinition($function); |
|
|
|
|
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
protected function _getPortableTriggersList($triggers) |
263
|
|
|
{ |
264
|
|
|
return $this->schemaManager->_getPortableTriggersList($triggers); |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
protected function _getPortableTriggerDefinition($trigger) |
268
|
|
|
{ |
269
|
|
|
return $this->schemaManager->_getPortableTriggerDefinition($trigger); |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
protected function _getPortableSequencesList($sequences) |
273
|
|
|
{ |
274
|
|
|
return $this->schemaManager->_getPortableSequencesList($sequences); |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
protected function _getPortableSequenceDefinition($sequence) |
278
|
|
|
{ |
279
|
|
|
$this->schemaManager->_getPortableSequenceDefinition($sequence); |
280
|
|
|
} |
281
|
|
|
|
282
|
|
|
protected function _getPortableTableColumnList($table, $database, $tableColumns) |
283
|
|
|
{ |
284
|
|
|
return $this->schemaManager->_getPortableTableColumnList($table, $database, $tableColumns); |
285
|
|
|
} |
286
|
|
|
|
287
|
|
|
protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) |
288
|
|
|
{ |
289
|
|
|
return $this->schemaManager->_getPortableTableIndexesList($tableIndexRows, $tableName); |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
protected function _getPortableTablesList($tables) |
293
|
|
|
{ |
294
|
|
|
return $this->schemaManager->_getPortableTablesList($tables); |
295
|
|
|
} |
296
|
|
|
|
297
|
|
|
protected function _getPortableTableDefinition($table) |
298
|
|
|
{ |
299
|
|
|
return $this->schemaManager->_getPortableTableDefinition($table); |
300
|
|
|
} |
301
|
|
|
|
302
|
|
|
protected function _getPortableUsersList($users) |
303
|
|
|
{ |
304
|
|
|
return $this->schemaManager->_getPortableUsersList($users); |
305
|
|
|
} |
306
|
|
|
|
307
|
|
|
protected function _getPortableUserDefinition($user) |
308
|
|
|
{ |
309
|
|
|
return $this->schemaManager->_getPortableUserDefinition($user); |
310
|
|
|
} |
311
|
|
|
|
312
|
|
|
protected function _getPortableViewsList($views) |
313
|
|
|
{ |
314
|
|
|
return $this->schemaManager->_getPortableViewsList($views); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
protected function _getPortableViewDefinition($view) |
318
|
|
|
{ |
319
|
|
|
return $this->schemaManager->_getPortableViewDefinition($view); |
320
|
|
|
} |
321
|
|
|
|
322
|
|
|
protected function _getPortableTableForeignKeysList($tableForeignKeys) |
323
|
|
|
{ |
324
|
|
|
return $this->schemaManager->_getPortableTableForeignKeysList($tableForeignKeys); |
325
|
|
|
} |
326
|
|
|
|
327
|
|
|
protected function _getPortableTableForeignKeyDefinition($tableForeignKey) |
328
|
|
|
{ |
329
|
|
|
return $this->schemaManager->_getPortableTableForeignKeyDefinition($tableForeignKey); |
330
|
|
|
} |
331
|
|
|
|
332
|
|
|
protected function _execSql($sql) |
333
|
|
|
{ |
334
|
|
|
$this->schemaManager->_execSql($sql); |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
public function createSchema() |
338
|
|
|
{ |
339
|
|
|
return $this->schemaLockFileDumper->getSchema(); |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
public function createSchemaConfig() |
343
|
|
|
{ |
344
|
|
|
return $this->schemaManager->createSchemaConfig(); |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
public function getSchemaSearchPaths() |
348
|
|
|
{ |
349
|
|
|
return $this->schemaManager->getSchemaSearchPaths(); |
350
|
|
|
} |
351
|
|
|
|
352
|
|
|
public function extractDoctrineTypeFromComment($comment, $currentType) |
353
|
|
|
{ |
354
|
|
|
return $this->schemaManager->extractDoctrineTypeFromComment($comment, $currentType); |
355
|
|
|
} |
356
|
|
|
|
357
|
|
|
public function removeDoctrineTypeFromComment($comment, $type) |
358
|
|
|
{ |
359
|
|
|
return $this->schemaManager->removeDoctrineTypeFromComment($comment, $type); |
360
|
|
|
} |
361
|
|
|
|
362
|
|
|
protected function _getPortableTableColumnDefinition($tableColumn) |
363
|
|
|
{ |
364
|
|
|
return $this->schemaManager->_getPortableTableColumnDefinition($tableColumn); |
365
|
|
|
} |
366
|
|
|
} |
367
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.