#!/usr/bin/env python import psycopg2 # Connect directly to the database try: conn = psycopg2.connect( dbname="imam_javad_db", user="postgres", password="123456789", host="localhost", port="5432" ) cursor = conn.cursor() print("Connected to database successfully") except Exception as e: print(f"Failed to connect to database: {e}") exit(1) # Create the missing TransmitterOpinion table sql = """ CREATE TABLE IF NOT EXISTS hadis_transmitteropinion ( id BIGSERIAL PRIMARY KEY, scholar_name VARCHAR(255) NOT NULL, opinion_text TEXT NOT NULL, status VARCHAR(20) DEFAULT 'confirmed', created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(), transmitter_id BIGINT REFERENCES hadis_transmitters(id) ON DELETE CASCADE ); """ try: cursor.execute(sql) print("✓ Created hadis_transmitteropinion table") except Exception as e: print(f"✗ Error creating table: {e}") conn.commit() conn.close() print("TransmitterOpinion table creation completed!")