legacy handling

save current schema if no schema is saved for an existing table
This commit is contained in:
Joby Elliott 2020-08-29 16:23:51 -06:00 committed by GitHub
parent 110c11dbb2
commit 16fbacf072
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -154,7 +154,12 @@ abstract class AbstractSQLDriver extends AbstractDriver
public function createTable(string $table, array $schema): bool public function createTable(string $table, array $schema): bool
{ {
// check if table exists, if it doesn't, save into schema table // check if table exists, if it doesn't, save into schema table
$saveSchema = !$this->tableExists($table); $tableExists = $this->tableExists($table);
// if table exists, but no schema does, assume table matches schema and save schema
if ($tableExists && !$this->getSchema($table)) {
$this->saveSchema($table,$schema);
return true;
}
// create table from scratch // create table from scratch
$sql = $this->sql_ddl([ $sql = $this->sql_ddl([
'table' => $table, 'table' => $table,
@ -163,7 +168,7 @@ abstract class AbstractSQLDriver extends AbstractDriver
$out = $this->pdo->exec($sql) !== false; $out = $this->pdo->exec($sql) !== false;
if ($out) { if ($out) {
$this->buildIndexes($table, $schema); $this->buildIndexes($table, $schema);
if ($saveSchema) { if (!$tableExists) {
$this->saveSchema($table, $schema); $this->saveSchema($table, $schema);
} }
} }