Lae/database/migrations/2023_02_02_000000_create_balances_table.php

40 lines
1.1 KiB
PHP
Raw Normal View History

2022-09-01 09:48:29 +00:00
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
2023-01-30 16:14:07 +00:00
return new class extends Migration
{
2022-09-01 09:48:29 +00:00
/**
* Run the migrations.
*
* @return void
*/
2023-01-14 10:02:27 +00:00
public function up(): void
2022-09-01 09:48:29 +00:00
{
Schema::create('balances', function (Blueprint $table) {
$table->id();
$table->string('order_id')->nullable()->index();
$table->string('trade_id')->nullable()->index();
$table->string('payment')->nullable()->index();
2022-12-11 11:47:30 +00:00
$table->decimal('amount', 10)->default(0);
2023-02-02 12:11:41 +00:00
$table->decimal('remaining_amount', 10)->default(0);
2022-09-01 09:48:29 +00:00
$table->timestamp('paid_at')->nullable();
$table->unsignedBigInteger('user_id')->nullable()->index();
2023-02-02 12:11:41 +00:00
$table->foreign(['user_id'])->references(['id'])->on('users')->onUpdate('NO ACTION')->onDelete('NO ACTION');
2023-02-02 12:16:06 +00:00
$table->timestamps();
2022-09-01 09:48:29 +00:00
});
}
/**
* Reverse the migrations.
*
* @return void
*/
2023-01-14 10:02:27 +00:00
public function down(): void
2022-09-01 09:48:29 +00:00
{
Schema::dropIfExists('balances');
}
};