mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +00:00
Updated bill_data table, alter indexes and add new column (#15751)
* Updated bill_data table, alter indexes and add new column * Added missing < * Removed first * Moved column in bill_data * Updated schmea changes * Updated schmea * Updated migration * Use id alias * index after and only index * Update and rename 2024_01_09_223917_bill_data_new_column.php to 2024_01_09_223917_bill_data_new_primary.php * Trying these schema changes * Another go * And another * Debugging * Revert change * Revert changes + debugging * Updated schemas again * Trying to rename column name * Updated db_schema.yaml * renamed column back to id * Added debugging * Added debugging * Added debugging * Added debugging * Added debugging * Remove redundant primary id * Remove var_dump * Remove var_dump * I swear --------- Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
parent
0b8413ed96
commit
7325995954
@ -13,13 +13,13 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('bill_data', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->unsignedInteger('bill_id')->index();
|
||||
$table->dateTime('timestamp');
|
||||
$table->integer('period');
|
||||
$table->bigInteger('delta');
|
||||
$table->bigInteger('in_delta');
|
||||
$table->bigInteger('out_delta');
|
||||
$table->primary(['bill_id', 'timestamp']);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasColumn('bill_data', 'id')) {
|
||||
Schema::table('bill_data', function (Blueprint $table) {
|
||||
$table->dropPrimary(['bill_id', 'timestamp']);
|
||||
});
|
||||
|
||||
Schema::table('bill_data', function (Blueprint $table) {
|
||||
$table->id()->first();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('bill_data', function (Blueprint $table) {
|
||||
$table->dropColumn('id');
|
||||
});
|
||||
|
||||
Schema::table('bill_data', function (Blueprint $table) {
|
||||
$table->primary(['bill_id', 'timestamp']);
|
||||
});
|
||||
}
|
||||
};
|
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('bill_data', function (Blueprint $table) {
|
||||
$table->index(['bill_id', 'timestamp']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('bill_data', function (Blueprint $table) {
|
||||
$table->dropIndex(['bill_id', 'timestamp']);
|
||||
});
|
||||
}
|
||||
};
|
@ -374,13 +374,14 @@ DROP TABLE IF EXISTS `bill_data`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `bill_data` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`bill_id` int(10) unsigned NOT NULL,
|
||||
`timestamp` datetime NOT NULL,
|
||||
`period` int(11) NOT NULL,
|
||||
`delta` bigint(20) NOT NULL,
|
||||
`in_delta` bigint(20) NOT NULL,
|
||||
`in_delta` bigint(20) NOT NULL,
|
||||
`out_delta` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`bill_id`,`timestamp`),
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `bill_data_bill_id_index` (`bill_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
@ -374,13 +374,14 @@ DROP TABLE IF EXISTS `bill_data`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!50503 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `bill_data` (
|
||||
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`bill_id` int(10) unsigned NOT NULL,
|
||||
`timestamp` datetime NOT NULL,
|
||||
`period` int(11) NOT NULL,
|
||||
`delta` bigint(20) NOT NULL,
|
||||
`in_delta` bigint(20) NOT NULL,
|
||||
`out_delta` bigint(20) NOT NULL,
|
||||
PRIMARY KEY (`bill_id`,`timestamp`),
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `bill_data_bill_id_index` (`bill_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
@ -33,7 +33,7 @@ CREATE UNIQUE INDEX "bgppeers_cbgp_device_id_bgppeeridentifier_afi_safi_unique"
|
||||
CREATE INDEX "bgppeers_cbgp_device_id_bgppeeridentifier_context_name_index" on "bgpPeers_cbgp" ("device_id", "bgpPeerIdentifier", "context_name");
|
||||
CREATE TABLE IF NOT EXISTS "bgpPeers" ("bgpPeer_id" integer primary key autoincrement not null, "device_id" integer not null, "astext" varchar not null, "bgpPeerIdentifier" text not null, "bgpPeerRemoteAs" integer not null, "bgpPeerState" text not null, "bgpPeerAdminStatus" text not null, "bgpLocalAddr" text not null, "bgpPeerRemoteAddr" text not null, "bgpPeerDescr" varchar not null default '', "bgpPeerInUpdates" integer not null, "bgpPeerOutUpdates" integer not null, "bgpPeerInTotalMessages" integer not null, "bgpPeerOutTotalMessages" integer not null, "bgpPeerFsmEstablishedTime" integer not null, "bgpPeerInUpdateElapsedTime" integer not null, "context_name" varchar, "vrf_id" integer, "bgpPeerLastErrorCode" integer, "bgpPeerLastErrorSubCode" integer, "bgpPeerLastErrorText" varchar, "bgpPeerIface" integer);
|
||||
CREATE INDEX "bgppeers_device_id_context_name_index" on "bgpPeers" ("device_id", "context_name");
|
||||
CREATE TABLE IF NOT EXISTS "bill_data" ("bill_id" integer not null, "timestamp" datetime not null, "period" integer not null, "delta" integer not null, "in_delta" integer not null, "out_delta" integer not null, primary key ("bill_id", "timestamp"));
|
||||
CREATE TABLE IF NOT EXISTS "bill_data" ("id" integer primary key autoincrement not null, "bill_id" integer not null, "timestamp" datetime not null, "period" integer not null, "delta" integer not null, "in_delta" integer not null, "out_delta" integer not null);
|
||||
CREATE INDEX "bill_data_bill_id_index" on "bill_data" ("bill_id");
|
||||
CREATE TABLE IF NOT EXISTS "bill_history" ("bill_hist_id" integer primary key autoincrement not null, "bill_id" integer not null, "updated" datetime not null default CURRENT_TIMESTAMP, "bill_datefrom" datetime not null, "bill_dateto" datetime not null, "bill_type" text not null, "bill_allowed" integer not null, "bill_used" integer not null, "bill_overuse" integer not null, "bill_percent" numeric not null, "rate_95th_in" integer not null, "rate_95th_out" integer not null, "rate_95th" integer not null, "dir_95th" varchar not null, "rate_average" integer not null, "rate_average_in" integer not null, "rate_average_out" integer not null, "traf_in" integer not null, "traf_out" integer not null, "traf_total" integer not null, "pdf" blob, "bill_peak_out" integer, "bill_peak_in" integer);
|
||||
CREATE UNIQUE INDEX "bill_history_bill_id_bill_datefrom_bill_dateto_unique" on "bill_history" ("bill_id", "bill_datefrom", "bill_dateto");
|
||||
|
@ -319,6 +319,7 @@ bills:
|
||||
PRIMARY: { Name: PRIMARY, Columns: [bill_id], Unique: true, Type: BTREE }
|
||||
bill_data:
|
||||
Columns:
|
||||
- { Field: id, Type: 'bigint unsigned', 'Null': false, Extra: auto_increment }
|
||||
- { Field: bill_id, Type: 'int unsigned', 'Null': false, Extra: '' }
|
||||
- { Field: timestamp, Type: datetime, 'Null': false, Extra: '' }
|
||||
- { Field: period, Type: int, 'Null': false, Extra: '' }
|
||||
@ -326,8 +327,9 @@ bill_data:
|
||||
- { Field: in_delta, Type: bigint, 'Null': false, Extra: '' }
|
||||
- { Field: out_delta, Type: bigint, 'Null': false, Extra: '' }
|
||||
Indexes:
|
||||
PRIMARY: { Name: PRIMARY, Columns: [bill_id, timestamp], Unique: true, Type: BTREE }
|
||||
PRIMARY: { Name: PRIMARY, Columns: [id], Unique: true, Type: BTREE }
|
||||
bill_data_bill_id_index: { Name: bill_data_bill_id_index, Columns: [bill_id], Unique: false, Type: BTREE }
|
||||
bill_data_bill_id_timestamp_index: { Name: bill_data_bill_id_timestamp_index, Columns: [bill_id, timestamp], Unique: false, Type: BTREE }
|
||||
bill_history:
|
||||
Columns:
|
||||
- { Field: bill_hist_id, Type: 'int unsigned', 'Null': false, Extra: auto_increment }
|
||||
|
Loading…
Reference in New Issue
Block a user