<?php

declare(strict_types=1);

use App\Support\DberpDocumentQueryViewDefinition;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

/**
 * 单据综合查询视图（SQL 与 {@see DberpDocumentQueryViewDefinition} 保持一致）。
 *
 * 须在采购申请明细、销售报价、结算核销/对账/调整及库存 base_quantity、采购 requested_warehouse_id 等结构就绪后执行。
 */
return new class extends Migration
{
    public function up(): void
    {
        DB::statement('DROP VIEW IF EXISTS dberp_document_queries');
        DB::statement(DberpDocumentQueryViewDefinition::sql());
    }

    public function down(): void
    {
        DB::statement('DROP VIEW IF EXISTS dberp_document_queries');
    }
};
