File size: 1,592 Bytes
d54ba19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Script para adicionar coluna numero_processo"""

from utils.database import get_db_connection

def add_numero_processo_column():
    """Adiciona coluna numero_processo na tabela checklists"""
    with open('/Users/abimaeltorcate/checklist/add_numero_processo.sql', 'r') as f:
        sql_script = f.read()
    
    try:
        with get_db_connection() as conn:
            with conn.cursor() as cur:
                # Executar cada comando separadamente
                commands = sql_script.split(';')
                for command in commands:
                    command = command.strip()
                    if command:
                        print(f"Executando: {command[:50]}...")
                        cur.execute(command)
                
                conn.commit()
                print("✅ Coluna numero_processo adicionada com sucesso!")
                
                # Verificar se a coluna foi adicionada
                cur.execute("""
                    SELECT column_name, data_type, is_nullable
                    FROM information_schema.columns 
                    WHERE table_name = 'checklists' AND table_schema = 'public'
                    ORDER BY ordinal_position
                """)
                
                columns = cur.fetchall()
                print("\n📋 Colunas da tabela checklists:")
                for col in columns:
                    print(f"  - {col[0]} ({col[1]}) - Nullable: {col[2]}")
                
    except Exception as e:
        print(f"❌ Erro: {e}")

if __name__ == "__main__":
    add_numero_processo_column()