1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Cycle\Schema\Generator; |
||
6 | |||
7 | use Cycle\Schema\GeneratorInterface; |
||
8 | use Cycle\Schema\Registry; |
||
9 | |||
10 | /** |
||
11 | * Declare table dropped (initiate diff calculation). |
||
12 | */ |
||
13 | final class ResetTables implements GeneratorInterface |
||
14 | { |
||
15 | public function run(Registry $registry): Registry |
||
16 | { |
||
17 | foreach ($registry as $entity) { |
||
18 | if (!$registry->hasTable($entity)) { |
||
19 | continue; |
||
20 | 16 | } |
|
21 | |||
22 | 16 | $schema = $registry->getTableSchema($entity); |
|
23 | 16 | if ($schema->exists()) { |
|
24 | $state = $schema->getState(); |
||
25 | |||
26 | // clean up all indexes and columns |
||
27 | 16 | foreach ($state->getForeignKeys() as $fk) { |
|
28 | 16 | $state->forgerForeignKey($fk); |
|
0 ignored issues
–
show
|
|||
29 | } |
||
30 | |||
31 | // clean up all indexes and columns |
||
32 | foreach ($state->getColumns() as $column) { |
||
33 | $state->forgetColumn($column); |
||
34 | } |
||
35 | |||
36 | foreach ($state->getIndexes() as $index) { |
||
37 | $state->forgetIndex($index); |
||
38 | } |
||
39 | |||
40 | $state->setPrimaryKeys([]); |
||
41 | |||
42 | $schema->setState($state); |
||
43 | } |
||
44 | } |
||
45 | |||
46 | return $registry; |
||
47 | } |
||
48 | } |
||
49 |
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.