Update and fix broadband traffic
This commit is contained in:
@@ -266,6 +266,8 @@ class RenameServiceTables extends Migration
|
||||
DB::statement('ALTER TABLE service_broadband MODIFY service_id int unsigned NOT NULL');
|
||||
DB::statement('ALTER TABLE service_broadband MODIFY service_stats_collect tinyint(1) DEFAULT NULL');
|
||||
DB::statement('ALTER TABLE service_broadband RENAME COLUMN service_stats_lastupdate TO service_stats_at');
|
||||
DB::statement('ALTER TABLE service_broadband RENAME COLUMN provided_adsl_plan_id TO provided_supplier_broadband_id');
|
||||
DB::statement('ALTER TABLE service_broadband MODIFY provided_supplier_broadband_id int unsigned DEFAULT NULL');
|
||||
// @todo drop column provided_adsl_plan_id
|
||||
|
||||
Schema::table('service_broadband', function (Blueprint $table) {
|
||||
@@ -281,6 +283,7 @@ class RenameServiceTables extends Migration
|
||||
$table->dropIndex('ab_service__adsl_id_site_id_index');
|
||||
|
||||
$table->foreign(['service_id','site_id'])->references(['id','site_id'])->on('services');
|
||||
$table->foreign(['provided_supplier_broadband_id','site_id'])->references(['id','site_id'])->on('supplier_broadband');
|
||||
});
|
||||
|
||||
// Convert our dates
|
||||
|
42
database/migrations/2022_04_20_134953_rename_traffic.php
Normal file
42
database/migrations/2022_04_20_134953_rename_traffic.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class RenameTraffic extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
DB::statement('ALTER TABLE ab_service__adsl_traffic RENAME TO usage_broadband');
|
||||
DB::statement('ALTER TABLE usage_broadband RENAME COLUMN ab_service_adsl_id TO service_item_id');
|
||||
DB::statement('ALTER TABLE usage_broadband MODIFY supplier_id int unsigned NOT NULL'); // @todo This should be deleted, it could be obtained by the product
|
||||
DB::statement('ALTER TABLE usage_broadband MODIFY service_item_id int unsigned DEFAULT NULL');
|
||||
DB::statement('ALTER TABLE usage_broadband MODIFY site_id int unsigned NOT NULL');
|
||||
|
||||
Schema::table('usage_broadband', function (Blueprint $table) {
|
||||
$table->unique(['service_item_id','site_id','date','time']);
|
||||
$table->foreign(['service_item_id','site_id'])->references(['id','site_id'])->on('service_broadband');
|
||||
$table->foreign(['supplier_id'])->references(['id'])->on('suppliers');
|
||||
});
|
||||
|
||||
Schema::table('suppliers', function (Blueprint $table) {
|
||||
$table->date('usage_last')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
abort(500,'Cant go back');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user