Skip to content

Commit

Permalink
Merge pull request #65 from MarkusKepert/master
Browse files Browse the repository at this point in the history
fix temp table creation issue and the root cause
  • Loading branch information
orzuionut authored Jun 15, 2021
2 parents ab45740 + cb44a50 commit fbadc52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion w2g2/lib/Migration/PostMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected function getLock($lock)
*/
protected function dropTempTable()
{
$dropStatement = "DROP TABLE " . $this->tempTableName;
$dropStatement = "DROP TABLE IF EXISTS " . $this->tempTableName;

$this->db->executeQuery($dropStatement);
}
Expand Down
16 changes: 13 additions & 3 deletions w2g2/lib/Migration/PreMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,19 @@ protected function isOldVersion()
*/
protected function createTempTable()
{
/**
* cleanup temp table (issue #68)
*/
$cleanupStatement = "DROP TABLE IF EXISTS " . $this->tempTableName;
$this->db->executeQuery($cleanupStatement);

/**
* create temp table
*/

$createStatement = "CREATE TABLE " .
$this->tempTableName .
" (name varchar(255) PRIMARY KEY, created TIMESTAMP DEFAULT null, locked_by varchar(255))";
" (name varchar(255) PRIMARY KEY, locked_by varchar(255), created TIMESTAMP null DEFAULT null)";

$this->db->executeQuery($createStatement);
}
Expand All @@ -79,8 +89,8 @@ protected function createTempTable()
*/
protected function insertDataInTempTable()
{
$insertStatement = "INSERT INTO " . $this->tempTableName .
" SELECT * FROM " . $this->tableName;
$insertStatement = "INSERT INTO " . $this->tempTableName . " (name, locked_by, created)" .
" SELECT file_id, locked_by, created FROM " . $this->tableName;

$this->db->executeQuery($insertStatement);
}
Expand Down

0 comments on commit fbadc52

Please sign in to comment.