|
@@ -78,7 +78,7 @@ discard block |
|
|
block discarded – undo |
|
78
|
78
|
} |
|
79
|
79
|
|
|
80
|
80
|
if ($appName === 'core') { |
|
81
|
|
- $this->migrationsPath = \OC::$SERVERROOT . '/core/Migrations'; |
|
|
81
|
+ $this->migrationsPath = \OC::$SERVERROOT.'/core/Migrations'; |
|
82
|
82
|
$this->migrationsNamespace = 'OC\\Core\\Migrations'; |
|
83
|
83
|
$this->checkOracle = true; |
|
84
|
84
|
} else { |
|
@@ -88,10 +88,10 @@ discard block |
|
|
block discarded – undo |
|
88
|
88
|
$appPath = $appLocator->getAppPath($appName); |
|
89
|
89
|
$namespace = App::buildAppNamespace($appName); |
|
90
|
90
|
$this->migrationsPath = "$appPath/lib/Migration"; |
|
91
|
|
- $this->migrationsNamespace = $namespace . '\\Migration'; |
|
|
91
|
+ $this->migrationsNamespace = $namespace.'\\Migration'; |
|
92
|
92
|
|
|
93
|
93
|
$infoParser = new InfoParser(); |
|
94
|
|
- $info = $infoParser->parse($appPath . '/appinfo/info.xml'); |
|
|
94
|
+ $info = $infoParser->parse($appPath.'/appinfo/info.xml'); |
|
95
|
95
|
if (!isset($info['dependencies']['database'])) { |
|
96
|
96
|
$this->checkOracle = true; |
|
97
|
97
|
} else { |
|
@@ -229,7 +229,7 @@ discard block |
|
|
block discarded – undo |
|
229
|
229
|
\RegexIterator::GET_MATCH); |
|
230
|
230
|
|
|
231
|
231
|
$files = array_keys(iterator_to_array($iterator)); |
|
232
|
|
- uasort($files, function ($a, $b) { |
|
|
232
|
+ uasort($files, function($a, $b) { |
|
233
|
233
|
preg_match('/^Version(\d+)Date(\d+)\\.php$/', basename($a), $matchA); |
|
234
|
234
|
preg_match('/^Version(\d+)Date(\d+)\\.php$/', basename($b), $matchB); |
|
235
|
235
|
if (!empty($matchA) && !empty($matchB)) { |
|
@@ -307,7 +307,7 @@ discard block |
|
|
block discarded – undo |
|
307
|
307
|
* @return string |
|
308
|
308
|
*/ |
|
309
|
309
|
public function getMigrationsTableName() { |
|
310
|
|
- return $this->connection->getPrefix() . 'migrations'; |
|
|
310
|
+ return $this->connection->getPrefix().'migrations'; |
|
311
|
311
|
} |
|
312
|
312
|
|
|
313
|
313
|
/** |
|
@@ -427,7 +427,7 @@ discard block |
|
|
block discarded – undo |
|
427
|
427
|
} catch (DriverException $e) { |
|
428
|
428
|
// The exception itself does not contain the name of the migration, |
|
429
|
429
|
// so we wrap it here, to make debugging easier. |
|
430
|
|
- throw new \Exception('Database error when running migration ' . $to . ' for app ' . $this->getApp(), 0, $e); |
|
|
430
|
+ throw new \Exception('Database error when running migration '.$to.' for app '.$this->getApp(), 0, $e); |
|
431
|
431
|
} |
|
432
|
432
|
} |
|
433
|
433
|
} |
|
@@ -450,7 +450,7 @@ discard block |
|
|
block discarded – undo |
|
450
|
450
|
foreach ($toBeExecuted as $version) { |
|
451
|
451
|
$instance = $this->createInstance($version); |
|
452
|
452
|
|
|
453
|
|
- $toSchema = $instance->changeSchema($this->output, function () use ($toSchema) { |
|
|
453
|
+ $toSchema = $instance->changeSchema($this->output, function() use ($toSchema) { |
|
454
|
454
|
return $toSchema ?: new SchemaWrapper($this->connection); |
|
455
|
455
|
}, ['tablePrefix' => $this->connection->getPrefix()]) ?: $toSchema; |
|
456
|
456
|
} |
|
@@ -523,12 +523,12 @@ discard block |
|
|
block discarded – undo |
|
523
|
523
|
$instance = $this->createInstance($version); |
|
524
|
524
|
|
|
525
|
525
|
if (!$schemaOnly) { |
|
526
|
|
- $instance->preSchemaChange($this->output, function () { |
|
|
526
|
+ $instance->preSchemaChange($this->output, function() { |
|
527
|
527
|
return new SchemaWrapper($this->connection); |
|
528
|
528
|
}, ['tablePrefix' => $this->connection->getPrefix()]); |
|
529
|
529
|
} |
|
530
|
530
|
|
|
531
|
|
- $toSchema = $instance->changeSchema($this->output, function () { |
|
|
531
|
+ $toSchema = $instance->changeSchema($this->output, function() { |
|
532
|
532
|
return new SchemaWrapper($this->connection); |
|
533
|
533
|
}, ['tablePrefix' => $this->connection->getPrefix()]); |
|
534
|
534
|
|
|
@@ -543,7 +543,7 @@ discard block |
|
|
block discarded – undo |
|
543
|
543
|
} |
|
544
|
544
|
|
|
545
|
545
|
if (!$schemaOnly) { |
|
546
|
|
- $instance->postSchemaChange($this->output, function () { |
|
|
546
|
+ $instance->postSchemaChange($this->output, function() { |
|
547
|
547
|
return new SchemaWrapper($this->connection); |
|
548
|
548
|
}, ['tablePrefix' => $this->connection->getPrefix()]); |
|
549
|
549
|
} |
|
@@ -577,35 +577,35 @@ discard block |
|
|
block discarded – undo |
|
577
|
577
|
$sourceTable = $sourceSchema->getTable($table->getName()); |
|
578
|
578
|
} catch (SchemaException $e) { |
|
579
|
579
|
if (\strlen($table->getName()) - $prefixLength > 27) { |
|
580
|
|
- throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.'); |
|
|
580
|
+ throw new \InvalidArgumentException('Table name "'.$table->getName().'" is too long.'); |
|
581
|
581
|
} |
|
582
|
582
|
$sourceTable = null; |
|
583
|
583
|
} |
|
584
|
584
|
|
|
585
|
585
|
foreach ($table->getColumns() as $thing) { |
|
586
|
586
|
if ((!$sourceTable instanceof Table || !$sourceTable->hasColumn($thing->getName())) && \strlen($thing->getName()) > 30) { |
|
587
|
|
- throw new \InvalidArgumentException('Column name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.'); |
|
|
587
|
+ throw new \InvalidArgumentException('Column name "'.$table->getName().'"."'.$thing->getName().'" is too long.'); |
|
588
|
588
|
} |
|
589
|
589
|
|
|
590
|
590
|
if ((!$sourceTable instanceof Table || !$sourceTable->hasColumn($thing->getName())) && $thing->getNotnull() && $thing->getDefault() === '' |
|
591
|
591
|
&& $sourceTable instanceof Table && !$sourceTable->hasColumn($thing->getName())) { |
|
592
|
|
- throw new \InvalidArgumentException('Column "' . $table->getName() . '"."' . $thing->getName() . '" is NotNull, but has empty string or null as default.'); |
|
|
592
|
+ throw new \InvalidArgumentException('Column "'.$table->getName().'"."'.$thing->getName().'" is NotNull, but has empty string or null as default.'); |
|
593
|
593
|
} |
|
594
|
594
|
|
|
595
|
595
|
if ((!$sourceTable instanceof Table || !$sourceTable->hasColumn($thing->getName())) && $thing->getNotnull() && $thing->getType()->getName() === Types::BOOLEAN) { |
|
596
|
|
- throw new \InvalidArgumentException('Column "' . $table->getName() . '"."' . $thing->getName() . '" is type Bool and also NotNull, so it can not store "false".'); |
|
|
596
|
+ throw new \InvalidArgumentException('Column "'.$table->getName().'"."'.$thing->getName().'" is type Bool and also NotNull, so it can not store "false".'); |
|
597
|
597
|
} |
|
598
|
598
|
} |
|
599
|
599
|
|
|
600
|
600
|
foreach ($table->getIndexes() as $thing) { |
|
601
|
601
|
if ((!$sourceTable instanceof Table || !$sourceTable->hasIndex($thing->getName())) && \strlen($thing->getName()) > 30) { |
|
602
|
|
- throw new \InvalidArgumentException('Index name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.'); |
|
|
602
|
+ throw new \InvalidArgumentException('Index name "'.$table->getName().'"."'.$thing->getName().'" is too long.'); |
|
603
|
603
|
} |
|
604
|
604
|
} |
|
605
|
605
|
|
|
606
|
606
|
foreach ($table->getForeignKeys() as $thing) { |
|
607
|
607
|
if ((!$sourceTable instanceof Table || !$sourceTable->hasForeignKey($thing->getName())) && \strlen($thing->getName()) > 30) { |
|
608
|
|
- throw new \InvalidArgumentException('Foreign key name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.'); |
|
|
608
|
+ throw new \InvalidArgumentException('Foreign key name "'.$table->getName().'"."'.$thing->getName().'" is too long.'); |
|
609
|
609
|
} |
|
610
|
610
|
} |
|
611
|
611
|
|
|
@@ -615,32 +615,32 @@ discard block |
|
|
block discarded – undo |
|
615
|
615
|
$isUsingDefaultName = $indexName === 'primary'; |
|
616
|
616
|
|
|
617
|
617
|
if ($this->connection->getDatabasePlatform() instanceof PostgreSQL94Platform) { |
|
618
|
|
- $defaultName = $table->getName() . '_pkey'; |
|
|
618
|
+ $defaultName = $table->getName().'_pkey'; |
|
619
|
619
|
$isUsingDefaultName = strtolower($defaultName) === $indexName; |
|
620
|
620
|
|
|
621
|
621
|
if ($isUsingDefaultName) { |
|
622
|
|
- $sequenceName = $table->getName() . '_' . implode('_', $primaryKey->getColumns()) . '_seq'; |
|
623
|
|
- $sequences = array_filter($sequences, function (Sequence $sequence) use ($sequenceName) { |
|
|
622
|
+ $sequenceName = $table->getName().'_'.implode('_', $primaryKey->getColumns()).'_seq'; |
|
|
623
|
+ $sequences = array_filter($sequences, function(Sequence $sequence) use ($sequenceName) { |
|
624
|
624
|
return $sequence->getName() !== $sequenceName; |
|
625
|
625
|
}); |
|
626
|
626
|
} |
|
627
|
627
|
} elseif ($this->connection->getDatabasePlatform() instanceof OraclePlatform) { |
|
628
|
|
- $defaultName = $table->getName() . '_seq'; |
|
|
628
|
+ $defaultName = $table->getName().'_seq'; |
|
629
|
629
|
$isUsingDefaultName = strtolower($defaultName) === $indexName; |
|
630
|
630
|
} |
|
631
|
631
|
|
|
632
|
632
|
if (!$isUsingDefaultName && \strlen($indexName) > 30) { |
|
633
|
|
- throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.'); |
|
|
633
|
+ throw new \InvalidArgumentException('Primary index name on "'.$table->getName().'" is too long.'); |
|
634
|
634
|
} |
|
635
|
635
|
if ($isUsingDefaultName && \strlen($table->getName()) - $prefixLength >= 23) { |
|
636
|
|
- throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.'); |
|
|
636
|
+ throw new \InvalidArgumentException('Primary index name on "'.$table->getName().'" is too long.'); |
|
637
|
637
|
} |
|
638
|
638
|
} |
|
639
|
639
|
} |
|
640
|
640
|
|
|
641
|
641
|
foreach ($sequences as $sequence) { |
|
642
|
642
|
if (!$sourceSchema->hasSequence($sequence->getName()) && \strlen($sequence->getName()) > 30) { |
|
643
|
|
- throw new \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" is too long.'); |
|
|
643
|
+ throw new \InvalidArgumentException('Sequence name "'.$sequence->getName().'" is too long.'); |
|
644
|
644
|
} |
|
645
|
645
|
} |
|
646
|
646
|
} |