mass refactor
This commit is contained in:
43
scripts/add-hobbies-column.js
Normal file
43
scripts/add-hobbies-column.js
Normal file
@@ -0,0 +1,43 @@
|
||||
// add-hobbies-column.js
|
||||
// Скрипт для добавления колонки hobbies в таблицу profiles
|
||||
|
||||
const { Pool } = require('pg');
|
||||
|
||||
// Настройки подключения к базе данных
|
||||
const pool = new Pool({
|
||||
host: '192.168.0.102',
|
||||
port: 5432,
|
||||
database: 'telegram_tinder_bot',
|
||||
user: 'trevor',
|
||||
password: 'Cl0ud_1985!'
|
||||
});
|
||||
|
||||
async function addHobbiesColumn() {
|
||||
try {
|
||||
console.log('Подключение к базе данных...');
|
||||
const client = await pool.connect();
|
||||
|
||||
console.log('Добавление колонки hobbies в таблицу profiles...');
|
||||
|
||||
// SQL запрос для добавления колонки
|
||||
const sql = `
|
||||
ALTER TABLE profiles
|
||||
ADD COLUMN IF NOT EXISTS hobbies TEXT;
|
||||
`;
|
||||
|
||||
await client.query(sql);
|
||||
console.log('✅ Колонка hobbies успешно добавлена в таблицу profiles');
|
||||
|
||||
// Закрытие соединения
|
||||
client.release();
|
||||
await pool.end();
|
||||
console.log('Подключение к базе данных закрыто');
|
||||
} catch (error) {
|
||||
console.error('❌ Ошибка при добавлении колонки:', error);
|
||||
await pool.end();
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Запуск функции
|
||||
addHobbiesColumn();
|
||||
Reference in New Issue
Block a user