19 lines
642 B
JavaScript
19 lines
642 B
JavaScript
const { Pool } = require('pg');
|
|
|
|
async function run() {
|
|
const pool = new Pool({ connectionString: 'postgresql://postgres:postgres@localhost:5432/xflow' });
|
|
const res = await pool.query('SELECT id, username FROM "User"');
|
|
console.log(JSON.stringify(res.rows, null, 2));
|
|
|
|
// Also change owner of all canvases to the first non-system user
|
|
const realUser = res.rows.find(u => u.username !== 'system');
|
|
if (realUser) {
|
|
await pool.query('UPDATE "Canvas" SET "ownerId" = $1', [realUser.id]);
|
|
console.log('Ownership of all canvases transferred to:', realUser.username);
|
|
}
|
|
|
|
await pool.end();
|
|
}
|
|
|
|
run().catch(console.error);
|