Files
yarmarka/migrate_experience.py
2026-03-16 18:57:22 +03:00

49 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# migrate_experience.py
import sqlite3
DB_NAME = "rabota_today.db"
def add_description_column():
"""Добавление поля description в таблицу work_experience"""
conn = sqlite3.connect(DB_NAME)
cursor = conn.cursor()
try:
# Проверяем существующие колонки
cursor.execute("PRAGMA table_info(work_experience)")
columns = [col[1] for col in cursor.fetchall()]
print("📊 Текущие колонки в таблице work_experience:", columns)
# Добавляем колонку description, если её нет
if 'description' not in columns:
print(" Добавление колонки description...")
cursor.execute("ALTER TABLE work_experience ADD COLUMN description TEXT")
print("✅ Колонка description добавлена")
conn.commit()
print("\n🎉 Миграция успешно завершена!")
# Показываем обновленную структуру
cursor.execute("PRAGMA table_info(work_experience)")
new_columns = [col[1] for col in cursor.fetchall()]
print("\n📊 Обновленные колонки:", new_columns)
except Exception as e:
print(f"❌ Ошибка: {e}")
conn.rollback()
finally:
conn.close()
if __name__ == "__main__":
print("=" * 50)
print("🚀 Миграция таблицы work_experience")
print("=" * 50)
response = input("Добавить поле description? (y/n): ")
if response.lower() == 'y':
add_description_column()
else:
print("❌ Миграция отменена")