database migration for kadar anggota koperasi
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateAnggotaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('anggota', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('no_anggota')->unique()->nullable(); // No keahlian
|
||||
$table->string('nama');
|
||||
$table->string('noic')->unique(); // IC wajib unik
|
||||
$table->string('no_tel')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('anggota');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddStatusToAnggotaTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('anggota', function (Blueprint $table) {
|
||||
$table->tinyInteger('status')
|
||||
->default(1)
|
||||
->comment('1 = aktif, 0 = tidak aktif')
|
||||
->after('no_tel');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('anggota', function (Blueprint $table) {
|
||||
//
|
||||
$table->dropColumn('status');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddTagAnggotaToCustomerTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('customer', function (Blueprint $table) {
|
||||
$table->boolean('tag_anggota')->default(0)->after('ahli');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('customer', function (Blueprint $table) {
|
||||
$table->dropColumn('tag_anggota');
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class CreateMohonAnggotaTable extends Migration
|
||||
{
|
||||
// Dapatkan semua sambungan DB aktif (kecuali mysql7 pusat)
|
||||
public function getActiveDB()
|
||||
{
|
||||
$config_db = array_keys(config("database.connections"));
|
||||
|
||||
$db_connection = array_filter($config_db, function($connection) {
|
||||
try {
|
||||
if ($connection == 'mysql7') return false; // skip pusat
|
||||
DB::connection($connection)->getPdo();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return $db_connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Jalankan migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach ($db_connection as $dbase) {
|
||||
if (!Schema::connection($dbase)->hasTable('mohon_anggota')) {
|
||||
Schema::connection($dbase)->create('mohon_anggota', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->date('tarikh')->nullable();
|
||||
$table->string('nokp', 20)->nullable();
|
||||
$table->string('nama', 100)->nullable();
|
||||
$table->string('status', 50)->default('MENUNGGU OPERASI');
|
||||
$table->text('komen')->nullable();
|
||||
$table->string('teller', 100)->nullable();
|
||||
$table->string('peloperasi', 100)->nullable();
|
||||
$table->dateTime('datetime_pelulus')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Undur migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$db_connection = $this->getActiveDB();
|
||||
|
||||
foreach ($db_connection as $dbase) {
|
||||
Schema::connection($dbase)->dropIfExists('mohon_anggota');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user