<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class LinkTailoringOrdersToSales extends Migration
{
    public function up()
    {
        Schema::table('sales', function (Blueprint $table) {
            $table->string('sale_type', 30)->default('product')->after('reference_no');
            $table->unsignedInteger('tailoring_product_id')->nullable()->unique()->after('sale_type');
            $table->decimal('service_charge', 18, 4)->default(0)->after('total_price');
        });
    }

    public function down()
    {
        Schema::table('sales', function (Blueprint $table) {
            $table->dropUnique(['tailoring_product_id']);
            $table->dropColumn(['sale_type', 'tailoring_product_id', 'service_charge']);
        });
    }
}
