| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?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
- {
- $sql = "CREATE OR REPLACE VIEW mafs_view AS
-
- SELECT ps.*,
- ov.district_name,
- ov.area_name,
- ov.user_name,
- ov.object_address,
- mo.order_number,
- p.article,
- p.nomenclature_number,
- p.name_tz,
- p.type_tz,
- p.`type`,
- p.manufacturer_name,
- f.original_name as passport_name
- FROM products_sku ps
- LEFT JOIN orders_view ov ON ov.id = ps.order_id
- LEFT JOIN maf_orders mo ON ps.maf_order_id = mo.id
- LEFT JOIN products p ON p.id = ps.product_id
- LEFT JOIN files f ON f.id = ps.passport_id
- ";
- DB::unprepared($sql);
- }
- /**
- * Reverse the migrations.
- */
- public function down(): void
- {
- DB::unprepared("DROP VIEW IF EXISTS mafs_view");
- }
- };
|