Skip to content

Commit 1f0883e

Browse files
Merge pull request #79 from goldlabelapps/staging
This pull request introduces several database schema migrations for the `prospects` table, focusing on cleaning up unused or redundant columns and standardizing column names.
2 parents b655be6 + 96bc5f3 commit 1f0883e

17 files changed

Lines changed: 146 additions & 0 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- Migration: Add name column and populate with first_name + ' ' + last_name
2+
ALTER TABLE prospects ADD COLUMN IF NOT EXISTS name TEXT;
3+
UPDATE prospects SET name = CONCAT_WS(' ', first_name, last_name);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Migration: Remove mobile_phone column from prospects table
2+
ALTER TABLE prospects DROP COLUMN IF EXISTS mobile_phone;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Migration: Remove other_phone column from prospects table
2+
ALTER TABLE prospects DROP COLUMN IF EXISTS other_phone;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Migration: Remove other_photne column from prospects table
2+
ALTER TABLE prospects DROP COLUMN IF EXISTS other_photne;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Migration: Remove subsidiary_of column from prospects table
2+
ALTER TABLE prospects DROP COLUMN IF EXISTS subsidiary_of;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Migration: Remove subsidiary_of_organization_id column from prospects table
2+
ALTER TABLE prospects DROP COLUMN IF EXISTS subsidiary_of_organization_id;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Migration: Rename person_linkinkedin_url column to linkedin in prospects table
2+
ALTER TABLE prospects RENAME COLUMN person_linkinkedin_url TO linkedin;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- Migration: Rename sub_departments column to department in prospects table
2+
ALTER TABLE prospects RENAME COLUMN sub_departments TO department;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
import sys
3+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..')))
4+
from app.utils.db import get_db_connection_direct
5+
6+
if __name__ == "__main__":
7+
sql = """
8+
ALTER TABLE prospects ADD COLUMN IF NOT EXISTS name TEXT;
9+
UPDATE prospects SET name = CONCAT_WS(' ', first_name, last_name);
10+
"""
11+
conn = get_db_connection_direct()
12+
cur = conn.cursor()
13+
cur.execute(sql)
14+
conn.commit()
15+
cur.close()
16+
conn.close()
17+
print("Migration complete: name column added and populated in prospects table.")
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import os
2+
import sys
3+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../..')))
4+
from app.utils.db import get_db_connection_direct
5+
6+
if __name__ == "__main__":
7+
sql = "ALTER TABLE prospects DROP COLUMN IF EXISTS mobile_phone;"
8+
conn = get_db_connection_direct()
9+
cur = conn.cursor()
10+
cur.execute(sql)
11+
conn.commit()
12+
cur.close()
13+
conn.close()
14+
print('Migration complete: mobile_phone column dropped from prospects table.')

0 commit comments

Comments
 (0)