diff --git a/database_updates.php b/database_updates.php new file mode 100644 index 00000000..28949d9a --- /dev/null +++ b/database_updates.php @@ -0,0 +1,48 @@ + CURRENT_DATABASE_VERSION){ + + // We need updates! + + + if(CURRENT_DATABASE_VERSION == '0.0.1'){ + // Insert queries here required to update to DB version 0.0.2 + // mysqli_query($mysqli, "ALTER TABLE ....."); + + + // Then, update the database to the next sequential version + //mysqli_query($mysqli, "UPDATE settings SET config_current_database_version = '0.0.2' WHERE company_id = '1'"); + + } + + + if(CURRENT_DATABASE_VERSION == '0.0.2'){ + // Insert queries here required to update to DB version 0.0.3 + // mysqli_query($mysqli, "ALTER TABLE ....."); + + + // Then, update the database to the next sequential version + //mysqli_query($mysqli, "UPDATE settings SET config_current_database_version = '0.0.3' WHERE company_id = '1'"); + + } + + // etc + +} +else{ + // Up-to-date +} \ No newline at end of file diff --git a/database_version.php b/database_version.php new file mode 100644 index 00000000..290242b2 --- /dev/null +++ b/database_version.php @@ -0,0 +1,8 @@ + + %h%ar%s'"); ?> -
+
-

Update

+

Update

-
- -
Update App
- -
Update Database
-

Latest version

- - -
- - - - - - - - - - - - - -
CommitWhenDescription
- + + +
Update App
+ CURRENT_DATABASE_VERSION){ ?> +
Update Database
+
+ Current DB Version: +
+ Latest DB Version: + +

Latest version!

+ Current DB Version: + + $tmp_path/current-structure.sql"); - - // Get the new structure from db.sql - exec("egrep -v 'MariaDB dump|Host:|Server version|Dump completed' db.sql > $tmp_path/new-structure.sql"); - - // Compare - exec("diff $tmp_path/current-structure.sql $tmp_path/new-structure.sql > $tmp_path/diff.txt"); - $diff = file_get_contents("$tmp_path/diff.txt"); - - // Display, if there is a difference - if(!empty($diff)){ - echo "

Diff between your database structure and db.sql

"; - echo "
$diff
"; - } - - } - ?> + + + + + + + + + + + + + + +
CommitWhenDescription
+
-
+