Skip to content

Commit

Permalink
FIX: should drop sqlite3 table first when try to upgrade codes
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperjiang committed Dec 12, 2019
1 parent 4b49c92 commit b323827
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/DivisionCode/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ public function upgrade()
file_put_contents($this->getCodesFile(), $content);

if ($this->supportSQLite()) {
$this->db->exec('CREATE TABLE IF NOT EXISTS division_codes (code TEXT PRIMARY KEY, name TEXT)');
$this->db->exec('DROP TABLE IF EXISTS division_codes');
$this->db->exec('CREATE TABLE division_codes (code TEXT PRIMARY KEY, name TEXT)');
foreach ($codes as $k => $v) {
$this->db->exec("REPLACE INTO `division_codes` (`code`, `name`) VALUES ('$k', '$v')");
$this->db->exec("INSERT INTO `division_codes` (`code`, `name`) VALUES ('$k', '$v')");
}
}

Expand Down
Binary file modified src/DivisionCode/codes.db
Binary file not shown.

0 comments on commit b323827

Please sign in to comment.