Reduce the number of schemas we generate when we just run all migrations anyway
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
7f45f90789
commit
dde0e73c6b
|
@ -408,6 +408,11 @@ class MigrationService {
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function migrate($to = 'latest', $schemaOnly = false) {
|
public function migrate($to = 'latest', $schemaOnly = false) {
|
||||||
|
if ($schemaOnly) {
|
||||||
|
$this->migrateSchemaOnly($to);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// read known migrations
|
// read known migrations
|
||||||
$toBeExecuted = $this->getMigrationsToExecute($to);
|
$toBeExecuted = $this->getMigrationsToExecute($to);
|
||||||
foreach ($toBeExecuted as $version) {
|
foreach ($toBeExecuted as $version) {
|
||||||
|
@ -415,6 +420,42 @@ class MigrationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies all not yet applied versions up to $to
|
||||||
|
*
|
||||||
|
* @param string $to
|
||||||
|
* @throws \InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function migrateSchemaOnly($to = 'latest') {
|
||||||
|
// read known migrations
|
||||||
|
$toBeExecuted = $this->getMigrationsToExecute($to);
|
||||||
|
|
||||||
|
if (empty($toBeExecuted)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$toSchema = null;
|
||||||
|
foreach ($toBeExecuted as $version) {
|
||||||
|
$instance = $this->createInstance($version);
|
||||||
|
|
||||||
|
$toSchema = $instance->changeSchema($this->output, function () use ($toSchema) {
|
||||||
|
return $toSchema ?: new SchemaWrapper($this->connection);
|
||||||
|
}, ['tablePrefix' => $this->connection->getPrefix()]) ?: $toSchema;
|
||||||
|
|
||||||
|
$this->markAsExecuted($version);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($toSchema instanceof SchemaWrapper) {
|
||||||
|
$targetSchema = $toSchema->getWrappedSchema();
|
||||||
|
if ($this->checkOracle) {
|
||||||
|
$beforeSchema = $this->connection->createSchema();
|
||||||
|
$this->ensureOracleIdentifierLengthLimit($beforeSchema, $targetSchema, strlen($this->connection->getPrefix()));
|
||||||
|
}
|
||||||
|
$this->connection->migrateToSchema($targetSchema);
|
||||||
|
$toSchema->performDropTableCalls();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the human readable descriptions for the migration steps to run
|
* Get the human readable descriptions for the migration steps to run
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue