ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto
1-- Test Data Seeding Script
2-- Use this for local development and testing
3
4-- Clean existing test data (optional)
5DELETE FROM user_match_status WHERE user_did LIKE 'did:plc:test%';
6DELETE FROM atproto_matches WHERE source_account_id IN (SELECT id FROM source_accounts WHERE source_platform = 'test');
7DELETE FROM user_source_follows WHERE user_did LIKE 'did:plc:test%';
8DELETE FROM source_accounts WHERE source_platform = 'test';
9DELETE FROM user_uploads WHERE upload_id LIKE 'test-%';
10DELETE FROM user_sessions WHERE session_id LIKE 'test-%';
11
12-- Test user session
13INSERT INTO user_sessions (session_id, did, fingerprint, expires_at)
14VALUES (
15 'test-session-123',
16 'did:plc:test',
17 'test-fingerprint',
18 NOW() + INTERVAL '7 days'
19);
20
21-- Test upload
22INSERT INTO user_uploads (upload_id, user_did, source_platform, total_users, matched_users, unmatched_users)
23VALUES (
24 'test-upload-1',
25 'did:plc:test',
26 'instagram',
27 10,
28 5,
29 5
30);
31
32-- Test source accounts
33INSERT INTO source_accounts (source_platform, original_username, normalized_username)
34VALUES
35 ('instagram', 'test_user', 'testuser'),
36 ('instagram', 'john.doe', 'johndoe'),
37 ('instagram', 'jane_smith', 'janesmith'),
38 ('tiktok', '@cool_person', 'coolperson'),
39 ('twitter', 'example_account', 'exampleaccount')
40ON CONFLICT (source_platform, normalized_username) DO NOTHING;
41
42-- Link source accounts to upload
43INSERT INTO user_source_follows (user_did, upload_id, source_account_id)
44SELECT
45 'did:plc:test',
46 'test-upload-1',
47 id
48FROM source_accounts
49WHERE source_platform IN ('instagram', 'tiktok', 'twitter')
50 AND normalized_username IN ('testuser', 'johndoe', 'janesmith', 'coolperson', 'exampleaccount')
51ON CONFLICT DO NOTHING;
52
53-- Test AT Protocol matches
54INSERT INTO atproto_matches (
55 source_account_id,
56 atproto_did,
57 atproto_handle,
58 display_name,
59 match_score,
60 post_count,
61 follower_count,
62 follow_status
63)
64SELECT
65 sa.id,
66 'did:plc:matched-' || sa.id,
67 sa.normalized_username || '.bsky.social',
68 INITCAP(REPLACE(sa.normalized_username, '_', ' ')),
69 100,
70 42,
71 128,
72 '{}'::jsonb
73FROM source_accounts sa
74WHERE sa.source_platform IN ('instagram', 'tiktok')
75 AND sa.normalized_username IN ('testuser', 'johndoe')
76ON CONFLICT (source_account_id, atproto_did) DO NOTHING;
77
78-- Test user match status
79INSERT INTO user_match_status (user_did, match_id, viewed, dismissed, followed, notified)
80SELECT
81 'did:plc:test',
82 am.id,
83 false,
84 false,
85 false,
86 false
87FROM atproto_matches am
88WHERE am.atproto_did LIKE 'did:plc:matched-%'
89ON CONFLICT DO NOTHING;
90
91-- Display summary
92SELECT 'Test data seeded successfully!' as message;
93SELECT COUNT(*) as session_count FROM user_sessions WHERE session_id LIKE 'test-%';
94SELECT COUNT(*) as upload_count FROM user_uploads WHERE upload_id LIKE 'test-%';
95SELECT COUNT(*) as source_account_count FROM source_accounts WHERE source_platform IN ('test', 'instagram', 'tiktok', 'twitter');
96SELECT COUNT(*) as match_count FROM atproto_matches WHERE atproto_did LIKE 'did:plc:matched-%';