main
|
Last change
on this file since b374c85 was d8deee6, checked in by GitHub <noreply@…>, 3 months ago |
|
Add files via upload
|
-
Property mode
set to
100644
|
|
File size:
857 bytes
|
| Rev | Line | |
|---|
| [d8deee6] | 1 | // Add role column to guest table
|
|---|
| 2 | require('dotenv').config();
|
|---|
| 3 | const { Pool } = require('pg');
|
|---|
| 4 |
|
|---|
| 5 | const pool = new Pool({
|
|---|
| 6 | user: process.env.DB_USER,
|
|---|
| 7 | host: process.env.DB_HOST,
|
|---|
| 8 | database: process.env.DB_NAME,
|
|---|
| 9 | password: process.env.DB_PASSWORD,
|
|---|
| 10 | port: parseInt(process.env.DB_PORT, 10),
|
|---|
| 11 | ssl: { rejectUnauthorized: false }
|
|---|
| 12 | });
|
|---|
| 13 |
|
|---|
| 14 | async function addRoleColumn() {
|
|---|
| 15 | try {
|
|---|
| 16 | console.log('🔄 Adding role column to guest table...');
|
|---|
| 17 |
|
|---|
| 18 | await pool.query(`
|
|---|
| 19 | ALTER TABLE project.guest
|
|---|
| 20 | ADD COLUMN IF NOT EXISTS role VARCHAR(100) DEFAULT 'Guest'
|
|---|
| 21 | `);
|
|---|
| 22 |
|
|---|
| 23 | console.log('✅ Role column added successfully!');
|
|---|
| 24 | process.exit(0);
|
|---|
| 25 | } catch (err) {
|
|---|
| 26 | console.error('❌ Error:', err.message);
|
|---|
| 27 | process.exit(1);
|
|---|
| 28 | }
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | addRoleColumn();
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.