from sqlalchemy import text from app.database import engine def run_migrations(): with engine.connect() as conn: print("Starting migrations...") # 1. Add commit_message to data_records try: conn.execute(text("ALTER TABLE data_records ADD COLUMN commit_message TEXT DEFAULT NULL;")) print("Added commit_message to data_records") except Exception as e: print(f"Skipping commit_message for data_records: {e}") # 2. Add commit_message to data_versions try: conn.execute(text("ALTER TABLE data_versions ADD COLUMN commit_message TEXT DEFAULT NULL;")) print("Added commit_message to data_versions") except Exception as e: print(f"Skipping commit_message for data_versions: {e}") # 3. Add content_hash to data_records try: conn.execute(text("ALTER TABLE data_records ADD COLUMN content_hash VARCHAR(64) DEFAULT NULL;")) print("Added content_hash to data_records") except Exception as e: print(f"Skipping content_hash for data_records: {e}") conn.commit() print("Migrations complete.") if __name__ == "__main__": run_migrations()