change transition structure 2

This commit is contained in:
2026-07-10 23:29:36 +03:30
parent 028c5d5938
commit 47a2f8e6bf
7 changed files with 226 additions and 1 deletions
@@ -0,0 +1,35 @@
<?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
{
if (!Schema::hasTable('orders')) {
return;
}
Schema::table('orders', function (Blueprint $table) {
if (!Schema::hasColumn('orders', 'fee_asset')) {
// سمت کسر کارمزد: 'gold' یعنی از طلا کسر شده، 'rial' یعنی از ریال.
$table->string('fee_asset', 8)->nullable()->after('service_charge_price');
}
});
}
public function down(): void
{
if (!Schema::hasTable('orders')) {
return;
}
Schema::table('orders', function (Blueprint $table) {
if (Schema::hasColumn('orders', 'fee_asset')) {
$table->dropColumn('fee_asset');
}
});
}
};
@@ -0,0 +1,33 @@
<?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
{
if (Schema::hasTable('profit_conversions')) {
return;
}
Schema::create('profit_conversions', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id')->nullable();
$table->decimal('rial_amount', 20, 0)->default(0); // مبلغ ریالی سود که تبدیل شد
$table->decimal('gram_amount', 16, 4)->default(0); // معادل طلا (گرم)
$table->decimal('unit_price', 20, 0)->default(0); // مظنه/قیمت هر گرم هنگام تبدیل
$table->dateTime('converted_at')->nullable(); // تاریخ سند
$table->string('description', 500)->nullable();
$table->timestamps();
$table->index('converted_at');
});
}
public function down(): void
{
Schema::dropIfExists('profit_conversions');
}
};