Skip to content

Commit a59bc6a

Browse files
author
Valentin V / vvval
committed
Revert redundant updates
1 parent 5d9d061 commit a59bc6a

File tree

3 files changed

+86
-86
lines changed

3 files changed

+86
-86
lines changed

src/Atomizer/Renderer.php

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -119,90 +119,6 @@ public function dropTable(Source $source, AbstractTable $table): void
119119
);
120120
}
121121

122-
/**
123-
* @param Source $source
124-
* @param AbstractColumn $column
125-
* @param AbstractColumn $original
126-
*/
127-
protected function alterColumn(
128-
Source $source,
129-
AbstractColumn $column,
130-
AbstractColumn $original
131-
): void {
132-
if ($column->getName() !== $original->getName()) {
133-
$name = $original->getName();
134-
} else {
135-
$name = $column->getName();
136-
}
137-
138-
$this->render(
139-
$source,
140-
' ->alterColumn(%s, %s, %s)',
141-
$name,
142-
$column->getDeclaredType() ?? $column->getAbstractType(),
143-
$column
144-
);
145-
146-
if ($column->getName() !== $original->getName()) {
147-
$this->render(
148-
$source,
149-
' ->renameColumn(%s, %s)',
150-
$name,
151-
$column->getName()
152-
);
153-
}
154-
}
155-
156-
/**
157-
* Render values and options into source.
158-
*
159-
* @param Source $source
160-
* @param string $format
161-
* @param array ...$values
162-
*/
163-
protected function render(Source $source, string $format, ...$values): void
164-
{
165-
$serializer = $this->getSerializer();
166-
167-
$rendered = [];
168-
foreach ($values as $value) {
169-
if ($value instanceof AbstractTable) {
170-
$rendered[] = $serializer->serialize(
171-
substr($value->getName(), strlen($value->getPrefix()))
172-
);
173-
continue;
174-
}
175-
176-
if ($value instanceof AbstractColumn) {
177-
$rendered[] = $this->columnOptions($serializer, $value);
178-
continue;
179-
}
180-
181-
if ($value instanceof AbstractIndex) {
182-
$rendered[] = $this->indexOptions($serializer, $value);
183-
continue;
184-
}
185-
186-
if ($value instanceof AbstractForeignKey) {
187-
$rendered[] = $this->foreignKeyOptions($serializer, $value);
188-
continue;
189-
}
190-
191-
// numeric array
192-
if (is_array($value) && count($value) > 0 && is_numeric(array_keys($value)[0])) {
193-
$rendered[] = '["' . implode('", "', $value) . '"]';
194-
continue;
195-
}
196-
197-
$rendered[] = $serializer->serialize($value);
198-
}
199-
200-
$lines = sprintf($format, ...$rendered);
201-
foreach (explode("\n", $lines) as $line) {
202-
$source->addLine($line);
203-
}
204-
}
205-
206122
/**
207123
* @param Source $source
208124
* @param Comparator $comparator
@@ -415,6 +331,90 @@ private function revertForeignKeys(Source $source, Comparator $comparator, strin
415331
}
416332
}
417333

334+
/**
335+
* @param Source $source
336+
* @param AbstractColumn $column
337+
* @param AbstractColumn $original
338+
*/
339+
protected function alterColumn(
340+
Source $source,
341+
AbstractColumn $column,
342+
AbstractColumn $original
343+
): void {
344+
if ($column->getName() !== $original->getName()) {
345+
$name = $original->getName();
346+
} else {
347+
$name = $column->getName();
348+
}
349+
350+
$this->render(
351+
$source,
352+
' ->alterColumn(%s, %s, %s)',
353+
$name,
354+
$column->getDeclaredType() ?? $column->getAbstractType(),
355+
$column
356+
);
357+
358+
if ($column->getName() !== $original->getName()) {
359+
$this->render(
360+
$source,
361+
' ->renameColumn(%s, %s)',
362+
$name,
363+
$column->getName()
364+
);
365+
}
366+
}
367+
368+
/**
369+
* Render values and options into source.
370+
*
371+
* @param Source $source
372+
* @param string $format
373+
* @param array ...$values
374+
*/
375+
protected function render(Source $source, string $format, ...$values): void
376+
{
377+
$serializer = $this->getSerializer();
378+
379+
$rendered = [];
380+
foreach ($values as $value) {
381+
if ($value instanceof AbstractTable) {
382+
$rendered[] = $serializer->serialize(
383+
substr($value->getName(), strlen($value->getPrefix()))
384+
);
385+
continue;
386+
}
387+
388+
if ($value instanceof AbstractColumn) {
389+
$rendered[] = $this->columnOptions($serializer, $value);
390+
continue;
391+
}
392+
393+
if ($value instanceof AbstractIndex) {
394+
$rendered[] = $this->indexOptions($serializer, $value);
395+
continue;
396+
}
397+
398+
if ($value instanceof AbstractForeignKey) {
399+
$rendered[] = $this->foreignKeyOptions($serializer, $value);
400+
continue;
401+
}
402+
403+
// numeric array
404+
if (is_array($value) && count($value) > 0 && is_numeric(array_keys($value)[0])) {
405+
$rendered[] = '["' . implode('", "', $value) . '"]';
406+
continue;
407+
}
408+
409+
$rendered[] = $serializer->serialize($value);
410+
}
411+
412+
$lines = sprintf($format, ...$rendered);
413+
foreach (explode("\n", $lines) as $line) {
414+
$source->addLine($line);
415+
}
416+
}
417+
418418
/**
419419
* @param Serializer $serializer
420420
* @param AbstractColumn $column

tests/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ services:
2828
environment:
2929
POSTGRES_DB: "spiral"
3030
POSTGRES_USER: "postgres"
31-
POSTGRES_PASSWORD: "postgres"
31+
POSTGRES_PASSWORD: "postgres"

tests/install-sqlsrv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
44
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
55
sudo apt-get update
66

7-
sudo ACCEPT_EULA=Y apt-get install -qy msodbcsql17 mssql-tools
7+
sudo ACCEPT_EULA=Y apt-get install -qy msodbcsql17 mssql-tools

0 commit comments

Comments
 (0)