feat: Implement comments, notifications, and custom emojis with new API routes, UI components, and database migrations.
This commit is contained in:
62
debug/verify_db.mjs
Normal file
62
debug/verify_db.mjs
Normal file
@@ -0,0 +1,62 @@
|
||||
import db from "../src/inc/sql.mjs";
|
||||
|
||||
const runTest = async () => {
|
||||
console.log("Verifying Database Schema...");
|
||||
|
||||
// 1. Check Tables
|
||||
try {
|
||||
await db`SELECT 1 FROM comments LIMIT 1`;
|
||||
console.log("✔ Table 'comments' exists.");
|
||||
} catch (e) {
|
||||
console.error("✘ Table 'comments' missing.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
await db`SELECT 1 FROM comment_subscriptions LIMIT 1`;
|
||||
console.log("✔ Table 'comment_subscriptions' exists.");
|
||||
} catch (e) {
|
||||
console.error("✘ Table 'comment_subscriptions' missing.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// 2. Insert Test Data
|
||||
console.log("Testing Insert...");
|
||||
const user = await db`SELECT id FROM "user" LIMIT 1`;
|
||||
const item = await db`SELECT id FROM "items" LIMIT 1`;
|
||||
|
||||
if (!user.length || !item.length) {
|
||||
console.log("⚠ No user/item to test insert. Skipping.");
|
||||
} else {
|
||||
const userId = user[0].id;
|
||||
const itemId = item[0].id;
|
||||
|
||||
const comment = await db`
|
||||
INSERT INTO comments (item_id, user_id, content)
|
||||
VALUES (${itemId}, ${userId}, 'Test Comment DB Verify')
|
||||
RETURNING id
|
||||
`;
|
||||
console.log("✔ Inserted comment ID:", comment[0].id);
|
||||
|
||||
const fetch = await db`SELECT content FROM comments WHERE id = ${comment[0].id}`;
|
||||
if (fetch[0].content === 'Test Comment DB Verify') {
|
||||
console.log("✔ Verified content.");
|
||||
} else {
|
||||
console.error("✘ Content mismatch.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
await db`DELETE FROM comments WHERE id = ${comment[0].id}`;
|
||||
}
|
||||
|
||||
console.log("DB Schema Verification Passed.");
|
||||
|
||||
// 3. Optional: subscription test
|
||||
await db`INSERT INTO comment_subscriptions (user_id, item_id) VALUES (${user[0].id}, ${item[0].id}) ON CONFLICT DO NOTHING`;
|
||||
console.log("✔ Subscription table write access confirmed.");
|
||||
|
||||
process.exit(0);
|
||||
};
|
||||
|
||||
runTest().catch(console.error);
|
||||
Reference in New Issue
Block a user