This repository was archived by the owner on Aug 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdirect-column-add.ts
More file actions
62 lines (56 loc) · 2.53 KB
/
Copy pathdirect-column-add.ts
File metadata and controls
62 lines (56 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { pool } from './db';
async function main() {
try {
console.log("Directly adding social media columns via SQL commands...");
// Add columns using direct SQL (more reliable than the schema-based approach)
await pool.query(`
ALTER TABLE users
ADD COLUMN IF NOT EXISTS google_id_hash TEXT,
ADD COLUMN IF NOT EXISTS google_verified BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS youtube_id_hash TEXT,
ADD COLUMN IF NOT EXISTS youtube_verified BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS youtube_subscribers INTEGER,
ADD COLUMN IF NOT EXISTS github_id_hash TEXT,
ADD COLUMN IF NOT EXISTS github_verified BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS github_followers INTEGER,
ADD COLUMN IF NOT EXISTS discord_id_hash TEXT,
ADD COLUMN IF NOT EXISTS discord_verified BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS discord_username TEXT,
ADD COLUMN IF NOT EXISTS telegram_id INTEGER,
ADD COLUMN IF NOT EXISTS telegram_username TEXT,
ADD COLUMN IF NOT EXISTS telegram_verified BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS telegram_followers INTEGER,
ADD COLUMN IF NOT EXISTS instagram_username TEXT,
ADD COLUMN IF NOT EXISTS instagram_verified BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS instagram_followers INTEGER,
ADD COLUMN IF NOT EXISTS x_id_hash TEXT,
ADD COLUMN IF NOT EXISTS x_username TEXT,
ADD COLUMN IF NOT EXISTS x_verified BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS x_followers INTEGER,
ADD COLUMN IF NOT EXISTS facebook_id_hash TEXT,
ADD COLUMN IF NOT EXISTS facebook_verified BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS facebook_friends INTEGER,
ADD COLUMN IF NOT EXISTS linkedin_id_hash TEXT,
ADD COLUMN IF NOT EXISTS linkedin_verified BOOLEAN DEFAULT FALSE,
ADD COLUMN IF NOT EXISTS linkedin_connections INTEGER
`);
// Verify columns were added
const result = await pool.query(`
SELECT column_name
FROM information_schema.columns
WHERE table_name='users' AND column_name='google_id_hash'
`);
console.log(`Column google_id_hash exists: ${result.rows.length > 0}`);
if (result.rows.length > 0) {
console.log("Direct SQL column addition successful");
} else {
throw new Error("Column addition failed to take effect");
}
} catch (error) {
console.error("Error during direct column addition:", error);
process.exit(1);
} finally {
await pool.end();
}
}
main();