1
0

Update Database dan ALL yang di butuhkan

This commit is contained in:
Wian Drs
2026-06-19 14:35:42 +07:00
parent 5be2c5fbfe
commit 2f805a233d
9469 changed files with 1159473 additions and 25 deletions
@@ -0,0 +1,31 @@
<?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::create('ticket_types', function (Blueprint $table) {
$table->id();
$table->string('code', 50)->unique();
$table->string('name', 100);
$table->boolean('need_approval')->default(false);
$table->integer('sla_minutes')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ticket_types');
}
};
@@ -0,0 +1,42 @@
<?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::create('ticket_logs', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('ticket_id');
$table->unsignedBigInteger('user_id');
$table->string('activity');
$table->text('notes')->nullable();
$table->decimal('latitude', 10, 8)->nullable();
$table->decimal('longitude', 11, 8)->nullable();
$table->timestamp('created_at')->nullable();
$table->index('ticket_id');
$table->index('user_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ticket_logs');
}
};
@@ -0,0 +1,75 @@
<?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::create('tickets', function (Blueprint $table) {
$table->id();
$table->string('ticket_no', 50)->unique();
$table->unsignedBigInteger('ticket_type_id');
$table->unsignedBigInteger('tenant_id')->default(1);
$table->unsignedBigInteger('customer_id')->nullable();
$table->string('title');
$table->text('description')->nullable();
$table->enum('priority', [
'low',
'medium',
'high',
'critical'
])->default('medium');
$table->enum('status', [
'draft',
'open',
'approved',
'assigned',
'progress',
'pending',
'resolved',
'closed',
'cancelled',
'rejected'
])->default('draft');
$table->integer('sla_minutes')->nullable();
$table->unsignedBigInteger('created_by');
$table->unsignedBigInteger('approved_by')->nullable();
$table->timestamp('approved_at')->nullable();
$table->unsignedBigInteger('rejected_by')->nullable();
$table->timestamp('rejected_at')->nullable();
$table->text('rejection_reason')->nullable();
$table->timestamp('assigned_at')->nullable();
$table->timestamp('resolved_at')->nullable();
$table->timestamp('closed_at')->nullable();
$table->timestamps();
$table->index('ticket_no');
$table->index('ticket_type_id');
$table->index('tenant_id');
$table->index('customer_id');
$table->index('status');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tickets');
}
};
@@ -0,0 +1,46 @@
<?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::create('ticket_approvals', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('ticket_id');
$table->unsignedBigInteger('approver_id');
$table->enum('status', [
'pending',
'approved',
'rejected'
])->default('pending');
$table->text('notes')->nullable();
$table->timestamp('approved_at')->nullable();
$table->timestamp('created_at')->nullable();
$table->index('ticket_id');
$table->index('approver_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ticket_approvals');
}
};
@@ -0,0 +1,47 @@
<?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::create('ticket_assignments', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('ticket_id');
$table->unsignedBigInteger('user_id');
$table->boolean('is_leader')->default(false);
$table->unsignedBigInteger('assigned_by');
$table->timestamp('assigned_at')->nullable();
$table->enum('status', [
'assigned',
'accepted',
'rejected',
'completed'
])->default('assigned');
$table->index('ticket_id');
$table->index('user_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ticket_assignments');
}
};
@@ -0,0 +1,45 @@
<?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::create('ticket_files', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('ticket_id');
$table->unsignedBigInteger('ticket_log_id')->nullable();
$table->string('file_name');
$table->string('file_path', 500);
$table->bigInteger('file_size')->nullable();
$table->string('file_type', 100)->nullable();
$table->unsignedBigInteger('uploaded_by');
$table->timestamp('created_at')->nullable();
$table->index('ticket_id');
$table->index('ticket_log_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ticket_files');
}
};
@@ -0,0 +1,45 @@
<?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::create('ticket_materials', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('ticket_id');
$table->unsignedBigInteger('ticket_log_id')->nullable();
$table->string('material_name');
$table->decimal('qty', 12, 2);
$table->text('notes')->nullable();
$table->unsignedBigInteger('used_by');
$table->timestamp('created_at')->nullable();
$table->index('ticket_id');
$table->index('ticket_log_id');
$table->index('used_by');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ticket_materials');
}
};