35d460b127
Multi-tenant marine invoicing system: Stripe payments, PDF generation, digital signatures, QR codes, SMTP email, bilingual templates. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
31 lines
935 B
Python
31 lines
935 B
Python
"""
|
|
Ejecutar UNA SOLA VEZ para agregar las columnas nuevas a la DB existente.
|
|
Comando: python fix_db.py
|
|
"""
|
|
import sqlite3, os
|
|
|
|
DB_PATH = os.path.join('instance', 'marineinvoice.db')
|
|
|
|
columns_to_add = [
|
|
("document", "payment_token", "TEXT"),
|
|
("company", "stripe_secret_key", "TEXT"),
|
|
("company", "stripe_publishable_key", "TEXT"),
|
|
]
|
|
|
|
conn = sqlite3.connect(DB_PATH)
|
|
cur = conn.cursor()
|
|
|
|
for table, column, col_type in columns_to_add:
|
|
# Verificar si la columna ya existe antes de agregarla
|
|
cur.execute(f"PRAGMA table_info({table})")
|
|
existing = [row[1] for row in cur.fetchall()]
|
|
if column not in existing:
|
|
cur.execute(f"ALTER TABLE {table} ADD COLUMN {column} {col_type}")
|
|
print(f"✅ Agregada: {table}.{column}")
|
|
else:
|
|
print(f"⏭️ Ya existe: {table}.{column}")
|
|
|
|
conn.commit()
|
|
conn.close()
|
|
print("\n✅ DB actualizada. Ya puedes reiniciar el servidor.")
|