librenms/scripts/build-schema.php
Tony Murray d841625f12 refactor: Refactor database and config init (#8527)
* Refactor database and config init
Connect to the database without loading full config
Load config completely so post-processing is always done consistently.
Erase existing $config when loading, fixes issues in case we load the config twice.
If the database is not connected, don't try to load database settings. (Fixes some db errors on install)
Attempt to remove $config access/modification before init.php
Remove usage of db_name, that might not match the connected database.
Centralize db config loading, so we consistently apply db_test database settings.
Many of these changes are influenced by Laravel port.

* Some safety so we don't assign strings to numeric port field
Smooth out phpunit bootstrap

* Fix a couple of scrutinizer warnings.
2018-04-11 16:15:13 +01:00

15 lines
340 B
PHP
Executable File

#!/usr/bin/env php
<?php
$install_dir = realpath(__DIR__ . '/..');
// update.php will call init.php
require $install_dir . '/includes/sql-schema/update.php';
$file = $install_dir . '/misc/db_schema.yaml';
$yaml = Symfony\Component\Yaml\Yaml::dump(dump_db_schema(), 3, 2);
if (file_put_contents($file, $yaml)) {
echo "Updated!\n";
}