Faster initial database creation (#12297)

* Faster initial database creation
Add db dumps to improve initial db migration
On my test system 13s -> 7s, a 46% reduction.
Should help out a lot on systems like RPi

* lnms schema:dump command

--snapshots saves db snapshots, otherwise it saves the yaml

* fix style

* fix timezones...

* not working with in-memory db yet
remove build.sql
This commit is contained in:
Tony Murray
2020-11-05 18:19:15 -06:00
committed by GitHub
parent 03c950af8c
commit 25722bbbd5
10 changed files with 5663 additions and 196 deletions

View File

@@ -26,6 +26,7 @@ namespace LibreNMS\Tests;
use Artisan;
use DB;
use LibreNMS\DB\Schema;
class DBSetupTest extends DBTestCase
{
@@ -118,10 +119,10 @@ class DBSetupTest extends DBTestCase
file_get_contents('misc/db_schema.yaml')
);
$current_schema = dump_db_schema($this->connection);
$current_schema = Schema::dump($this->connection);
$message = "Schema does not match the expected schema defined by misc/db_schema.yaml\n";
$message .= "If you have changed the schema, make sure you update it with ./scripts/build-schema.php\n";
$message .= "If you have changed the schema, make sure you update it with: lnms schema:dump\n";
$this->assertEquals($master_schema, $current_schema, $message);
}