diff --git a/database/migrations/2026_02_05_093000_add_mng_columns_to_purchases_table.php b/database/migrations/2026_02_05_093000_add_mng_columns_to_purchases_table.php new file mode 100644 index 0000000..3b55e36 --- /dev/null +++ b/database/migrations/2026_02_05_093000_add_mng_columns_to_purchases_table.php @@ -0,0 +1,49 @@ +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); + } + } + }); + } +};