<?php
require 'vendor/autoload.php';
$app = require 'bootstrap/app.php';
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();

echo "=== COLUMNS ===\n";
$cols = DB::select("SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = 'orders_override' AND table_schema = 'public' ORDER BY ordinal_position");
foreach ($cols as $c) {
    echo $c->column_name . ' | ' . $c->data_type . ' | nullable:' . $c->is_nullable . "\n";
}

echo "\n=== CONSTRAINTS ===\n";
$constrs = DB::select("SELECT constraint_name, constraint_type FROM information_schema.table_constraints WHERE table_name = 'orders_override' AND table_schema = 'public'");
foreach ($constrs as $c) {
    echo $c->constraint_name . ' | ' . $c->constraint_type . "\n";
}

echo "\n=== FOREIGN KEY DETAILS ===\n";
$fk = DB::select("SELECT kcu.column_name, ccu.table_name AS foreign_table, ccu.column_name AS foreign_column FROM information_schema.key_column_usage kcu JOIN information_schema.referential_constraints rc ON kcu.constraint_name = rc.constraint_name JOIN information_schema.key_column_usage ccu ON rc.unique_constraint_name = ccu.constraint_name WHERE kcu.table_name = 'orders_override' AND kcu.table_schema = 'public'");
foreach ($fk as $r) {
    echo $r->column_name . ' => ' . $r->foreign_table . '.' . $r->foreign_column . "\n";
}

echo "\n=== CURRENT ADMIN USER ID ===\n";
$adminId = \Illuminate\Support\Facades\Auth::guard('admin')->id();
echo "Auth::guard('admin')->id() = " . var_export($adminId, true) . "\n";
