File size: 2,168 Bytes
98bf1ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
09dd636
98bf1ef
 
 
09dd636
98bf1ef
 
 
09dd636
98bf1ef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
"""
Script para crear la tabla 'actions' en la base de datos remota
"""

import mysql.connector
from dotenv import load_dotenv
import os

# Cargar variables de entorno
load_dotenv()

try:
    # Conexión a la base de datos
    conexion = mysql.connector.connect(
        host=os.getenv('DB_HOST'),
        user=os.getenv('DB_USER'),
        password=os.getenv('mariadb_c'),
        database=os.getenv('DB_NAME'),
        port=int(os.getenv('DB_PORT', 3306)),
        autocommit=True
    )
    
    cursor = conexion.cursor()
    
    # Verificar si la tabla ya existe
    cursor.execute("""
        SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES 
        WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'action_call'
    """)
    
    if cursor.fetchone():
        print("ℹ️  La tabla 'action_call' ya existe")
    else:
        # Crear la tabla
        cursor.execute("""
            CREATE TABLE `action_call` (
              `usuario` varchar(255) PRIMARY KEY,
              `uid` varchar(255),
              `displayName` varchar(255),
              `email` varchar(255),
              `action_call` boolean,
              `country_header` varchar(10),
              `country_ip` varchar(10),
              `creditos` int,
              `esta_hora` int,
              `explicit_counter` int,
              `fecha_registro` datetime,
              `gaClient` varchar(255),
              `open_use` boolean,
              `ritmo` decimal(10,2),
              `streak` int,
              `ultima_generacion_hora` datetime,
              `ultimo_uso` datetime,
              `usos` int,
              `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
              `updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
            )
        """)
        print("✅ Tabla 'actions' creada correctamente")
    
    # Mostrar estructura
    cursor.execute("DESCRIBE actions")
    columnas = cursor.fetchall()
    
    print("\n📋 Estructura de la tabla 'actions':")
    for col in columnas:
        print(f"  - {col[0]}: {col[1]}")
    
    cursor.close()
    conexion.close()
    
except Exception as e:
    print(f"❌ Error: {str(e)}")