aboutsummaryrefslogtreecommitdiffstats
path: root/core/namespace/Application.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-06-24 21:09:24 +0200
committerThomas Lange <code@nerdmind.de>2021-06-24 21:09:24 +0200
commitd69d7e82b8bbb567668c935ace848c7dcf750b08 (patch)
treedfad6bc5ce73262e958c92a3c3875c619c28ffc8 /core/namespace/Application.php
parent55ae320e7cfd710f3ea0f295c880619217db2220 (diff)
downloadblog-d69d7e82b8bbb567668c935ace848c7dcf750b08.tar.gz
blog-d69d7e82b8bbb567668c935ace848c7dcf750b08.tar.xz
blog-d69d7e82b8bbb567668c935ace848c7dcf750b08.zip
Implement database schema Migrator
This commit implements the new database schema Migrator which keeps track of the on-disk schema and the schema used by the codebase. It tries to makes future database schema upgrades user-friendlier.
Diffstat (limited to 'core/namespace/Application.php')
-rw-r--r--core/namespace/Application.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/core/namespace/Application.php b/core/namespace/Application.php
index 3cecf3b..829f758 100644
--- a/core/namespace/Application.php
+++ b/core/namespace/Application.php
@@ -6,6 +6,7 @@ class Application {
#===============================================================================
private static $Database;
private static $Language;
+ private static $Migrator;
private static $repositories = [];
#===============================================================================
@@ -81,6 +82,19 @@ class Application {
}
#===============================================================================
+ # Return singleton Migrator instance
+ #===============================================================================
+ public static function getMigrator(): Migrator {
+ if(!self::$Migrator instanceof Migrator) {
+ $Migrator = new Migrator(self::getDatabase());
+ $Migrator->setMigrationsDir(ROOT.'core/db/migrations/');
+ self::$Migrator = $Migrator;
+ }
+
+ return self::$Migrator;
+ }
+
+ #===============================================================================
# Return singleton repository instance
#===============================================================================
public static function getRepository(string $namespace): Repository {