From d69d7e82b8bbb567668c935ace848c7dcf750b08 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Thu, 24 Jun 2021 21:09:24 +0200 Subject: 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. --- core/namespace/Application.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'core/namespace/Application.php') 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 = []; #=============================================================================== @@ -80,6 +81,19 @@ class Application { return self::$Language; } + #=============================================================================== + # 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 #=============================================================================== -- cgit v1.2.3