Make migrations work in SQLite (#11643)

* WIP Sqlite

Down methods don't work either, avoid them with refresh for now.

WIP persistent support

WIP db_schema

WIP db_schema 2

Update new migrations...

revert dump_db_schema changes for now, too much difference.

fix migrations on mysql

fix up some more items, this should be our target schema
lots of index renames and a two misc changes

index rename WIP

index rename WIP

another round

fix up new schema changes

try case insensitive fix

Trying tests WIP

fix down methods

DBSetupTest working (uses mysql)

Test sqlite migrations work

* Properly validate sqlite output

* revert glue changes, should be separate PR

* remove dusk workaround

* remove unused variables

* import

* sqlite capitalization

* Revert some refresh tests

* testing_mysql back to testing
This commit is contained in:
Tony Murray
2020-05-22 16:49:21 -05:00
committed by GitHub
parent 5927983c50
commit 5fc3fcb9e8
128 changed files with 746 additions and 457 deletions

View File

@@ -77,7 +77,7 @@ class Eloquent
*/
public static function setStrictMode($strict = true)
{
if (self::isConnected()) {
if (self::isConnected() && self::getDriver() == 'mysql') {
if ($strict) {
self::DB()->getPdo()->exec("SET sql_mode='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'");
} else {
@@ -118,4 +118,10 @@ class Eloquent
return self::$capsule->getDatabaseManager()->connection();
}
public static function getDriver()
{
$connection = config('database.default');
return config("database.connections.{$connection}.driver");
}
}

View File

@@ -46,13 +46,13 @@ return [
'connections' => [
// 'sqlite' => [
// 'driver' => 'sqlite',
// 'url' => env('DATABASE_URL'),
// 'database' => env('DB_DATABASE', database_path('database.sqlite')),
// 'prefix' => '',
// 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
// ],
'sqlite' => [
'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', storage_path('librenms.sqlite')),
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],
'mysql' => [
'driver' => 'mysql',
@@ -117,10 +117,18 @@ return [
'prefix_indexes' => true,
],
'memory' => [
'testing_memory' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
'foreign_key_constraints' => true,
],
'testing_persistent' => [
'driver' => 'sqlite',
'database' => storage_path('testing.sqlite'),
'prefix' => '',
'foreign_key_constraints' => true,
]
],

View File

@@ -20,7 +20,7 @@ class CreateAccessPointsTable extends Migration
$table->tinyInteger('radio_number')->nullable();
$table->string('type', 16);
$table->string('mac_addr', 24);
$table->boolean('deleted')->default(0)->index('deleted');
$table->boolean('deleted')->default(0)->index();
$table->tinyInteger('channel')->unsigned()->default(0);
$table->tinyInteger('txpow')->default(0);
$table->tinyInteger('radioutil')->default(0);

View File

@@ -17,7 +17,7 @@ class CreateAlertDeviceMapTable extends Migration
$table->increments('id');
$table->unsignedInteger('rule_id');
$table->unsignedInteger('device_id');
$table->unique(['rule_id','device_id'], 'alert_device_map_rule_id_device_id_uindex');
$table->unique(['rule_id','device_id']);
});
}

View File

@@ -17,7 +17,7 @@ class CreateAlertGroupMapTable extends Migration
$table->increments('id');
$table->unsignedInteger('rule_id');
$table->unsignedInteger('group_id');
$table->unique(['rule_id','group_id'], 'alert_group_map_rule_id_group_id_uindex');
$table->unique(['rule_id','group_id']);
});
}

View File

@@ -15,14 +15,16 @@ class CreateAlertLogTable extends Migration
{
Schema::create('alert_log', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('rule_id')->index('rule_id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('rule_id')->index();
$table->unsignedInteger('device_id')->index();
$table->integer('state');
$table->binary('details')->nullable();
$table->timestamp('time_logged')->default(DB::raw('CURRENT_TIMESTAMP'))->index('time_logged');
$table->timestamp('time_logged')->useCurrent()->index();
});
\DB::statement("ALTER TABLE `alert_log` CHANGE `details` `details` longblob NULL ;");
if (\LibreNMS\DB\Eloquent::getDriver() == 'mysql') {
\DB::statement("ALTER TABLE `alert_log` CHANGE `details` `details` longblob NULL ;");
}
}
/**

View File

@@ -15,13 +15,13 @@ class CreateAlertRulesTable extends Migration
{
Schema::create('alert_rules', function (Blueprint $table) {
$table->increments('id');
$table->text('rule', 65535);
$table->text('rule');
$table->enum('severity', array('ok','warning','critical'));
$table->string('extra');
$table->boolean('disabled');
$table->string('name')->unique('name');
$table->text('query', 65535);
$table->text('builder', 65535);
$table->string('name')->unique();
$table->text('query');
$table->text('builder');
$table->string('proc', 80)->nullable();
});
}

View File

@@ -15,7 +15,7 @@ class CreateAlertSchedulablesTable extends Migration
{
Schema::create('alert_schedulables', function (Blueprint $table) {
$table->increments('item_id');
$table->unsignedInteger('schedule_id')->index('schedule_id');
$table->unsignedInteger('schedule_id')->index();
$table->unsignedInteger('alert_schedulable_id');
$table->string('alert_schedulable_type');
$table->index(['alert_schedulable_type', 'alert_schedulable_id'], 'schedulable_morph_index');

View File

@@ -24,7 +24,7 @@ class CreateAlertScheduleTable extends Migration
$table->time('end_recurring_hr')->default('00:00:00');
$table->string('recurring_day', 15)->nullable();
$table->string('title');
$table->text('notes', 65535);
$table->text('notes');
});
}

View File

@@ -15,15 +15,15 @@ class CreateAlertsTable extends Migration
{
Schema::create('alerts', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('rule_id')->index('rule_id');
$table->unsignedInteger('device_id')->index();
$table->unsignedInteger('rule_id')->index();
$table->integer('state');
$table->integer('alerted');
$table->integer('open');
$table->text('note')->nullable();
$table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
$table->timestamp('timestamp')->useCurrent();
$table->text('info');
$table->unique(['device_id','rule_id'], 'unique_alert');
$table->unique(['device_id','rule_id']);
});
}

View File

@@ -16,7 +16,7 @@ class CreateApiTokensTable extends Migration
Schema::create('api_tokens', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('user_id');
$table->string('token_hash')->nullable()->unique('token_hash');
$table->string('token_hash')->nullable()->unique();
$table->string('description', 100);
$table->boolean('disabled')->default(0);
});

View File

@@ -18,7 +18,7 @@ class CreateApplicationMetricsTable extends Migration
$table->string('metric', 32);
$table->double('value')->nullable();
$table->double('value_prev')->nullable();
$table->unique(['app_id','metric'], 'application_metrics_app_id_metric_uindex');
$table->unique(['app_id','metric']);
});
}

View File

@@ -21,9 +21,13 @@ class CreateApplicationsTable extends Migration
$table->tinyInteger('discovered')->default(0);
$table->string('app_state_prev', 32)->nullable();
$table->string('app_status', 8);
$table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
if (\LibreNMS\DB\Eloquent::getDriver() == 'mysql') {
$table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
} else {
$table->timestamp('timestamp')->useCurrent();
}
$table->string('app_instance');
$table->unique(['device_id','app_type'], 'unique_index');
$table->unique(['device_id','app_type']);
});
}

View File

@@ -15,10 +15,10 @@ class CreateAuthlogTable extends Migration
{
Schema::create('authlog', function (Blueprint $table) {
$table->increments('id');
$table->timestamp('datetime')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->text('user', 65535);
$table->text('address', 65535);
$table->text('result', 65535);
$table->timestamp('datetime')->useCurrent();
$table->text('user');
$table->text('address');
$table->text('result');
});
}

View File

@@ -37,8 +37,8 @@ class CreateBgpPeersCbgpTable extends Migration
$table->integer('WithdrawnPrefixes_delta');
$table->integer('WithdrawnPrefixes_prev');
$table->string('context_name', 128)->nullable();
$table->unique(['device_id','bgpPeerIdentifier','afi','safi'], 'unique_index');
$table->index(['device_id','bgpPeerIdentifier','context_name'], 'device_id');
$table->unique(['device_id','bgpPeerIdentifier','afi','safi']);
$table->index(['device_id','bgpPeerIdentifier','context_name']);
});
}

View File

@@ -17,12 +17,12 @@ class CreateBgpPeersTable extends Migration
$table->increments('bgpPeer_id');
$table->unsignedInteger('device_id');
$table->string('astext');
$table->text('bgpPeerIdentifier', 65535);
$table->text('bgpPeerIdentifier');
$table->bigInteger('bgpPeerRemoteAs');
$table->text('bgpPeerState', 65535);
$table->text('bgpPeerAdminStatus', 65535);
$table->text('bgpLocalAddr', 65535);
$table->text('bgpPeerRemoteAddr', 65535);
$table->text('bgpPeerState');
$table->text('bgpPeerAdminStatus');
$table->text('bgpLocalAddr');
$table->text('bgpPeerRemoteAddr');
$table->string('bgpPeerDescr')->default('');
$table->integer('bgpPeerInUpdates');
$table->integer('bgpPeerOutUpdates');
@@ -31,7 +31,7 @@ class CreateBgpPeersTable extends Migration
$table->integer('bgpPeerFsmEstablishedTime');
$table->integer('bgpPeerInUpdateElapsedTime');
$table->string('context_name', 128)->nullable();
$table->index(['device_id','context_name'], 'device_id');
$table->index(['device_id','context_name']);
});
}

View File

@@ -14,7 +14,7 @@ class CreateBillDataTable extends Migration
public function up()
{
Schema::create('bill_data', function (Blueprint $table) {
$table->unsignedInteger('bill_id')->index('bill_id');
$table->unsignedInteger('bill_id')->index();
$table->dateTime('timestamp');
$table->integer('period');
$table->bigInteger('delta');

View File

@@ -15,8 +15,8 @@ class CreateBillHistoryTable extends Migration
{
Schema::create('bill_history', function (Blueprint $table) {
$table->increments('bill_hist_id');
$table->unsignedInteger('bill_id')->index('bill_id');
$table->timestamp('updated')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->unsignedInteger('bill_id')->index();
$table->timestamp('updated')->useCurrent();
$table->dateTime('bill_datefrom');
$table->dateTime('bill_dateto');
$table->text('bill_type');
@@ -35,10 +35,12 @@ class CreateBillHistoryTable extends Migration
$table->bigInteger('traf_out');
$table->bigInteger('traf_total');
$table->binary('pdf')->nullable();
$table->unique(['bill_id','bill_datefrom','bill_dateto'], 'unique_index');
$table->unique(['bill_id','bill_datefrom','bill_dateto']);
});
\DB::statement("ALTER TABLE `bill_history` CHANGE `pdf` `pdf` longblob NULL ;");
if (\LibreNMS\DB\Eloquent::getDriver() == 'mysql') {
\DB::statement("ALTER TABLE `bill_history` CHANGE `pdf` `pdf` longblob NULL ;");
}
}
/**

View File

@@ -15,7 +15,7 @@ class CreateBillPortCountersTable extends Migration
{
Schema::create('bill_port_counters', function (Blueprint $table) {
$table->unsignedInteger('port_id');
$table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('timestamp')->useCurrent();
$table->bigInteger('in_counter')->nullable();
$table->bigInteger('in_delta')->default(0);
$table->bigInteger('out_counter')->nullable();

View File

@@ -15,8 +15,8 @@ class CreateBillsTable extends Migration
{
Schema::create('bills', function (Blueprint $table) {
$table->increments('bill_id');
$table->text('bill_name', 65535);
$table->text('bill_type', 65535);
$table->text('bill_name');
$table->text('bill_type');
$table->bigInteger('bill_cdr')->nullable();
$table->integer('bill_day')->default(1);
$table->bigInteger('bill_quota')->nullable();

View File

@@ -28,7 +28,7 @@ class CreateCefSwitchingTable extends Migration
$table->integer('punt2host_prev');
$table->unsignedInteger('updated');
$table->unsignedInteger('updated_prev');
$table->unique(['device_id','entPhysicalIndex','afi','cef_index'], 'device_id');
$table->unique(['device_id','entPhysicalIndex','afi','cef_index']);
});
}

View File

@@ -15,7 +15,7 @@ class CreateCiscoASATable extends Migration
{
Schema::create('ciscoASA', function (Blueprint $table) {
$table->increments('ciscoASA_id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->string('oid');
$table->bigInteger('data');
$table->bigInteger('high_alert');

View File

@@ -15,7 +15,7 @@ class CreateComponentPrefsTable extends Migration
{
Schema::create('component_prefs', function (Blueprint $table) {
$table->increments('id')->comment('ID for each entry');
$table->unsignedInteger('component')->index('component')->comment('id from the component table');
$table->unsignedInteger('component')->index()->comment('id from the component table');
$table->string('attribute')->comment('Attribute for the Component');
$table->text('value')->comment('Value for the Component');
});

View File

@@ -15,10 +15,10 @@ class CreateComponentStatuslogTable extends Migration
{
Schema::create('component_statuslog', function (Blueprint $table) {
$table->increments('id')->comment('ID for each log entry, unique index');
$table->unsignedInteger('component_id')->index('device')->comment('id from the component table');
$table->unsignedInteger('component_id')->index()->comment('id from the component table');
$table->boolean('status')->default(0)->comment('The status that the component was changed TO');
$table->text('message')->nullable();
$table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP'))->comment('When the status of the component was changed');
$table->timestamp('timestamp')->useCurrent()->comment('When the status of the component was changed');
});
}

View File

@@ -15,8 +15,8 @@ class CreateComponentTable extends Migration
{
Schema::create('component', function (Blueprint $table) {
$table->increments('id')->comment('ID for each component, unique index');
$table->unsignedInteger('device_id')->index('device')->comment('device_id from the devices table');
$table->string('type', 50)->index('type')->comment('name from the component_type table');
$table->unsignedInteger('device_id')->index()->comment('device_id from the devices table');
$table->string('type', 50)->index()->comment('name from the component_type table');
$table->string('label')->nullable()->comment('Display label for the component');
$table->boolean('status')->default(0)->comment('The status of the component, retreived from the device');
$table->boolean('disabled')->default(0)->comment('Should this component be polled');

View File

@@ -15,7 +15,7 @@ class CreateConfigTable extends Migration
{
Schema::create('config', function (Blueprint $table) {
$table->increments('config_id');
$table->string('config_name')->unique('uniqueindex_configname');
$table->string('config_name')->unique();
$table->string('config_value', 512);
$table->string('config_default', 512);
$table->string('config_descr', 100);

View File

@@ -15,7 +15,7 @@ class CreateCustomersTable extends Migration
{
Schema::create('customers', function (Blueprint $table) {
$table->increments('customer_id');
$table->char('username', 64)->unique('username');
$table->char('username', 64)->unique();
$table->char('password', 32);
$table->char('string', 64);
$table->tinyInteger('level')->default(0);

View File

@@ -14,7 +14,8 @@ class CreateDeviceGraphsTable extends Migration
public function up()
{
Schema::create('device_graphs', function (Blueprint $table) {
$table->unsignedInteger('device_id')->index('device_id');
$table->bigIncrements('id');
$table->unsignedInteger('device_id')->index();
$table->string('graph')->nullable();
});
}

View File

@@ -15,7 +15,7 @@ class CreateDeviceGroupsTable extends Migration
{
Schema::create('device_groups', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->default('')->unique('name');
$table->string('name')->default('')->unique();
$table->string('desc')->default('');
$table->text('pattern')->nullable();
$table->text('params')->nullable();

View File

@@ -18,7 +18,11 @@ class CreateDeviceMibsTable extends Migration
$table->string('module');
$table->string('mib');
$table->string('included_by');
$table->timestamp('last_modified')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
if (\LibreNMS\DB\Eloquent::getDriver() == 'mysql') {
$table->timestamp('last_modified')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
} else {
$table->timestamp('last_modified')->useCurrent();
}
$table->primary(['device_id','module','mib']);
});
}

View File

@@ -21,7 +21,11 @@ class CreateDeviceOidsTable extends Migration
$table->string('object_type');
$table->string('value')->nullable();
$table->bigInteger('numvalue')->nullable();
$table->timestamp('last_modified')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
if (\LibreNMS\DB\Eloquent::getDriver() == 'mysql') {
$table->timestamp('last_modified')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
} else {
$table->timestamp('last_modified')->useCurrent();
}
$table->primary(['device_id','oid']);
});
}

View File

@@ -15,7 +15,7 @@ class CreateDevicePerfTable extends Migration
{
Schema::create('device_perf', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->dateTime('timestamp');
$table->integer('xmt');
$table->integer('rcv');

View File

@@ -15,7 +15,7 @@ class CreateDeviceRelationshipsTable extends Migration
{
Schema::create('device_relationships', function (Blueprint $table) {
$table->unsignedInteger('parent_device_id')->default(0);
$table->unsignedInteger('child_device_id')->index('device_relationship_child_device_id_fk');
$table->unsignedInteger('child_device_id')->index();
$table->primary(['parent_device_id','child_device_id']);
});
}

View File

@@ -15,10 +15,14 @@ class CreateDevicesAttribsTable extends Migration
{
Schema::create('devices_attribs', function (Blueprint $table) {
$table->increments('attrib_id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->string('attrib_type', 32);
$table->text('attrib_value', 65535);
$table->timestamp('updated')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
$table->text('attrib_value');
if (\LibreNMS\DB\Eloquent::getDriver() == 'mysql') {
$table->timestamp('updated')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
} else {
$table->timestamp('updated')->useCurrent();
}
});
}

View File

@@ -14,7 +14,7 @@ class CreateDevicesPermsTable extends Migration
public function up()
{
Schema::create('devices_perms', function (Blueprint $table) {
$table->unsignedInteger('user_id')->index('user_id');
$table->unsignedInteger('user_id')->index();
$table->unsignedInteger('device_id');
});
}

View File

@@ -15,8 +15,8 @@ class CreateDevicesTable extends Migration
{
Schema::create('devices', function (Blueprint $table) {
$table->increments('device_id');
$table->string('hostname', 128)->index('hostname');
$table->string('sysName', 128)->nullable()->index('sysName');
$table->string('hostname', 128)->index();
$table->string('sysName', 128)->nullable()->index();
$table->binary('ip')->nullable();
$table->string('community')->nullable();
$table->enum('authlevel', array('noAuthNoPriv','authNoPriv','authPriv'))->nullable();
@@ -39,32 +39,34 @@ class CreateDevicesTable extends Migration
$table->text('hardware')->nullable();
$table->text('features')->nullable();
$table->unsignedInteger('location_id')->nullable();
$table->string('os', 32)->nullable()->index('os');
$table->boolean('status')->default(0)->index('status');
$table->string('os', 32)->nullable()->index();
$table->boolean('status')->default(0)->index();
$table->string('status_reason', 50);
$table->boolean('ignore')->default(0);
$table->boolean('disabled')->default(0);
$table->bigInteger('uptime')->nullable();
$table->unsignedInteger('agent_uptime')->default(0);
$table->timestamp('last_polled')->nullable()->index('last_polled');
$table->timestamp('last_poll_attempted')->nullable()->index('last_poll_attempted');
$table->timestamp('last_polled')->nullable()->index();
$table->timestamp('last_poll_attempted')->nullable()->index();
$table->float('last_polled_timetaken', 5)->nullable();
$table->float('last_discovered_timetaken', 5)->nullable();
$table->timestamp('last_discovered')->nullable();
$table->timestamp('last_ping')->nullable();
$table->float('last_ping_timetaken')->nullable();
$table->text('purpose', 65535)->nullable();
$table->text('purpose')->nullable();
$table->string('type', 20)->default('');
$table->text('serial', 65535)->nullable();
$table->text('serial')->nullable();
$table->string('icon')->nullable();
$table->integer('poller_group')->default(0);
$table->boolean('override_sysLocation')->nullable()->default(0);
$table->text('notes', 65535)->nullable();
$table->text('notes')->nullable();
$table->integer('port_association_mode')->default(1);
$table->integer('max_depth')->default(0);
});
\DB::statement("ALTER TABLE `devices` CHANGE `ip` `ip` varbinary(16) NULL ;");
if (\LibreNMS\DB\Eloquent::getDriver() == 'mysql') {
\DB::statement("ALTER TABLE `devices` CHANGE `ip` `ip` varbinary(16) NULL ;");
}
}
/**

View File

@@ -15,23 +15,23 @@ class CreateEntPhysicalTable extends Migration
{
Schema::create('entPhysical', function (Blueprint $table) {
$table->increments('entPhysical_id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->integer('entPhysicalIndex');
$table->text('entPhysicalDescr', 65535);
$table->text('entPhysicalClass', 65535);
$table->text('entPhysicalName', 65535);
$table->text('entPhysicalDescr');
$table->text('entPhysicalClass');
$table->text('entPhysicalName');
$table->string('entPhysicalHardwareRev', 64)->nullable();
$table->string('entPhysicalFirmwareRev', 64)->nullable();
$table->string('entPhysicalSoftwareRev', 64)->nullable();
$table->string('entPhysicalAlias', 32)->nullable();
$table->string('entPhysicalAssetID', 32)->nullable();
$table->string('entPhysicalIsFRU', 8)->nullable();
$table->text('entPhysicalModelName', 65535);
$table->text('entPhysicalVendorType', 65535)->nullable();
$table->text('entPhysicalSerialNum', 65535);
$table->text('entPhysicalModelName');
$table->text('entPhysicalVendorType')->nullable();
$table->text('entPhysicalSerialNum');
$table->integer('entPhysicalContainedIn');
$table->integer('entPhysicalParentRelPos');
$table->text('entPhysicalMfgName', 65535);
$table->text('entPhysicalMfgName');
$table->integer('ifIndex')->nullable();
});
}

View File

@@ -15,7 +15,7 @@ class CreateEntityStateTable extends Migration
{
Schema::create('entityState', function (Blueprint $table) {
$table->increments('entity_state_id');
$table->unsignedInteger('device_id')->nullable();
$table->unsignedInteger('device_id')->nullable()->index();
$table->unsignedInteger('entPhysical_id')->nullable();
$table->dateTime('entStateLastChanged')->nullable();
$table->integer('entStateAdmin')->nullable();
@@ -23,7 +23,6 @@ class CreateEntityStateTable extends Migration
$table->integer('entStateUsage')->nullable();
$table->text('entStateAlarm')->nullable();
$table->integer('entStateStandby')->nullable();
$table->index('device_id', 'entityState_device_id_index');
});
}

View File

@@ -15,8 +15,8 @@ class CreateEventlogTable extends Migration
{
Schema::create('eventlog', function (Blueprint $table) {
$table->increments('event_id');
$table->unsignedInteger('device_id')->nullable()->index('device_id');
$table->dateTime('datetime')->default('1970-01-02 00:00:01')->index('datetime');
$table->unsignedInteger('device_id')->nullable()->index();
$table->dateTime('datetime')->default('1970-01-02 00:00:01')->index();
$table->text('message')->nullable();
$table->string('type', 64)->nullable();
$table->string('reference', 64)->nullable();

View File

@@ -14,9 +14,9 @@ class CreateGraphTypesTable extends Migration
public function up()
{
Schema::create('graph_types', function (Blueprint $table) {
$table->string('graph_type', 32)->index('graph_type');
$table->string('graph_subtype', 64)->index('graph_subtype');
$table->string('graph_section', 32)->index('graph_section');
$table->string('graph_type', 32)->index();
$table->string('graph_subtype', 64)->index();
$table->string('graph_section', 32)->index();
$table->string('graph_descr')->nullable();
$table->integer('graph_order');
$table->primary(['graph_type','graph_subtype','graph_section']);

View File

@@ -15,7 +15,7 @@ class CreateHrDeviceTable extends Migration
{
Schema::create('hrDevice', function (Blueprint $table) {
$table->increments('hrDevice_id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->integer('hrDeviceIndex');
$table->text('hrDeviceDescr');
$table->text('hrDeviceType');

View File

@@ -22,7 +22,7 @@ class CreateIpsecTunnelsTable extends Migration
$table->unsignedInteger('local_port');
$table->string('tunnel_name', 96);
$table->string('tunnel_status', 11);
$table->unique(['device_id','peer_addr'], 'unique_index');
$table->unique(['device_id','peer_addr']);
});
}

View File

@@ -18,7 +18,7 @@ class CreateIpv4AddressesTable extends Migration
$table->string('ipv4_address', 32);
$table->integer('ipv4_prefixlen');
$table->string('ipv4_network_id', 32);
$table->unsignedInteger('port_id')->index('interface_id');
$table->unsignedInteger('port_id')->index();
$table->string('context_name', 128)->nullable();
});
}

View File

@@ -14,9 +14,9 @@ class CreateIpv4MacTable extends Migration
public function up()
{
Schema::create('ipv4_mac', function (Blueprint $table) {
$table->unsignedInteger('port_id')->index('port_id');
$table->unsignedInteger('port_id')->index();
$table->unsignedInteger('device_id')->nullable();
$table->string('mac_address', 32)->index('mac_address');
$table->string('mac_address', 32)->index();
$table->string('ipv4_address', 32);
$table->string('context_name', 128);
});

View File

@@ -20,7 +20,7 @@ class CreateIpv6AddressesTable extends Migration
$table->integer('ipv6_prefixlen');
$table->string('ipv6_origin', 16);
$table->string('ipv6_network_id', 128);
$table->unsignedInteger('port_id')->index('interface_id');
$table->unsignedInteger('port_id')->index();
$table->string('context_name', 128)->nullable();
});
}

View File

@@ -15,7 +15,7 @@ class CreateJuniAtmVpTable extends Migration
{
Schema::create('juniAtmVp', function (Blueprint $table) {
$table->unsignedInteger('juniAtmVp_id');
$table->unsignedInteger('port_id')->index('port_id');
$table->unsignedInteger('port_id')->index();
$table->unsignedInteger('vp_id');
$table->string('vp_descr', 32);
});

View File

@@ -15,9 +15,9 @@ class CreateLinksTable extends Migration
{
Schema::create('links', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('local_port_id')->nullable()->index('src_if');
$table->unsignedInteger('local_port_id')->nullable()->index();
$table->unsignedInteger('local_device_id');
$table->unsignedInteger('remote_port_id')->nullable()->index('dst_if');
$table->unsignedInteger('remote_port_id')->nullable()->index();
$table->boolean('active')->default(1);
$table->string('protocol', 11)->nullable();
$table->string('remote_hostname', 128);

View File

@@ -17,7 +17,7 @@ class CreateLoadbalancerVserversTable extends Migration
$table->unsignedInteger('classmap_id');
$table->string('classmap', 128);
$table->string('serverstate', 64);
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
});
}

View File

@@ -15,7 +15,7 @@ class CreateLocationsTable extends Migration
{
Schema::create('locations', function (Blueprint $table) {
$table->increments('id');
$table->string('location')->unique('locations_location_uindex');
$table->string('location')->unique();
$table->float('lat', 10, 6)->nullable();
$table->float('lng', 10, 6)->nullable();
$table->dateTime('timestamp');

View File

@@ -15,7 +15,7 @@ class CreateMacAccountingTable extends Migration
{
Schema::create('mac_accounting', function (Blueprint $table) {
$table->increments('ma_id');
$table->unsignedInteger('port_id')->index('interface_id_2');
$table->unsignedInteger('port_id')->index();
$table->string('mac', 32);
$table->string('in_oid', 128);
$table->string('out_oid', 128);
@@ -40,7 +40,6 @@ class CreateMacAccountingTable extends Migration
$table->unsignedInteger('poll_time')->nullable();
$table->unsignedInteger('poll_prev')->nullable();
$table->unsignedInteger('poll_period')->nullable();
$table->index('port_id', 'interface_id');
});
}

View File

@@ -15,8 +15,8 @@ class CreateMefinfoTable extends Migration
{
Schema::create('mefinfo', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('device_id')->index('device_id');
$table->integer('mefID')->index('mefID');
$table->unsignedInteger('device_id')->index();
$table->integer('mefID')->index();
$table->string('mefType', 128);
$table->string('mefIdent', 128);
$table->integer('mefMTU')->default(1500);

View File

@@ -21,7 +21,7 @@ class CreateMempoolsTable extends Migration
$table->string('mempool_type', 32);
$table->integer('mempool_precision')->default(1);
$table->string('mempool_descr', 64);
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->integer('mempool_perc');
$table->bigInteger('mempool_used');
$table->bigInteger('mempool_free');

View File

@@ -23,7 +23,11 @@ class CreateMibdefsTable extends Migration
$table->string('max_access')->nullable();
$table->string('status')->nullable();
$table->string('included_by');
$table->timestamp('last_modified')->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'));
if (\LibreNMS\DB\Eloquent::getDriver() == 'mysql') {
$table->timestamp('last_modified')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
} else {
$table->timestamp('last_modified')->useCurrent();
}
$table->primary(['module','mib','object_type']);
});
}

View File

@@ -22,17 +22,17 @@ class CreateMuninPluginsDsTable extends Migration
$table->string('ds_draw', 64);
$table->enum('ds_graph', array('no','yes'))->default('yes');
$table->string('ds_info');
$table->text('ds_extinfo', 65535);
$table->text('ds_extinfo');
$table->string('ds_max', 32);
$table->string('ds_min', 32);
$table->string('ds_negative', 32);
$table->string('ds_warning', 32);
$table->string('ds_critical', 32);
$table->string('ds_colour', 32);
$table->text('ds_sum', 65535);
$table->text('ds_stack', 65535);
$table->text('ds_sum');
$table->text('ds_stack');
$table->string('ds_line', 64);
$table->unique(['mplug_id','ds_name'], 'splug_id');
$table->unique(['mplug_id','ds_name']);
});
}

View File

@@ -15,7 +15,7 @@ class CreateMuninPluginsTable extends Migration
{
Schema::create('munin_plugins', function (Blueprint $table) {
$table->increments('mplug_id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->string('mplug_type');
$table->string('mplug_instance', 128)->nullable();
$table->string('mplug_category', 32)->nullable();
@@ -25,7 +25,7 @@ class CreateMuninPluginsTable extends Migration
$table->string('mplug_args', 512)->nullable();
$table->boolean('mplug_total')->default(0);
$table->boolean('mplug_graph')->default(1);
$table->unique(['device_id','mplug_type'], 'UNIQUE');
$table->unique(['device_id','mplug_type']);
});
}

View File

@@ -16,10 +16,10 @@ class CreateNotificationsTable extends Migration
Schema::create('notifications', function (Blueprint $table) {
$table->increments('notifications_id');
$table->string('title')->default('');
$table->text('body', 65535);
$table->text('body');
$table->integer('severity')->nullable()->default(0)->index()->comment('0=ok,1=warning,2=critical');
$table->string('source')->default('');
$table->string('checksum', 128)->unique('checksum');
$table->string('checksum', 128)->unique();
$table->timestamp('datetime')->default('1970-01-02 00:00:00');
});
}

View File

@@ -27,7 +27,7 @@ class CreateOspfAreasTable extends Migration
$table->string('ospfAreaSummary', 64);
$table->string('ospfAreaStatus', 64);
$table->string('context_name', 128)->nullable();
$table->unique(['device_id','ospfAreaId','context_name'], 'device_area');
$table->unique(['device_id','ospfAreaId','context_name']);
});
}

View File

@@ -32,7 +32,7 @@ class CreateOspfInstancesTable extends Migration
$table->integer('ospfExitOverflowInterval')->nullable();
$table->string('ospfDemandExtensions', 32)->nullable();
$table->string('context_name', 128)->nullable();
$table->unique(['device_id','ospf_instance_id','context_name'], 'device_id');
$table->unique(['device_id','ospf_instance_id','context_name']);
});
}

View File

@@ -30,7 +30,7 @@ class CreateOspfNbrsTable extends Migration
$table->string('ospfNbmaNbrPermanence', 32);
$table->string('ospfNbrHelloSuppressed', 32);
$table->string('context_name', 128)->nullable();
$table->unique(['device_id','ospf_nbr_id','context_name'], 'device_id');
$table->unique(['device_id','ospf_nbr_id','context_name']);
});
}

View File

@@ -39,7 +39,7 @@ class CreateOspfPortsTable extends Migration
$table->string('ospfIfDemand', 32)->nullable();
$table->string('ospfIfAuthType', 32)->nullable();
$table->string('context_name', 128)->nullable();
$table->unique(['device_id','ospf_port_id','context_name'], 'device_id');
$table->unique(['device_id','ospf_port_id','context_name']);
});
}

View File

@@ -15,7 +15,7 @@ class CreatePackagesTable extends Migration
{
Schema::create('packages', function (Blueprint $table) {
$table->increments('pkg_id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->string('name', 64);
$table->string('manager', 16)->default('1');
$table->boolean('status');
@@ -23,7 +23,7 @@ class CreatePackagesTable extends Migration
$table->string('build', 64);
$table->string('arch', 16);
$table->bigInteger('size')->nullable();
$table->unique(['device_id','name','manager','arch','version','build'], 'unique_key');
$table->unique(['device_id','name','manager','arch','version','build']);
});
}

View File

@@ -15,7 +15,7 @@ class CreatePerfTimesTable extends Migration
{
Schema::create('perf_times', function (Blueprint $table) {
$table->increments('id');
$table->string('type', 8)->index('type');
$table->string('type', 8)->index();
$table->string('doing', 64);
$table->unsignedInteger('start');
$table->float('duration');

View File

@@ -22,7 +22,7 @@ class CreatePollerClusterStatsTable extends Migration
$table->double('worker_seconds')->unsigned();
$table->unsignedInteger('workers');
$table->unsignedInteger('frequency');
$table->unique(['parent_poller', 'poller_type'], 'parent_poller_poller_type');
$table->unique(['parent_poller', 'poller_type']);
});
}

View File

@@ -15,7 +15,7 @@ class CreatePollersTable extends Migration
{
Schema::create('pollers', function (Blueprint $table) {
$table->increments('id');
$table->string('poller_name')->unique('poller_name');
$table->string('poller_name')->unique();
$table->dateTime('last_polled');
$table->unsignedInteger('devices');
$table->float('time_taken', 10, 0);

View File

@@ -14,8 +14,8 @@ class CreatePortsAdslTable extends Migration
public function up()
{
Schema::create('ports_adsl', function (Blueprint $table) {
$table->unsignedInteger('port_id')->unique('interface_id');
$table->timestamp('port_adsl_updated')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->unsignedInteger('port_id')->unique();
$table->timestamp('port_adsl_updated')->useCurrent();
$table->string('adslLineCoding', 8);
$table->string('adslLineType', 16);
$table->string('adslAtucInvVendorID', 8);

View File

@@ -16,7 +16,7 @@ class CreatePortsFdbTable extends Migration
Schema::create('ports_fdb', function (Blueprint $table) {
$table->unsignedBigInteger('ports_fdb_id', true);
$table->unsignedInteger('port_id')->index();
$table->string('mac_address', 32)->index('mac_address');
$table->string('mac_address', 32)->index();
$table->unsignedInteger('vlan_id')->index();
$table->unsignedInteger('device_id')->index();
});

View File

@@ -16,7 +16,7 @@ class CreatePortsNacTable extends Migration
Schema::create('ports_nac', function (Blueprint $table) {
$table->increments('ports_nac_id');
$table->string('auth_id', 50);
$table->unsignedInteger('device_id')->index('ports_nac_device_id_index');
$table->unsignedInteger('device_id')->index();
$table->unsignedInteger('port_id');
$table->string('domain', 50);
$table->string('username', 50);

View File

@@ -18,7 +18,7 @@ class CreatePortsStackTable extends Migration
$table->unsignedInteger('port_id_high');
$table->unsignedInteger('port_id_low');
$table->string('ifStackStatus', 32);
$table->unique(['device_id','port_id_high','port_id_low'], 'device_id');
$table->unique(['device_id','port_id_high','port_id_low']);
});
}

View File

@@ -26,7 +26,7 @@ class CreatePortsStpTable extends Migration
$table->string('designatedBridge', 32);
$table->mediumInteger('designatedPort');
$table->integer('forwardTransitions')->unsigned();
$table->unique(['device_id','port_id'], 'device_id');
$table->unique(['device_id','port_id']);
});
}

View File

@@ -21,7 +21,7 @@ class CreatePortsTable extends Migration
$table->string('port_descr_circuit')->nullable();
$table->string('port_descr_speed', 32)->nullable();
$table->string('port_descr_notes')->nullable();
$table->string('ifDescr')->nullable()->index('if_2');
$table->string('ifDescr')->nullable()->index();
$table->string('ifName')->nullable();
$table->string('portName', 128)->nullable();
$table->bigInteger('ifIndex')->nullable()->default(0);
@@ -35,9 +35,9 @@ class CreatePortsTable extends Migration
$table->string('ifAdminStatus_prev', 16)->nullable();
$table->string('ifDuplex', 12)->nullable();
$table->integer('ifMtu')->nullable();
$table->text('ifType', 65535)->nullable();
$table->text('ifAlias', 65535)->nullable();
$table->text('ifPhysAddress', 65535)->nullable();
$table->text('ifType')->nullable();
$table->text('ifAlias')->nullable();
$table->text('ifPhysAddress')->nullable();
$table->string('ifHardType', 64)->nullable();
$table->bigInteger('ifLastChange')->unsigned()->default(0);
$table->string('ifVlan', 8)->default('');
@@ -86,7 +86,7 @@ class CreatePortsTable extends Migration
$table->unsignedInteger('poll_time')->nullable();
$table->unsignedInteger('poll_prev')->nullable();
$table->unsignedInteger('poll_period')->nullable();
$table->unique(['device_id','ifIndex'], 'device_ifIndex');
$table->unique(['device_id','ifIndex']);
});
}

View File

@@ -23,7 +23,7 @@ class CreatePortsVlansTable extends Migration
$table->string('state', 16);
$table->integer('cost');
$table->boolean('untagged')->default(0);
$table->unique(['device_id','port_id','vlan'], 'unique');
$table->unique(['device_id','port_id','vlan']);
});
}

View File

@@ -14,7 +14,7 @@ class CreateProcessesTable extends Migration
public function up()
{
Schema::create('processes', function (Blueprint $table) {
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->integer('pid');
$table->integer('vsz');
$table->integer('rss');

View File

@@ -17,7 +17,7 @@ class CreateProcessorsTable extends Migration
$table->increments('processor_id');
$table->integer('entPhysicalIndex')->default(0);
$table->integer('hrDeviceIndex')->nullable();
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->string('processor_oid', 128);
$table->string('processor_index', 32);
$table->string('processor_type', 16);

View File

@@ -17,8 +17,8 @@ class CreateProxmoxPortsTable extends Migration
$table->increments('id');
$table->integer('vm_id');
$table->string('port', 10);
$table->timestamp('last_seen')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->unique(['vm_id','port'], 'vm_port');
$table->timestamp('last_seen')->useCurrent();
$table->unique(['vm_id','port']);
});
}

View File

@@ -19,8 +19,8 @@ class CreateProxmoxTable extends Migration
$table->integer('vmid');
$table->string('cluster');
$table->string('description')->nullable();
$table->timestamp('last_seen')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->unique(['cluster','vmid'], 'cluster_vm');
$table->timestamp('last_seen')->useCurrent();
$table->unique(['cluster','vmid']);
});
}

View File

@@ -16,12 +16,12 @@ class CreateSensorsTable extends Migration
Schema::create('sensors', function (Blueprint $table) {
$table->increments('sensor_id');
$table->boolean('sensor_deleted')->default(0);
$table->string('sensor_class', 64)->index('sensor_class');
$table->unsignedInteger('device_id')->default(0)->index('sensor_host');
$table->string('sensor_class', 64)->index();
$table->unsignedInteger('device_id')->default(0)->index();
$table->string('poller_type', 16)->default('snmp');
$table->string('sensor_oid');
$table->string('sensor_index', 128)->nullable();
$table->string('sensor_type')->index('sensor_type');
$table->string('sensor_type')->index();
$table->string('sensor_descr')->nullable();
$table->string('group')->nullable();
$table->bigInteger('sensor_divisor')->default(1);
@@ -35,7 +35,11 @@ class CreateSensorsTable extends Migration
$table->enum('sensor_custom', array('No','Yes'))->default('No');
$table->string('entPhysicalIndex', 16)->nullable();
$table->string('entPhysicalIndex_measured', 16)->nullable();
$table->timestamp('lastupdate')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
if (\LibreNMS\DB\Eloquent::getDriver() == 'mysql') {
$table->timestamp('lastupdate')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
} else {
$table->timestamp('lastupdate')->useCurrent();
}
$table->double('sensor_prev')->nullable();
$table->string('user_func', 100)->nullable();
});

View File

@@ -16,8 +16,8 @@ class CreateSensorsToStateIndexesTable extends Migration
Schema::create('sensors_to_state_indexes', function (Blueprint $table) {
$table->increments('sensors_to_state_translations_id');
$table->unsignedInteger('sensor_id');
$table->unsignedInteger('state_index_id')->index('state_index_id');
$table->unique(['sensor_id','state_index_id'], 'sensor_id_state_index_id');
$table->unsignedInteger('state_index_id')->index();
$table->unique(['sensor_id','state_index_id']);
});
}

View File

@@ -15,7 +15,7 @@ class CreateServicesTable extends Migration
{
Schema::create('services', function (Blueprint $table) {
$table->increments('service_id');
$table->unsignedInteger('device_id')->index('service_host');
$table->unsignedInteger('device_id')->index();
$table->text('service_ip');
$table->string('service_type');
$table->text('service_desc');

View File

@@ -16,7 +16,7 @@ class CreateSessionTable extends Migration
Schema::create('session', function (Blueprint $table) {
$table->increments('session_id');
$table->string('session_username');
$table->string('session_value', 60)->unique('session_value');
$table->string('session_value', 60)->unique();
$table->string('session_token', 60);
$table->string('session_auth', 16);
$table->integer('session_expiry');

View File

@@ -15,7 +15,7 @@ class CreateSlasTable extends Migration
{
Schema::create('slas', function (Blueprint $table) {
$table->increments('sla_id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->integer('sla_nr');
$table->string('owner');
$table->string('tag');
@@ -23,7 +23,7 @@ class CreateSlasTable extends Migration
$table->boolean('status');
$table->boolean('opstatus')->default(0);
$table->boolean('deleted')->default(0);
$table->unique(['device_id','sla_nr'], 'unique_key');
$table->unique(['device_id','sla_nr']);
});
}

View File

@@ -15,7 +15,7 @@ class CreateStateIndexesTable extends Migration
{
Schema::create('state_indexes', function (Blueprint $table) {
$table->increments('state_index_id');
$table->string('state_name', 64)->unique('state_name');
$table->string('state_name', 64)->unique();
});
}

View File

@@ -20,8 +20,12 @@ class CreateStateTranslationsTable extends Migration
$table->boolean('state_draw_graph');
$table->smallInteger('state_value')->default(0);
$table->boolean('state_generic_value');
$table->timestamp('state_lastupdated')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
$table->unique(['state_index_id','state_value'], 'state_index_id_value');
if (\LibreNMS\DB\Eloquent::getDriver() == 'mysql') {
$table->timestamp('state_lastupdated')->default(DB::raw('CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP'));
} else {
$table->timestamp('state_lastupdated')->useCurrent();
}
$table->unique(['state_index_id','state_value']);
});
}

View File

@@ -15,11 +15,11 @@ class CreateStorageTable extends Migration
{
Schema::create('storage', function (Blueprint $table) {
$table->increments('storage_id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->string('storage_mib', 16);
$table->string('storage_index', 64)->nullable();
$table->string('storage_type', 32)->nullable();
$table->text('storage_descr', 65535);
$table->text('storage_descr');
$table->bigInteger('storage_size');
$table->integer('storage_units');
$table->bigInteger('storage_used')->default(0);
@@ -27,7 +27,7 @@ class CreateStorageTable extends Migration
$table->integer('storage_perc')->default(0);
$table->integer('storage_perc_warn')->nullable()->default(60);
$table->boolean('storage_deleted')->default(0);
$table->unique(['device_id','storage_mib','storage_index'], 'index_unique');
$table->unique(['device_id','storage_mib','storage_index']);
});
}

View File

@@ -14,7 +14,7 @@ class CreateStpTable extends Migration
{
Schema::create('stp', function (Blueprint $table) {
$table->increments('stp_id');
$table->unsignedInteger('device_id')->index('stp_host');
$table->unsignedInteger('device_id')->index();
$table->boolean('rootBridge');
$table->string('bridgeAddress', 32);
$table->string('protocolSpecification', 16);

View File

@@ -14,17 +14,17 @@ class CreateSyslogTable extends Migration
public function up()
{
Schema::create('syslog', function (Blueprint $table) {
$table->unsignedInteger('device_id')->nullable()->index('device_id');
$table->unsignedInteger('device_id')->nullable()->index();
$table->string('facility', 10)->nullable();
$table->string('priority', 10)->nullable();
$table->string('level', 10)->nullable();
$table->string('tag', 10)->nullable();
$table->timestamp('timestamp')->default(DB::raw('CURRENT_TIMESTAMP'))->index('datetime');
$table->string('program', 32)->nullable()->index('program');
$table->text('msg', 65535)->nullable();
$table->timestamp('timestamp')->useCurrent()->index();
$table->string('program', 32)->nullable()->index();
$table->text('msg')->nullable();
$table->bigInteger('seq', true)->unsigned();
$table->index(['priority','level'], 'priority_level');
$table->index(['device_id', 'timestamp'], 'device_id-timestamp');
$table->index(['priority','level']);
$table->index(['device_id', 'timestamp']);
});
}

View File

@@ -15,8 +15,8 @@ class CreateTnmsneinfoTable extends Migration
{
Schema::create('tnmsneinfo', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('device_id')->index('device_id');
$table->integer('neID')->index('neID');
$table->unsignedInteger('device_id')->index();
$table->integer('neID')->index();
$table->string('neType', 128);
$table->string('neName', 128);
$table->string('neLocation', 128);

View File

@@ -15,7 +15,7 @@ class CreateTonerTable extends Migration
{
Schema::create('toner', function (Blueprint $table) {
$table->increments('toner_id');
$table->unsignedInteger('device_id')->default(0)->index('device_id');
$table->unsignedInteger('device_id')->default(0)->index();
$table->integer('toner_index');
$table->string('toner_type', 64);
$table->string('toner_oid', 64);

View File

@@ -15,7 +15,7 @@ class CreateUcdDiskioTable extends Migration
{
Schema::create('ucd_diskio', function (Blueprint $table) {
$table->increments('diskio_id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->integer('diskio_index');
$table->string('diskio_descr', 32);
});

View File

@@ -25,9 +25,9 @@ class CreateUsersTable extends Migration
$table->tinyInteger('level')->default(0);
$table->boolean('can_modify_passwd')->default(1);
$table->timestamp('created_at')->default('1970-01-02 00:00:01');
$table->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('updated_at')->useCurrent();
$table->string('remember_token', 100)->nullable();
$table->unique(['auth_type', 'username'], 'username');
$table->unique(['auth_type', 'username']);
});
}

View File

@@ -15,9 +15,9 @@ class CreateVminfoTable extends Migration
{
Schema::create('vminfo', function (Blueprint $table) {
$table->increments('id');
$table->unsignedInteger('device_id')->index('device_id');
$table->unsignedInteger('device_id')->index();
$table->string('vm_type', 16)->default('vmware');
$table->integer('vmwVmVMID')->index('vmwVmVMID');
$table->integer('vmwVmVMID')->index();
$table->string('vmwVmDisplayName', 128);
$table->string('vmwVmGuestOS', 128);
$table->integer('vmwVmMemSize');

View File

@@ -15,11 +15,11 @@ class CreateVrfLiteCiscoTable extends Migration
{
Schema::create('vrf_lite_cisco', function (Blueprint $table) {
$table->increments('vrf_lite_cisco_id');
$table->unsignedInteger('device_id')->index('device');
$table->string('context_name', 128)->index('context');
$table->unsignedInteger('device_id')->index();
$table->string('context_name', 128)->index();
$table->string('intance_name', 128)->nullable()->default('');
$table->string('vrf_name', 128)->nullable()->default('Default')->index('vrf');
$table->index(['device_id','context_name','vrf_name'], 'mix');
$table->string('vrf_name', 128)->nullable()->default('Default')->index();
$table->index(['device_id','context_name','vrf_name']);
});
}

View File

@@ -18,8 +18,8 @@ class CreateVrfsTable extends Migration
$table->string('vrf_oid', 256);
$table->string('vrf_name', 128)->nullable();
$table->string('mplsVpnVrfRouteDistinguisher', 128)->nullable();
$table->text('mplsVpnVrfDescription', 65535);
$table->unsignedInteger('device_id')->index('device_id');
$table->text('mplsVpnVrfDescription');
$table->unsignedInteger('device_id')->index();
});
}

View File

@@ -16,7 +16,7 @@ class CreateWidgetsTable extends Migration
Schema::create('widgets', function (Blueprint $table) {
$table->increments('widget_id');
$table->string('widget_title');
$table->string('widget')->unique('widget');
$table->string('widget')->unique();
$table->string('base_dimensions', 10);
});
}

View File

@@ -16,10 +16,10 @@ class CreateWirelessSensorsTable extends Migration
Schema::create('wireless_sensors', function (Blueprint $table) {
$table->increments('sensor_id');
$table->boolean('sensor_deleted')->default(0);
$table->string('sensor_class', 64)->index('sensor_class');
$table->unsignedInteger('device_id')->default(0)->index('sensor_host');
$table->string('sensor_class', 64)->index();
$table->unsignedInteger('device_id')->default(0)->index();
$table->string('sensor_index', 64)->nullable();
$table->string('sensor_type')->index('sensor_type');
$table->string('sensor_type')->index();
$table->string('sensor_descr')->nullable();
$table->integer('sensor_divisor')->default(1);
$table->integer('sensor_multiplier')->default(1);
@@ -34,7 +34,7 @@ class CreateWirelessSensorsTable extends Migration
$table->enum('sensor_custom', ['No', 'Yes'])->default('No');
$table->string('entPhysicalIndex', 16)->nullable();
$table->string('entPhysicalIndex_measured', 16)->nullable();
$table->timestamp('lastupdate')->default(DB::raw('CURRENT_TIMESTAMP'));
$table->timestamp('lastupdate')->useCurrent();
$table->text('sensor_oids');
$table->unsignedInteger('access_point_id')->nullable();
});

View File

@@ -25,8 +25,10 @@ class AddForeignKeysToComponentPrefsTable extends Migration
*/
public function down()
{
Schema::table('component_prefs', function (Blueprint $table) {
$table->dropForeign('component_prefs_ibfk_1');
});
if (\LibreNMS\DB\Eloquent::getDriver() !== 'sqlite') {
Schema::table('component_prefs', function (Blueprint $table) {
$table->dropForeign('component_prefs_ibfk_1');
});
}
}
}

View File

@@ -26,8 +26,10 @@ class AddForeignKeysToComponentStatuslogTable extends Migration
*/
public function down()
{
Schema::table('component_statuslog', function (Blueprint $table) {
$table->dropForeign('component_statuslog_ibfk_1');
});
if (\LibreNMS\DB\Eloquent::getDriver() !== 'sqlite') {
Schema::table('component_statuslog', function (Blueprint $table) {
$table->dropForeign('component_statuslog_ibfk_1');
});
}
}
}

View File

@@ -27,9 +27,11 @@ class AddForeignKeysToDeviceGroupDeviceTable extends Migration
*/
public function down()
{
Schema::table('device_group_device', function (Blueprint $table) {
$table->dropForeign('device_group_device_device_group_id_foreign');
$table->dropForeign('device_group_device_device_id_foreign');
});
if (\LibreNMS\DB\Eloquent::getDriver() !== 'sqlite') {
Schema::table('device_group_device', function (Blueprint $table) {
$table->dropForeign('device_group_device_device_group_id_foreign');
$table->dropForeign('device_group_device_device_id_foreign');
});
}
}
}

View File

@@ -26,9 +26,11 @@ class AddForeignKeysToDeviceRelationshipsTable extends Migration
*/
public function down()
{
Schema::table('device_relationships', function (Blueprint $table) {
$table->dropForeign('device_relationship_child_device_id_fk');
$table->dropForeign('device_relationship_parent_device_id_fk');
});
if (\LibreNMS\DB\Eloquent::getDriver() !== 'sqlite') {
Schema::table('device_relationships', function (Blueprint $table) {
$table->dropForeign('device_relationship_child_device_id_fk');
$table->dropForeign('device_relationship_parent_device_id_fk');
});
}
}
}

View File

@@ -25,8 +25,10 @@ class AddForeignKeysToSensorsTable extends Migration
*/
public function down()
{
Schema::table('sensors', function (Blueprint $table) {
$table->dropForeign('sensors_device_id_foreign');
});
if (\LibreNMS\DB\Eloquent::getDriver() !== 'sqlite') {
Schema::table('sensors', function (Blueprint $table) {
$table->dropForeign('sensors_device_id_foreign');
});
}
}
}

View File

@@ -26,9 +26,11 @@ class AddForeignKeysToSensorsToStateIndexesTable extends Migration
*/
public function down()
{
Schema::table('sensors_to_state_indexes', function (Blueprint $table) {
$table->dropForeign('sensors_to_state_indexes_ibfk_1');
$table->dropForeign('sensors_to_state_indexes_sensor_id_foreign');
});
if (\LibreNMS\DB\Eloquent::getDriver() !== 'sqlite') {
Schema::table('sensors_to_state_indexes', function (Blueprint $table) {
$table->dropForeign('sensors_to_state_indexes_ibfk_1');
$table->dropForeign('sensors_to_state_indexes_sensor_id_foreign');
});
}
}
}

Some files were not shown because too many files have changed in this diff Show More