Files
Wyndham-RSVN-0918/database/postgresql/postflight_read_only.sql
鲨鱼辣椒 31849411a8
Some checks failed
verify / booking-verify (push) Has been cancelled
建立5178独立项目基线
2026-09-08 15:03:45 +08:00

49 lines
1.3 KiB
SQL

\set ON_ERROR_STOP on
BEGIN READ ONLY;
SELECT
current_database() AS current_database,
current_user AS current_user,
n.nspname AS schema_name,
pg_get_userbyid(n.nspowner) AS schema_owner,
has_schema_privilege(current_user, n.oid, 'USAGE') AS can_use,
has_schema_privilege(current_user, n.oid, 'CREATE') AS can_create_objects
FROM pg_namespace n
WHERE n.nspname = 'th_hotel_booking';
SELECT version, description, installed_by, installed_at
FROM th_hotel_booking.schema_migration
ORDER BY version;
SELECT
c.relkind,
c.relname AS object_name
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname = 'th_hotel_booking'
ORDER BY c.relkind, c.relname;
SELECT
n.nspname AS schema_name,
c.relkind,
count(*) AS object_count
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE n.nspname NOT LIKE 'pg_%'
AND n.nspname <> 'information_schema'
GROUP BY n.nspname, c.relkind
ORDER BY n.nspname, c.relkind;
SELECT
conrelid::regclass::text AS constrained_table,
confrelid::regclass::text AS referenced_table,
conname
FROM pg_constraint
WHERE contype = 'f'
AND connamespace = 'th_hotel_booking'::regnamespace
AND confrelid::regclass::text NOT LIKE 'th_hotel_booking.%'
ORDER BY constrained_table, conname;
COMMIT;