kite-menu
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import pkg from 'pg';
|
||||
import dotenv from 'dotenv';
|
||||
dotenv.config();
|
||||
|
||||
const { Client } = pkg;
|
||||
|
||||
async function main() {
|
||||
const client = new Client({
|
||||
connectionString: process.env.DATABASE_URL,
|
||||
});
|
||||
await client.connect();
|
||||
|
||||
const mockImageUrl = '/default-product.png';
|
||||
|
||||
try {
|
||||
const result = await client.query(`
|
||||
UPDATE "products"
|
||||
SET "image_url" = $1
|
||||
`, [mockImageUrl]);
|
||||
|
||||
console.log(`Successfully updated ${result.rowCount} products with a mock image.`);
|
||||
} catch (e) {
|
||||
console.error('Error updating products:', e.message);
|
||||
} finally {
|
||||
await client.end();
|
||||
}
|
||||
}
|
||||
|
||||
main().catch(e => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user