-- ============================================ -- 验证测试1的数据库状态 -- ============================================ \echo '==========================================' \echo '1. 检查 app_cache 表是否存在' \echo '==========================================' \dt platform_schema.app_cache \echo '' \echo '==========================================' \echo '2. 查看表结构' \echo '==========================================' \d platform_schema.app_cache \echo '' \echo '==========================================' \echo '3. 查看索引' \echo '==========================================' SELECT indexname, indexdef FROM pg_indexes WHERE schemaname = 'platform_schema' AND tablename = 'app_cache'; \echo '' \echo '==========================================' \echo '4. 检查测试数据是否清理(应为0行)' \echo '==========================================' SELECT COUNT(*) as test_data_count FROM platform_schema.app_cache WHERE key LIKE 'test:%'; \echo '' \echo '==========================================' \echo '5. 查看所有缓存数据' \echo '==========================================' SELECT id, key, LEFT(value::text, 50) as value_preview, expires_at, created_at FROM platform_schema.app_cache ORDER BY created_at DESC LIMIT 10; \echo '' \echo '==========================================' \echo '6. 查看表统计信息' \echo '==========================================' SELECT COUNT(*) as total_records, pg_size_pretty(pg_total_relation_size('platform_schema.app_cache')) as total_size, pg_size_pretty(pg_relation_size('platform_schema.app_cache')) as table_size, pg_size_pretty(pg_indexes_size('platform_schema.app_cache')) as indexes_size FROM platform_schema.app_cache; \echo '' \echo '==========================================' \echo '7. 测试写入和删除(不会影响现有数据)' \echo '==========================================' -- 插入测试数据 INSERT INTO platform_schema.app_cache (key, value, expires_at, created_at) VALUES ('verify_test', '{"status": "ok"}', NOW() + INTERVAL '1 hour', NOW()); -- 验证插入 SELECT 'INSERT 成功' as result FROM platform_schema.app_cache WHERE key = 'verify_test'; -- 删除测试数据 DELETE FROM platform_schema.app_cache WHERE key = 'verify_test'; -- 验证删除 SELECT CASE WHEN COUNT(*) = 0 THEN 'DELETE 成功' ELSE 'DELETE 失败' END as result FROM platform_schema.app_cache WHERE key = 'verify_test'; \echo '' \echo '==========================================' \echo '✅ 数据库验证完成!' \echo '=========================================='