fix(migration): rename-admin-email crashes — neon() returns array, not { rows } #24

Merged
varutasu merged 1 commit from fix/migration-neon-return-shape into main 2026-05-25 12:30:10 -04:00
Showing only changes of commit 98406fafbe - Show all commits

View file

@ -34,7 +34,11 @@ async function main() {
const sql = neon(process.env.POSTGRES_URL);
const { rows: before } = await sql`
// NOTE: @neondatabase/serverless's tagged-template returns the rows array
// directly — NOT wrapped in { rows, rowCount } like @vercel/postgres does.
// See lib/database.js line 33 for the same finding. Do NOT destructure
// `{ rows: x }` from a `neon()` result; assign the result directly.
const before = await sql`
SELECT id, email, role
FROM users
WHERE email LIKE '%@tcgvault.com'
@ -58,7 +62,7 @@ async function main() {
WHERE email LIKE '%@tcgvault.com'
`;
const { rows: after } = await sql`
const after = await sql`
SELECT id, email, role
FROM users
WHERE email LIKE '%@deckhearth.com'
@ -70,7 +74,7 @@ async function main() {
console.log(` id=${r.id} role=${r.role} email=${r.email}`);
}
const { rows: stragglers } = await sql`
const stragglers = await sql`
SELECT COUNT(*)::int AS count FROM users WHERE email LIKE '%@tcgvault.com'
`;
if (stragglers[0].count !== 0) {