Skip to content

Commit

Permalink
schema: add missing primary keys (librenms#12106)
Browse files Browse the repository at this point in the history
* schema: add missing primary keys

* Exclude ipv4_mac.id

* Made primary key migrations SQLite compatible

Co-authored-by: Tony Murray <[email protected]>
  • Loading branch information
rkojedzinszky and murrant authored Oct 15, 2020
1 parent 3bfafc8 commit 2ca6f2f
Show file tree
Hide file tree
Showing 22 changed files with 405 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreateBillPermsTable extends Migration
public function up()
{
Schema::create('bill_perms', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('user_id');
$table->unsignedInteger('bill_id');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreateBillPortsTable extends Migration
public function up()
{
Schema::create('bill_ports', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('bill_id');
$table->unsignedInteger('port_id');
$table->boolean('bill_port_autoadded')->default(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreateDevicesPermsTable extends Migration
public function up()
{
Schema::create('devices_perms', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('user_id')->index();
$table->unsignedInteger('device_id');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreateEntPhysicalStateTable extends Migration
public function up()
{
Schema::create('entPhysical_state', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('device_id');
$table->string('entPhysicalIndex', 64);
$table->string('subindex', 64)->nullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreateIpv4MacTable extends Migration
public function up()
{
Schema::create('ipv4_mac', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('port_id')->index();
$table->unsignedInteger('device_id')->nullable();
$table->string('mac_address', 32)->index();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreateJuniAtmVpTable extends Migration
public function up()
{
Schema::create('juniAtmVp', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('juniAtmVp_id');
$table->unsignedInteger('port_id')->index();
$table->unsignedInteger('vp_id');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreateLoadbalancerVserversTable extends Migration
public function up()
{
Schema::create('loadbalancer_vservers', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('classmap_id');
$table->string('classmap', 128);
$table->string('serverstate', 64);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreatePortsPermsTable extends Migration
public function up()
{
Schema::create('ports_perms', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('user_id');
$table->unsignedInteger('port_id');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CreateProcessesTable extends Migration
public function up()
{
Schema::create('processes', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('device_id')->index();
$table->integer('pid');
$table->integer('vsz');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class CreateTransportGroupTransportTable extends Migration
public function up()
{
Schema::create('transport_group_transport', function (Blueprint $table) {
$table->id();
$table->unsignedInteger('transport_group_id');
$table->unsignedInteger('transport_id');
});
Expand Down
37 changes: 37 additions & 0 deletions database/migrations/2020_10_03_1000_add_primary_key_bill_perms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
This migration adds primary key for table bill_perms.
Percona Xtradb refuses to modify a table
without a primary key.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class AddPrimaryKeyBillPerms extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (! Schema::hasColumn('bill_perms', 'id')) {
Schema::table('bill_perms', function (Blueprint $table) {
$table->id()->first();
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}
37 changes: 37 additions & 0 deletions database/migrations/2020_10_03_1000_add_primary_key_bill_ports.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
This migration adds primary key for table bill_ports.
Percona Xtradb refuses to modify a table
without a primary key.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class AddPrimaryKeyBillPorts extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (! Schema::hasColumn('bill_ports', 'id')) {
Schema::table('bill_ports', function (Blueprint $table) {
$table->id()->first();
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
This migration adds primary key for table devices_perms.
Percona Xtradb refuses to modify a table
without a primary key.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class AddPrimaryKeyDevicesPerms extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (! Schema::hasColumn('devices_perms', 'id')) {
Schema::table('devices_perms', function (Blueprint $table) {
$table->id()->first();
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
This migration adds primary key for table entPhysical_state.
Percona Xtradb refuses to modify a table
without a primary key.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class AddPrimaryKeyEntphysicalState extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (! Schema::hasColumn('entPhysical_state', 'id')) {
Schema::table('entPhysical_state', function (Blueprint $table) {
$table->id()->first();
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}
37 changes: 37 additions & 0 deletions database/migrations/2020_10_03_1000_add_primary_key_ipv4_mac.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
This migration adds primary key for table ipv4_mac.
Percona Xtradb refuses to modify a table
without a primary key.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class AddPrimaryKeyIpv4Mac extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (! Schema::hasColumn('ipv4_mac', 'id')) {
Schema::table('ipv4_mac', function (Blueprint $table) {
$table->id()->first();
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}
37 changes: 37 additions & 0 deletions database/migrations/2020_10_03_1000_add_primary_key_juniAtmVp.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
This migration adds primary key for table juniAtmVp.
Percona Xtradb refuses to modify a table
without a primary key.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class AddPrimaryKeyJuniatmvp extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (! Schema::hasColumn('juniAtmVp', 'id')) {
Schema::table('juniAtmVp', function (Blueprint $table) {
$table->id()->first();
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
This migration adds primary key for table loadbalancer_vservers.
Percona Xtradb refuses to modify a table
without a primary key.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class AddPrimaryKeyLoadbalancerVservers extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (! Schema::hasColumn('loadbalancer_vservers', 'id')) {
Schema::table('loadbalancer_vservers', function (Blueprint $table) {
$table->id()->first();
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

/*
This migration adds primary key for table ports_perms.
Percona Xtradb refuses to modify a table
without a primary key.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class AddPrimaryKeyPortsPerms extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (! Schema::hasColumn('ports_perms', 'id')) {
Schema::table('ports_perms', function (Blueprint $table) {
$table->id()->first();
});
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}
Loading

0 comments on commit 2ca6f2f

Please sign in to comment.