Update and fix broadband traffic

This commit is contained in:
Deon George
2022-04-20 16:24:58 +10:00
parent 621a132e35
commit 16b7e0b493
13 changed files with 161 additions and 112 deletions

View 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');
}
}