-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-database-tables.sql
More file actions
36 lines (35 loc) · 1.19 KB
/
check-database-tables.sql
File metadata and controls
36 lines (35 loc) · 1.19 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
-- Check what tables exist in the database
SELECT
table_schema,
table_name,
table_type
FROM information_schema.tables
WHERE table_schema IN ('public', 'auth')
ORDER BY table_schema, table_name;
-- Also check if specific tables we need exist
SELECT
CASE
WHEN EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'organizations' AND table_schema = 'public')
THEN 'EXISTS'
ELSE 'MISSING'
END as organizations_table,
CASE
WHEN EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'memberships' AND table_schema = 'public')
THEN 'EXISTS'
ELSE 'MISSING'
END as memberships_table,
CASE
WHEN EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'users' AND table_schema = 'auth')
THEN 'EXISTS'
ELSE 'MISSING'
END as auth_users_table,
CASE
WHEN EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'users' AND table_schema = 'public')
THEN 'EXISTS'
ELSE 'MISSING'
END as public_users_table,
CASE
WHEN EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'profiles' AND table_schema = 'public')
THEN 'EXISTS'
ELSE 'MISSING'
END as profiles_table;