mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #7704 from open-sausages/pulls/4.0/before-class-migration
BUG Do database migrations before default records
This commit is contained in:
commit
7e4ff1fb90
@ -318,22 +318,6 @@ class DatabaseAdmin extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($dataClasses as $dataClass) {
|
|
||||||
// Check if class exists before trying to instantiate - this sidesteps any manifest weirdness
|
|
||||||
// Test_ indicates that it's the data class is part of testing system
|
|
||||||
if (strpos($dataClass, 'Test_') === false && class_exists($dataClass)) {
|
|
||||||
if (!$quiet) {
|
|
||||||
if (Director::is_cli()) {
|
|
||||||
echo " * $dataClass\n";
|
|
||||||
} else {
|
|
||||||
echo "<li>$dataClass</li>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
singleton($dataClass)->requireDefaultRecords();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remap obsolete class names
|
// Remap obsolete class names
|
||||||
$schema = DataObject::getSchema();
|
$schema = DataObject::getSchema();
|
||||||
foreach ($this->config()->classname_value_remapping as $oldClassName => $newClassName) {
|
foreach ($this->config()->classname_value_remapping as $oldClassName => $newClassName) {
|
||||||
@ -353,7 +337,7 @@ class DatabaseAdmin extends Controller
|
|||||||
$updateQueries = [sprintf($updateQuery, '')];
|
$updateQueries = [sprintf($updateQuery, '')];
|
||||||
|
|
||||||
// Remap versioned table ClassName values as well
|
// Remap versioned table ClassName values as well
|
||||||
$class = singleton($newClassName);
|
$class = DataObject::singleton($newClassName);
|
||||||
if ($class->has_extension(Versioned::class)) {
|
if ($class->has_extension(Versioned::class)) {
|
||||||
if ($class->hasStages()) {
|
if ($class->hasStages()) {
|
||||||
$updateQueries[] = sprintf($updateQuery, '_Live');
|
$updateQueries[] = sprintf($updateQuery, '_Live');
|
||||||
@ -367,6 +351,23 @@ class DatabaseAdmin extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Require all default records
|
||||||
|
foreach ($dataClasses as $dataClass) {
|
||||||
|
// Check if class exists before trying to instantiate - this sidesteps any manifest weirdness
|
||||||
|
// Test_ indicates that it's the data class is part of testing system
|
||||||
|
if (strpos($dataClass, 'Test_') === false && class_exists($dataClass)) {
|
||||||
|
if (!$quiet) {
|
||||||
|
if (Director::is_cli()) {
|
||||||
|
echo " * $dataClass\n";
|
||||||
|
} else {
|
||||||
|
echo "<li>$dataClass</li>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DataObject::singleton($dataClass)->requireDefaultRecords();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$quiet && !Director::is_cli()) {
|
if (!$quiet && !Director::is_cli()) {
|
||||||
echo "</ul>";
|
echo "</ul>";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user