From 16fbacf07211b2738d9c9eb8fe09f5fec9d8e9f3 Mon Sep 17 00:00:00 2001 From: Joby Elliott Date: Sat, 29 Aug 2020 16:23:51 -0600 Subject: [PATCH] legacy handling save current schema if no schema is saved for an existing table --- src/Drivers/AbstractSQLDriver.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Drivers/AbstractSQLDriver.php b/src/Drivers/AbstractSQLDriver.php index fe9d863..0e20162 100644 --- a/src/Drivers/AbstractSQLDriver.php +++ b/src/Drivers/AbstractSQLDriver.php @@ -154,7 +154,12 @@ abstract class AbstractSQLDriver extends AbstractDriver public function createTable(string $table, array $schema): bool { // 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 $sql = $this->sql_ddl([ 'table' => $table, @@ -163,7 +168,7 @@ abstract class AbstractSQLDriver extends AbstractDriver $out = $this->pdo->exec($sql) !== false; if ($out) { $this->buildIndexes($table, $schema); - if ($saveSchema) { + if (!$tableExists) { $this->saveSchema($table, $schema); } }