import os
import psycopg2
from dotenv import load_dotenv

load_dotenv()

PLACE_ID = "ChIJl_j1m6v71y0RzcEBmBCj8tg"

def revert_test_data():
    try:
        conn = psycopg2.connect(
            host=os.getenv("DB_HOST"),
            port=os.getenv("DB_PORT"),
            database=os.getenv("DB_NAME"),
            user=os.getenv("DB_USER"),
            password=os.getenv("DB_PASSWORD")
        )
        with conn.cursor() as cur:
            # Revert the change
            cur.execute("UPDATE master_outlet SET place_id = NULL WHERE place_id = %s;", (PLACE_ID,))
            conn.commit()
            print(f"Reverted place_id for {cur.rowcount} outlet(s).")

        conn.close()
    except Exception as e:
        print(f"Error checking data: {e}")

if __name__ == "__main__":
    revert_test_data()
