From 4c7bde1400820f36caf8b2a5374007384c3018f3 Mon Sep 17 00:00:00 2001 From: winter Date: Mon, 9 Dec 2024 21:31:54 +0000 Subject: rename to Digitigrade / PawPub :3 --- WpfTest/Db/Migrator.php | 52 ------------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 WpfTest/Db/Migrator.php (limited to 'WpfTest/Db/Migrator.php') diff --git a/WpfTest/Db/Migrator.php b/WpfTest/Db/Migrator.php deleted file mode 100644 index ea7f92a..0000000 --- a/WpfTest/Db/Migrator.php +++ /dev/null @@ -1,52 +0,0 @@ -migrations[$newVersion] = $fn; - } - - /** - * Runs all available migrations - * @return void - */ - public function migrate() { - $db = Db::getInstance(); - $currentVersion = null; - try { - $currentVersion = $db->getDbVersion(); - error_log('starting on version ' . $currentVersion); - } catch (\PDOException $e) { - if ($e->getCode() == '42P01') { // undefined table - error_log("initialising database because db version table doesn't exist"); - $db->runInitialSchema(); - $currentVersion = $db->getDbVersion(); - error_log('starting on version ' . $currentVersion); - } else - throw $e; - } - - // find migrations that haven't been run yet - $available = array_filter($this->migrations, function (int $key) use ($currentVersion) { - return $key > $currentVersion; - }, ARRAY_FILTER_USE_KEY); - - try { - // run them in order (at least they should be in order?) - foreach (array_keys($available) as $version) { - $fn = $available[$version]; - $filename = basename((new \ReflectionFunction($fn))->getFileName()); - error_log("running migration $filename"); - $available[$version]($db->getPdo()); - $db->setDbVersion($version); - } - } finally { - error_log('now on version ' . $db->getDbVersion()); - } - } -} \ No newline at end of file -- cgit v1.3