|
@@ -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
|
} |
|
@@ -559,31 +559,31 @@ discard block |
|
|
block discarded – undo |
|
559
|
559
|
$sourceTable = $sourceSchema->getTable($table->getName()); |
|
560
|
560
|
} catch (SchemaException $e) { |
|
561
|
561
|
if (\strlen($table->getName()) - $prefixLength > 27) { |
|
562
|
|
- throw new \InvalidArgumentException('Table name "' . $table->getName() . '" is too long.'); |
|
|
562
|
+ throw new \InvalidArgumentException('Table name "'.$table->getName().'" is too long.'); |
|
563
|
563
|
} |
|
564
|
564
|
$sourceTable = null; |
|
565
|
565
|
} |
|
566
|
566
|
|
|
567
|
567
|
foreach ($table->getColumns() as $thing) { |
|
568
|
568
|
if ((!$sourceTable instanceof Table || !$sourceTable->hasColumn($thing->getName())) && \strlen($thing->getName()) > 30) { |
|
569
|
|
- throw new \InvalidArgumentException('Column name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.'); |
|
|
569
|
+ throw new \InvalidArgumentException('Column name "'.$table->getName().'"."'.$thing->getName().'" is too long.'); |
|
570
|
570
|
} |
|
571
|
571
|
|
|
572
|
572
|
if ($thing->getNotnull() && $thing->getDefault() === '' |
|
573
|
573
|
&& $sourceTable instanceof Table && !$sourceTable->hasColumn($thing->getName())) { |
|
574
|
|
- throw new \InvalidArgumentException('Column name "' . $table->getName() . '"."' . $thing->getName() . '" is NotNull, but has empty string or null as default.'); |
|
|
574
|
+ throw new \InvalidArgumentException('Column name "'.$table->getName().'"."'.$thing->getName().'" is NotNull, but has empty string or null as default.'); |
|
575
|
575
|
} |
|
576
|
576
|
} |
|
577
|
577
|
|
|
578
|
578
|
foreach ($table->getIndexes() as $thing) { |
|
579
|
579
|
if ((!$sourceTable instanceof Table || !$sourceTable->hasIndex($thing->getName())) && \strlen($thing->getName()) > 30) { |
|
580
|
|
- throw new \InvalidArgumentException('Index name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.'); |
|
|
580
|
+ throw new \InvalidArgumentException('Index name "'.$table->getName().'"."'.$thing->getName().'" is too long.'); |
|
581
|
581
|
} |
|
582
|
582
|
} |
|
583
|
583
|
|
|
584
|
584
|
foreach ($table->getForeignKeys() as $thing) { |
|
585
|
585
|
if ((!$sourceTable instanceof Table || !$sourceTable->hasForeignKey($thing->getName())) && \strlen($thing->getName()) > 30) { |
|
586
|
|
- throw new \InvalidArgumentException('Foreign key name "' . $table->getName() . '"."' . $thing->getName() . '" is too long.'); |
|
|
586
|
+ throw new \InvalidArgumentException('Foreign key name "'.$table->getName().'"."'.$thing->getName().'" is too long.'); |
|
587
|
587
|
} |
|
588
|
588
|
} |
|
589
|
589
|
|
|
@@ -593,32 +593,32 @@ discard block |
|
|
block discarded – undo |
|
593
|
593
|
$isUsingDefaultName = $indexName === 'primary'; |
|
594
|
594
|
|
|
595
|
595
|
if ($this->connection->getDatabasePlatform() instanceof PostgreSQL94Platform) { |
|
596
|
|
- $defaultName = $table->getName() . '_pkey'; |
|
|
596
|
+ $defaultName = $table->getName().'_pkey'; |
|
597
|
597
|
$isUsingDefaultName = strtolower($defaultName) === $indexName; |
|
598
|
598
|
|
|
599
|
599
|
if ($isUsingDefaultName) { |
|
600
|
|
- $sequenceName = $table->getName() . '_' . implode('_', $primaryKey->getColumns()) . '_seq'; |
|
601
|
|
- $sequences = array_filter($sequences, function (Sequence $sequence) use ($sequenceName) { |
|
|
600
|
+ $sequenceName = $table->getName().'_'.implode('_', $primaryKey->getColumns()).'_seq'; |
|
|
601
|
+ $sequences = array_filter($sequences, function(Sequence $sequence) use ($sequenceName) { |
|
602
|
602
|
return $sequence->getName() !== $sequenceName; |
|
603
|
603
|
}); |
|
604
|
604
|
} |
|
605
|
605
|
} elseif ($this->connection->getDatabasePlatform() instanceof OraclePlatform) { |
|
606
|
|
- $defaultName = $table->getName() . '_seq'; |
|
|
606
|
+ $defaultName = $table->getName().'_seq'; |
|
607
|
607
|
$isUsingDefaultName = strtolower($defaultName) === $indexName; |
|
608
|
608
|
} |
|
609
|
609
|
|
|
610
|
610
|
if (!$isUsingDefaultName && \strlen($indexName) > 30) { |
|
611
|
|
- throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.'); |
|
|
611
|
+ throw new \InvalidArgumentException('Primary index name on "'.$table->getName().'" is too long.'); |
|
612
|
612
|
} |
|
613
|
613
|
if ($isUsingDefaultName && \strlen($table->getName()) - $prefixLength >= 23) { |
|
614
|
|
- throw new \InvalidArgumentException('Primary index name on "' . $table->getName() . '" is too long.'); |
|
|
614
|
+ throw new \InvalidArgumentException('Primary index name on "'.$table->getName().'" is too long.'); |
|
615
|
615
|
} |
|
616
|
616
|
} |
|
617
|
617
|
} |
|
618
|
618
|
|
|
619
|
619
|
foreach ($sequences as $sequence) { |
|
620
|
620
|
if (!$sourceSchema->hasSequence($sequence->getName()) && \strlen($sequence->getName()) > 30) { |
|
621
|
|
- throw new \InvalidArgumentException('Sequence name "' . $sequence->getName() . '" is too long.'); |
|
|
621
|
+ throw new \InvalidArgumentException('Sequence name "'.$sequence->getName().'" is too long.'); |
|
622
|
622
|
} |
|
623
|
623
|
} |
|
624
|
624
|
} |