Files
website/scripts/set-admin.ts
Stan Runge 4cfe6bad6c app: lists on meta tables, schema-qualified SQL, typed columns
- lists read/write real lists.* tables via meta.tables/meta.columns and the
  SECURITY DEFINER meta functions; typed extra columns in the item forms
- old numeric list URLs 308-redirect to the slug
- include_recurring is boolean, osu accuracy/pp/rate numeric
- raw SQL qualified with the new schemas
2026-10-23 22:03:42 +00:00

16 lines
638 B
TypeScript

import postgres from 'postgres';
const [userId, role = 'admin'] = process.argv.slice(2);
if (!userId || !['admin', 'user'].includes(role))
throw new Error('Usage: bun scripts/set-admin.ts <user-id> [admin|user]');
if (!process.env.DB_URL) throw new Error('DB_URL is required');
const sql = postgres(process.env.DB_URL, { max: 1 });
try {
const users =
await sql`update auth."user" set role = ${role}, updated_at = now() where id = ${userId} returning id, role`;
if (!users.length)
throw new Error('User ID not found. Register first and copy the ID from your account page.');
console.log(users[0]);
} finally {
await sql.end();
}