repuve-backend-v1/database/migrations/2025_12_04_094140_modify_package_table.php

38 lines
1.1 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('packages', function (Blueprint $table) {
$table->dropForeign(['module_id']);
$table->dropColumn(['box_number', 'starting_page', 'ending_page', 'module_id']);
$table->integer('total_boxes')->after('lot')->default(0);
$table->string('description')->after('total_boxes')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('packages', function (Blueprint $table) {
$table->string('box_number')->after('lot');
$table->integer('starting_page')->after('box_number');
$table->integer('ending_page')->after('starting_page');
$table->foreignId('module_id')->after('ending_page')
->constrained('modules')
->cascadeOnDelete();
});
}
};