25 lines
876 B
JavaScript
25 lines
876 B
JavaScript
const { Pool } = require('pg');
|
|
require('dotenv').config();
|
|
|
|
const pool = new Pool({
|
|
connectionString: process.env.DATABASE_URL || 'postgres://postgres:csh%402018@localhost:5433/ai_pharmacy'
|
|
});
|
|
|
|
async function run() {
|
|
try {
|
|
await pool.query('ALTER TABLE stock_movements ADD COLUMN IF NOT EXISTS reason_code VARCHAR(100)');
|
|
await pool.query('ALTER TABLE stock_movements ADD COLUMN IF NOT EXISTS notes TEXT');
|
|
await pool.query('ALTER TABLE products ADD COLUMN IF NOT EXISTS hsn_code VARCHAR(20)');
|
|
await pool.query('ALTER TABLE products ADD COLUMN IF NOT EXISTS tenant_id VARCHAR(50)');
|
|
await pool.query('ALTER TABLE drugs ADD COLUMN IF NOT EXISTS tenant_id VARCHAR(50)');
|
|
console.log('Successfully added missing database columns.');
|
|
} catch (err) {
|
|
console.error('Error altering database:', err);
|
|
} finally {
|
|
pool.end();
|
|
}
|
|
}
|
|
run();
|
|
|
|
|