| """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() |