feat:purchases 테이블에 MNG용 컬럼 추가 마이그레이션

- date, vendor, item, category, amount, vat, invoice_no, memo 컬럼 추가
- MNG 매입관리 페이지 500 에러 수정용

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
김보곤
2026-02-05 09:35:04 +09:00
parent 2b5ac4c54d
commit 9626bca7eb

View File

@@ -0,0 +1,49 @@
<?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
{
Schema::table('purchases', function (Blueprint $table) {
if (!Schema::hasColumn('purchases', 'date')) {
$table->date('date')->nullable()->after('purchase_date')->comment('매입일(MNG용)');
}
if (!Schema::hasColumn('purchases', 'vendor')) {
$table->string('vendor', 100)->nullable()->after('date')->comment('공급자명(MNG용)');
}
if (!Schema::hasColumn('purchases', 'item')) {
$table->string('item', 200)->nullable()->after('vendor')->comment('품목명(MNG용)');
}
if (!Schema::hasColumn('purchases', 'category')) {
$table->string('category', 50)->default('운영비')->after('item')->comment('분류(MNG용)');
}
if (!Schema::hasColumn('purchases', 'amount')) {
$table->bigInteger('amount')->default(0)->after('category')->comment('금액(MNG용)');
}
if (!Schema::hasColumn('purchases', 'vat')) {
$table->bigInteger('vat')->default(0)->after('amount')->comment('부가세(MNG용)');
}
if (!Schema::hasColumn('purchases', 'invoice_no')) {
$table->string('invoice_no', 50)->nullable()->after('vat')->comment('인보이스번호(MNG용)');
}
if (!Schema::hasColumn('purchases', 'memo')) {
$table->text('memo')->nullable()->after('invoice_no')->comment('메모(MNG용)');
}
});
}
public function down(): void
{
Schema::table('purchases', function (Blueprint $table) {
$columns = ['date', 'vendor', 'item', 'category', 'amount', 'vat', 'invoice_no', 'memo'];
foreach ($columns as $col) {
if (Schema::hasColumn('purchases', $col)) {
$table->dropColumn($col);
}
}
});
}
};