#!/usr/bin/env tsx
import { createClient } from '@libsql/client';
import { config } from 'dotenv';

config();

const db = createClient({
  url: process.env.TURSO_URL!,
  authToken: process.env.TURSO_AUTH_TOKEN!,
});

async function checkSchema() {
  console.log('\n📊 Users table schema:\n');

  const columns = await db.execute(`SELECT * FROM pragma_table_info('users')`);
  columns.rows.forEach(col => {
    const row = col as any;
    console.log(`  ${row.name}: ${row.type} ${row.notnull ? 'NOT NULL' : 'NULL'} ${row.dflt_value ? `DEFAULT ${row.dflt_value}` : ''}`);
  });

  console.log('\n📊 Users indexes:\n');
  const indexes = await db.execute(`
    SELECT name FROM sqlite_master
    WHERE type='index' AND tbl_name='users'
    ORDER BY name
  `);
  indexes.rows.forEach(idx => console.log(`  - ${(idx as any).name}`));

  console.log('\n');
}

checkSchema().catch(console.error);
