fix(migration): rename-admin-email crashes — neon() returns array, not { rows } #24
1 changed files with 7 additions and 3 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue