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

use Illuminate\Support\Facades\DB;

// Which team does the user's dashboard default to?
$user = DB::table('users')->where('email', 'admin@csc-eifelgreen.org')->first();
echo "USER id:{$user->id} name:{$user->name}\n";

// team_user pivot
$tu = DB::select("SELECT * FROM team_user WHERE user_id = {$user->id}");
foreach ($tu as $t) {
    echo "PIVOT team_id:{$t->team_id} role:{$t->role}\n";
}

// Check users table for current_team_id column
$cols = DB::select("SELECT column_name FROM information_schema.columns WHERE table_name='users'");
$current = array_filter($cols, fn($c) => str_contains($c->column_name, 'team'));
foreach ($current as $c) echo "USER COL: {$c->column_name}\n";

// projects and apps team
echo "PROJECT team_id: ";
$p = DB::table('projects')->where('uuid', 'thuyxeybqpsqybkh6ggfsand')->first();
echo "{$p->team_id}\n";

echo "APP team (via project): ";
echo "{$p->team_id}\n";
