<?php
require __DIR__ . '/../bootstrap.php';

use Gestoreasy\Core\Tenant\ConnectionManager;

$tenant = $argv[1] ?? 'default';
$table = $argv[2] ?? null;
$column = $argv[3] ?? 'id';
if (!$table) { fwrite(STDERR, "Usage: php scripts/column_type.php <tenant> <table> [column]\n"); exit(1); }

$pdo = ConnectionManager::forTenant($tenant);
$sql = "SELECT COLUMN_TYPE, COLUMN_KEY, IS_NULLABLE FROM information_schema.columns WHERE table_schema = DATABASE() AND table_name = ? AND column_name = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$table, $column]);
$row = $stmt->fetch() ?: [];
echo json_encode($row, JSON_UNESCAPED_UNICODE) . "\n";