@@ -35,76 +35,76 @@ |
||
35 | 35 | |
36 | 36 | class Version20000Date20201109081918 extends SimpleMigrationStep { |
37 | 37 | |
38 | - /** @var IDBConnection */ |
|
39 | - protected $connection; |
|
38 | + /** @var IDBConnection */ |
|
39 | + protected $connection; |
|
40 | 40 | |
41 | - public function __construct(IDBConnection $connection) { |
|
42 | - $this->connection = $connection; |
|
43 | - } |
|
41 | + public function __construct(IDBConnection $connection) { |
|
42 | + $this->connection = $connection; |
|
43 | + } |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param IOutput $output |
|
47 | - * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
48 | - * @param array $options |
|
49 | - * @return null|ISchemaWrapper |
|
50 | - */ |
|
51 | - public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
52 | - /** @var ISchemaWrapper $schema */ |
|
53 | - $schema = $schemaClosure(); |
|
45 | + /** |
|
46 | + * @param IOutput $output |
|
47 | + * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` |
|
48 | + * @param array $options |
|
49 | + * @return null|ISchemaWrapper |
|
50 | + */ |
|
51 | + public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper { |
|
52 | + /** @var ISchemaWrapper $schema */ |
|
53 | + $schema = $schemaClosure(); |
|
54 | 54 | |
55 | - if (!$schema->hasTable('storages_credentials')) { |
|
56 | - $table = $schema->createTable('storages_credentials'); |
|
57 | - $table->addColumn('id', Type::BIGINT, [ |
|
58 | - 'autoincrement' => true, |
|
59 | - 'notnull' => true, |
|
60 | - 'length' => 64, |
|
61 | - ]); |
|
62 | - $table->addColumn('user', Type::STRING, [ |
|
63 | - 'notnull' => false, |
|
64 | - 'length' => 64, |
|
65 | - ]); |
|
66 | - $table->addColumn('identifier', Type::STRING, [ |
|
67 | - 'notnull' => true, |
|
68 | - 'length' => 64, |
|
69 | - ]); |
|
70 | - $table->addColumn('credentials', Type::TEXT, [ |
|
71 | - 'notnull' => false, |
|
72 | - ]); |
|
73 | - $table->setPrimaryKey(['id']); |
|
74 | - $table->addUniqueIndex(['user', 'identifier'], 'stocred_ui'); |
|
75 | - $table->addIndex(['user'], 'stocred_user'); |
|
76 | - } |
|
55 | + if (!$schema->hasTable('storages_credentials')) { |
|
56 | + $table = $schema->createTable('storages_credentials'); |
|
57 | + $table->addColumn('id', Type::BIGINT, [ |
|
58 | + 'autoincrement' => true, |
|
59 | + 'notnull' => true, |
|
60 | + 'length' => 64, |
|
61 | + ]); |
|
62 | + $table->addColumn('user', Type::STRING, [ |
|
63 | + 'notnull' => false, |
|
64 | + 'length' => 64, |
|
65 | + ]); |
|
66 | + $table->addColumn('identifier', Type::STRING, [ |
|
67 | + 'notnull' => true, |
|
68 | + 'length' => 64, |
|
69 | + ]); |
|
70 | + $table->addColumn('credentials', Type::TEXT, [ |
|
71 | + 'notnull' => false, |
|
72 | + ]); |
|
73 | + $table->setPrimaryKey(['id']); |
|
74 | + $table->addUniqueIndex(['user', 'identifier'], 'stocred_ui'); |
|
75 | + $table->addIndex(['user'], 'stocred_user'); |
|
76 | + } |
|
77 | 77 | |
78 | - return $schema; |
|
79 | - } |
|
78 | + return $schema; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * {@inheritDoc} |
|
83 | - * |
|
84 | - * @since 13.0.0 |
|
85 | - */ |
|
86 | - public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { |
|
87 | - if (!$this->connection->tableExists('credentials')) { |
|
88 | - return; |
|
89 | - } |
|
81 | + /** |
|
82 | + * {@inheritDoc} |
|
83 | + * |
|
84 | + * @since 13.0.0 |
|
85 | + */ |
|
86 | + public function postSchemaChange(IOutput $output, \Closure $schemaClosure, array $options): void { |
|
87 | + if (!$this->connection->tableExists('credentials')) { |
|
88 | + return; |
|
89 | + } |
|
90 | 90 | |
91 | - $query = $this->connection->getQueryBuilder(); |
|
92 | - $query->select('*') |
|
93 | - ->from('credentials'); |
|
91 | + $query = $this->connection->getQueryBuilder(); |
|
92 | + $query->select('*') |
|
93 | + ->from('credentials'); |
|
94 | 94 | |
95 | - $insert = $this->connection->getQueryBuilder(); |
|
96 | - $insert->insert('storages_credentials') |
|
97 | - ->setValue('user', $insert->createParameter('user')) |
|
98 | - ->setValue('identifier', $insert->createParameter('identifier')) |
|
99 | - ->setValue('credentials', $insert->createParameter('credentials')); |
|
95 | + $insert = $this->connection->getQueryBuilder(); |
|
96 | + $insert->insert('storages_credentials') |
|
97 | + ->setValue('user', $insert->createParameter('user')) |
|
98 | + ->setValue('identifier', $insert->createParameter('identifier')) |
|
99 | + ->setValue('credentials', $insert->createParameter('credentials')); |
|
100 | 100 | |
101 | - $result = $query->execute(); |
|
102 | - while ($row = $result->fetch()) { |
|
103 | - $insert->setParameter('user', (string) $row['user']) |
|
104 | - ->setParameter('identifier', (string) $row['identifier']) |
|
105 | - ->setParameter('credentials', (string) $row['credentials']); |
|
106 | - $insert->execute(); |
|
107 | - } |
|
108 | - $result->closeCursor(); |
|
109 | - } |
|
101 | + $result = $query->execute(); |
|
102 | + while ($row = $result->fetch()) { |
|
103 | + $insert->setParameter('user', (string) $row['user']) |
|
104 | + ->setParameter('identifier', (string) $row['identifier']) |
|
105 | + ->setParameter('credentials', (string) $row['credentials']); |
|
106 | + $insert->execute(); |
|
107 | + } |
|
108 | + $result->closeCursor(); |
|
109 | + } |
|
110 | 110 | } |