diff --git a/admin/index.php b/admin/index.php
index 41f817c4..73267e64 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -34,6 +34,7 @@ $hooks->load();
require SYSTEM . 'status.php';
require SYSTEM . 'login.php';
+require SYSTEM . 'migrate.php';
require ADMIN . 'includes/functions.php';
$twig->addGlobal('config', $config);
diff --git a/index.php b/index.php
index ff1801c4..32e8599c 100644
--- a/index.php
+++ b/index.php
@@ -186,26 +186,7 @@ if(!$db->hasTable('myaac_account_actions')) {
throw new RuntimeException('Seems that the table myaac_account_actions of MyAAC doesn\'t exist in the database. This is a fatal error. You can try to reinstall MyAAC by visiting this url.');
}
-// database migrations
-$tmp = '';
-if(fetchDatabaseConfig('database_version', $tmp)) { // we got version
- $tmp = (int)$tmp;
- if($tmp < DATABASE_VERSION) { // import if older
- $db->revalidateCache();
- for($i = $tmp + 1; $i <= DATABASE_VERSION; $i++) {
- require SYSTEM . 'migrations/' . $i . '.php';
- updateDatabaseConfig('database_version', $i);
- }
- }
-}
-else { // register first version
- registerDatabaseConfig('database_version', 0);
- $db->revalidateCache();
- for($i = 1; $i <= DATABASE_VERSION; $i++) {
- require SYSTEM . 'migrations/' . $i . '.php';
- updateDatabaseConfig('database_version', $i);
- }
-}
+require SYSTEM . 'migrate.php';
$hooks->trigger(HOOK_STARTUP);
diff --git a/system/migrate.php b/system/migrate.php
new file mode 100644
index 00000000..46daeef6
--- /dev/null
+++ b/system/migrate.php
@@ -0,0 +1,22 @@
+revalidateCache();
+ for($i = $tmp + 1; $i <= DATABASE_VERSION; $i++) {
+ require SYSTEM . 'migrations/' . $i . '.php';
+ updateDatabaseConfig('database_version', $i);
+ }
+ }
+}
+else { // register first version
+ registerDatabaseConfig('database_version', 0);
+ $db->revalidateCache();
+ for($i = 1; $i <= DATABASE_VERSION; $i++) {
+ require SYSTEM . 'migrations/' . $i . '.php';
+ updateDatabaseConfig('database_version', $i);
+ }
+}
\ No newline at end of file