add migration for users and tabel sistem pakar hihi
This commit is contained in:
parent
2dbadcae35
commit
fe67b688d2
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddUserProfileFieldsToUsersTable extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('username')->unique()->after('id');
|
||||
$table->string('nama')->after('username');
|
||||
$table->string('no_hp')->nullable()->after('email');
|
||||
$table->enum('role', ['admin', 'user'])->default('user')->after('no_hp');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(['username', 'nama', 'no_hp', 'role']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('master_penyakit', function (Blueprint $table) {
|
||||
$table->string('id_penyakit', 10)->primary();
|
||||
$table->string('nama_penyakit', 200);
|
||||
$table->string('nama_latin', 200)->nullable();
|
||||
$table->enum('kategori', ['Hama', 'Penyakit']);
|
||||
|
||||
// Deskripsi
|
||||
$table->text('deskripsi_singkat')->nullable();
|
||||
$table->text('deskripsi_lengkap')->nullable();
|
||||
|
||||
// Pengendalian/Solusi
|
||||
$table->text('pengendalian_pencegahan')->nullable();
|
||||
$table->text('pengendalian_kimia')->nullable();
|
||||
$table->text('pengendalian_organik')->nullable();
|
||||
$table->text('pengendalian_budidaya')->nullable();
|
||||
|
||||
// Metadata
|
||||
$table->enum('tingkat_bahaya', ['Rendah', 'Sedang', 'Tinggi', 'Sangat Tinggi'])->nullable();
|
||||
$table->string('gambar_url', 255)->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('master_penyakit');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('master_gejala', function (Blueprint $table) {
|
||||
$table->string('id_gejala', 10)->primary();
|
||||
$table->text('nama_gejala');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('master_gejala');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('rule_basis', function (Blueprint $table) {
|
||||
$table->id('id_rule');
|
||||
$table->string('id_penyakit', 10);
|
||||
$table->string('id_gejala', 10);
|
||||
$table->decimal('cf_pakar', 3, 2);
|
||||
$table->string('keterangan', 200)->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
// Foreign Keys
|
||||
$table->foreign('id_penyakit')
|
||||
->references('id_penyakit')
|
||||
->on('master_penyakit')
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('id_gejala')
|
||||
->references('id_gejala')
|
||||
->on('master_gejala')
|
||||
->onDelete('cascade');
|
||||
|
||||
// Unique Constraint
|
||||
$table->unique(['id_penyakit', 'id_gejala']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('rule_basis');
|
||||
}
|
||||
};
|
||||
|
|
@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('riwayat_diagnosis', function (Blueprint $table) {
|
||||
$table->id('id_diagnosis');
|
||||
$table->unsignedBigInteger('user_id')->nullable();
|
||||
$table->timestamp('tanggal')->useCurrent();
|
||||
|
||||
// Input & Output (JSON)
|
||||
$table->json('gejala_input')->nullable();
|
||||
$table->json('hasil_diagnosa')->nullable();
|
||||
|
||||
$table->decimal('cf_tertinggi', 3, 2)->nullable();
|
||||
$table->string('penyakit_final', 10)->nullable();
|
||||
|
||||
// Info tambahan
|
||||
$table->string('user_info', 100)->nullable();
|
||||
$table->string('lokasi', 100)->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
// Foreign Keys
|
||||
$table->foreign('user_id')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onDelete('set null');
|
||||
|
||||
$table->foreign('penyakit_final')
|
||||
->references('id_penyakit')
|
||||
->on('master_penyakit')
|
||||
->onDelete('set null');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('riwayat_diagnosis');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('informasi_budidaya', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Konten
|
||||
$table->string('judul', 200);
|
||||
$table->string('slug')->unique();
|
||||
$table->text('deskripsi_singkat')->nullable();
|
||||
$table->longText('konten');
|
||||
|
||||
// Media
|
||||
$table->string('gambar_utama', 255)->nullable();
|
||||
$table->json('galeri_gambar')->nullable();
|
||||
$table->string('file_pdf', 255)->nullable();
|
||||
|
||||
// Kategori/Tag
|
||||
$table->string('kategori', 50)->nullable();
|
||||
$table->json('tags')->nullable();
|
||||
|
||||
// Metadata
|
||||
$table->integer('urutan')->default(0);
|
||||
$table->boolean('is_published')->default(false);
|
||||
$table->timestamp('published_at')->nullable();
|
||||
|
||||
// Author
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
// Foreign Key
|
||||
$table->foreign('created_by')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onDelete('set null');
|
||||
|
||||
// Indexes
|
||||
$table->index('kategori');
|
||||
$table->index('is_published');
|
||||
$table->index('urutan');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('informasi_budidaya');
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('informasi_hama_penyakit', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
// Relasi ke master_penyakit (opsional)
|
||||
$table->string('id_penyakit', 10)->nullable();
|
||||
|
||||
// Konten
|
||||
$table->string('judul', 200);
|
||||
$table->string('slug')->unique();
|
||||
$table->text('deskripsi_singkat')->nullable();
|
||||
$table->longText('konten');
|
||||
|
||||
// Media
|
||||
$table->string('gambar_utama', 255)->nullable();
|
||||
$table->json('galeri_gambar')->nullable();
|
||||
$table->string('file_pdf', 255)->nullable();
|
||||
|
||||
// Kategori
|
||||
$table->enum('jenis', ['Hama', 'Penyakit']);
|
||||
$table->json('tags')->nullable();
|
||||
|
||||
// Info Tambahan Khusus
|
||||
$table->text('gejala_visual')->nullable();
|
||||
$table->text('cara_identifikasi')->nullable();
|
||||
$table->text('pencegahan')->nullable();
|
||||
$table->text('pengendalian')->nullable();
|
||||
|
||||
// Metadata
|
||||
$table->integer('urutan')->default(0);
|
||||
$table->boolean('is_published')->default(false);
|
||||
$table->timestamp('published_at')->nullable();
|
||||
|
||||
// Author
|
||||
$table->unsignedBigInteger('created_by')->nullable();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
// Foreign Keys
|
||||
$table->foreign('id_penyakit')
|
||||
->references('id_penyakit')
|
||||
->on('master_penyakit')
|
||||
->onDelete('set null');
|
||||
|
||||
$table->foreign('created_by')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onDelete('set null');
|
||||
|
||||
// Indexes
|
||||
$table->index('jenis');
|
||||
$table->index('is_published');
|
||||
$table->index('urutan');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('informasi_hama_penyakit');
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue