feat:가입비(registration_fee) 컬럼 추가 및 시더 업데이트
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('sales_products', function (Blueprint $table) {
|
||||||
|
$table->decimal('registration_fee', 15, 2)->default(0)->after('development_fee')->comment('가입비 (할인된 가격)');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 기존 데이터: 가입비 = 개발비 × 25%
|
||||||
|
DB::statement('UPDATE sales_products SET registration_fee = development_fee * 0.25');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('sales_products', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('registration_fee');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -153,6 +153,7 @@ public function run(): void
|
|||||||
DB::table('sales_products')->insert([
|
DB::table('sales_products')->insert([
|
||||||
'category_id' => $categoryIds['MANUFACTURER'],
|
'category_id' => $categoryIds['MANUFACTURER'],
|
||||||
...$product,
|
...$product,
|
||||||
|
'registration_fee' => $product['development_fee'] * 0.25,
|
||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
@@ -203,6 +204,7 @@ public function run(): void
|
|||||||
DB::table('sales_products')->insert([
|
DB::table('sales_products')->insert([
|
||||||
'category_id' => $categoryIds['CONSTRUCTION'],
|
'category_id' => $categoryIds['CONSTRUCTION'],
|
||||||
...$product,
|
...$product,
|
||||||
|
'registration_fee' => $product['development_fee'] * 0.25,
|
||||||
'is_active' => true,
|
'is_active' => true,
|
||||||
'created_at' => now(),
|
'created_at' => now(),
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
|
|||||||
Reference in New Issue
Block a user