From 9128bec18e715d583dacb3306b2798239132135c Mon Sep 17 00:00:00 2001 From: Wei Zang Date: Thu, 9 Apr 2026 08:53:05 +0100 Subject: [PATCH] Add migrations to drop and rename prospect columns Add two SQL migration files to modify the prospects table: drop primary_email_verification_source and rename corporate_phone to phone. Include corresponding Python runner scripts that execute the ALTER statements via get_db_connection_direct, commit the changes, close the connection, and print completion messages. --- ...lter_drop_primary_email_verification_source.sql | 2 ++ .../sql/alter_rename_corporate_phone_to_phone.sql | 2 ++ ...alter_drop_primary_email_verification_source.py | 14 ++++++++++++++ .../run_alter_rename_corporate_phone_to_phone.py | 14 ++++++++++++++ 4 files changed, 32 insertions(+) create mode 100644 app/api/prospects/sql/alter_drop_primary_email_verification_source.sql create mode 100644 app/api/prospects/sql/alter_rename_corporate_phone_to_phone.sql create mode 100644 app/api/prospects/sql/run_alter_drop_primary_email_verification_source.py create mode 100644 app/api/prospects/sql/run_alter_rename_corporate_phone_to_phone.py diff --git a/app/api/prospects/sql/alter_drop_primary_email_verification_source.sql b/app/api/prospects/sql/alter_drop_primary_email_verification_source.sql new file mode 100644 index 0000000..ecca285 --- /dev/null +++ b/app/api/prospects/sql/alter_drop_primary_email_verification_source.sql @@ -0,0 +1,2 @@ +-- Migration: Remove primary_email_verification_source column from prospects table +ALTER TABLE prospects DROP COLUMN IF EXISTS primary_email_verification_source; \ No newline at end of file diff --git a/app/api/prospects/sql/alter_rename_corporate_phone_to_phone.sql b/app/api/prospects/sql/alter_rename_corporate_phone_to_phone.sql new file mode 100644 index 0000000..d877336 --- /dev/null +++ b/app/api/prospects/sql/alter_rename_corporate_phone_to_phone.sql @@ -0,0 +1,2 @@ +-- Migration: Rename corporate_phone column to phone in prospects table +ALTER TABLE prospects RENAME COLUMN corporate_phone TO phone; \ No newline at end of file diff --git a/app/api/prospects/sql/run_alter_drop_primary_email_verification_source.py b/app/api/prospects/sql/run_alter_drop_primary_email_verification_source.py new file mode 100644 index 0000000..bc40678 --- /dev/null +++ b/app/api/prospects/sql/run_alter_drop_primary_email_verification_source.py @@ -0,0 +1,14 @@ +import os +import sys +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..'))) +from app.utils.db import get_db_connection_direct + +if __name__ == "__main__": + sql = "ALTER TABLE prospects DROP COLUMN IF EXISTS primary_email_verification_source;" + conn = get_db_connection_direct() + cur = conn.cursor() + cur.execute(sql) + conn.commit() + cur.close() + conn.close() + print("Migration complete: primary_email_verification_source column dropped from prospects table.") diff --git a/app/api/prospects/sql/run_alter_rename_corporate_phone_to_phone.py b/app/api/prospects/sql/run_alter_rename_corporate_phone_to_phone.py new file mode 100644 index 0000000..1161ea0 --- /dev/null +++ b/app/api/prospects/sql/run_alter_rename_corporate_phone_to_phone.py @@ -0,0 +1,14 @@ +import os +import sys +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..'))) +from app.utils.db import get_db_connection_direct + +if __name__ == "__main__": + sql = "ALTER TABLE prospects RENAME COLUMN corporate_phone TO phone;" + conn = get_db_connection_direct() + cur = conn.cursor() + cur.execute(sql) + conn.commit() + cur.close() + conn.close() + print("Migration complete: corporate_phone column renamed to phone in prospects table.")