Files
portal-api/database/migrations/2024_01_31_145201_customer.php
2026-09-09 16:56:22 +07:00

69 lines
2.6 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
Schema::create('customers', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('fullname', 255)->nullable();
$table->foreignId('saler')->nullable()->constrained('user')->nullOnDelete();
$table->string('avatar', 100)->nullable();
$table->integer('gender')->default(0);
$table->string('address', 100)->nullable();
$table->string('state', 100)->nullable();
$table->string('city', 100)->nullable();
$table->integer('postcode')->nullable();
$table->string('country', 100)->nullable();
$table->string('company', 100)->nullable();
$table->string('phone', 100)->unique()->nullable();
$table->string('email', 100)->unique()->nullable();
$table->string('email_verify', 100)->nullable();
$table->string('email_hash', 100)->nullable();
$table->tinyInteger('email_marketing')->default(1);
$table->tinyInteger('receive_deposit')->default(1);
$table->string('password')->nullable();
$table->integer('credit')->default(0);
$table->integer('unpaid_total')->default(0);
$table->integer('total')->default(0);
$table->string('identity_number')->nullable();
$table->string('front_identity_number')->nullable();
$table->string('back_identity_number')->nullable();
$table->string('province_code', 20)->nullable();
$table->string('ward_code', 20)->nullable();
$table->string('remember_token', 100)->nullable();
$table->tinyInteger('status')->default(0)->comment('1: Active, 0: InActive');
$table->timestamps();
$table->softDeletes();
$table->foreign('province_code')->references('code')->on('provinces')->onDelete('set null');
$table->foreign('ward_code')->references('code')->on('wards')->onDelete('set null');
$table->index('province_code', 'idx_users_province');
$table->index('ward_code', 'idx_users_ward');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::dropIfExists('customers');
}
};