fix: unblock ci audit checks
This commit is contained in:
@@ -36,10 +36,10 @@ export default async function globalTeardown() {
|
||||
//
|
||||
// Order matters due to foreign key constraints.
|
||||
// Seed user IDs and phones to preserve between runs
|
||||
const SEED_USER_IDS = `('seed-user-admin','seed-user-agent1','seed-user-agent2','seed-user-buyer','seed-user-seller')`;
|
||||
const SEED_PHONES = `('0900000001','0900000002','0900000003','0900000004','0900000005')`;
|
||||
const SEED_LISTING_IDS = `('listing-1','listing-2','listing-3','listing-4','listing-5')`;
|
||||
const SEED_PROP_IDS = `('prop-1','prop-2','prop-3','prop-4','prop-5')`;
|
||||
const SEED_USER_IDS = `('seed-admin-001','seed-agent-001','seed-agent-002','seed-agent-003','seed-buyer-001','seed-buyer-002','seed-seller-001','seed-seller-002')`;
|
||||
const SEED_PHONES = `('+84876677771','+84900000002','+84900000003','+84900000004','+84900000005','+84900000006','+84900000007','+84900000008')`;
|
||||
const SEED_LISTING_IDS = `('seed-listing-001','seed-listing-002','seed-listing-003','seed-listing-004','seed-listing-005','seed-listing-006','seed-listing-007','seed-listing-008','seed-listing-009','seed-listing-010')`;
|
||||
const SEED_PROP_IDS = `('seed-prop-001','seed-prop-002','seed-prop-003','seed-prop-004','seed-prop-005','seed-prop-006','seed-prop-007','seed-prop-008','seed-prop-009','seed-prop-010')`;
|
||||
const NON_SEED_USERS = `SELECT id FROM "User" WHERE id NOT IN ${SEED_USER_IDS} AND phone NOT IN ${SEED_PHONES}`;
|
||||
|
||||
await pool.query(`
|
||||
@@ -52,9 +52,24 @@ export default async function globalTeardown() {
|
||||
JOIN "User" u ON a."userId" = u.id
|
||||
WHERE u.id NOT IN ${SEED_USER_IDS} AND u.phone NOT IN ${SEED_PHONES}
|
||||
);
|
||||
DELETE FROM "Inquiry" WHERE "listingId" NOT IN ${SEED_LISTING_IDS};
|
||||
DELETE FROM "Inquiry" WHERE "listingId" NOT IN ${SEED_LISTING_IDS} OR "userId" IN (${NON_SEED_USERS});
|
||||
DELETE FROM "Transaction" WHERE "buyerId" IN (${NON_SEED_USERS});
|
||||
DELETE FROM "Payment" WHERE "userId" IN (${NON_SEED_USERS});
|
||||
DELETE FROM "Payment" WHERE "userId" IN (${NON_SEED_USERS}) OR "orderId" IN (
|
||||
SELECT id FROM "Order"
|
||||
WHERE "buyerId" IN (${NON_SEED_USERS})
|
||||
OR "sellerId" IN (${NON_SEED_USERS})
|
||||
OR "listingId" NOT IN ${SEED_LISTING_IDS}
|
||||
);
|
||||
DELETE FROM "Escrow" WHERE "orderId" IN (
|
||||
SELECT id FROM "Order"
|
||||
WHERE "buyerId" IN (${NON_SEED_USERS})
|
||||
OR "sellerId" IN (${NON_SEED_USERS})
|
||||
OR "listingId" NOT IN ${SEED_LISTING_IDS}
|
||||
);
|
||||
DELETE FROM "Order"
|
||||
WHERE "buyerId" IN (${NON_SEED_USERS})
|
||||
OR "sellerId" IN (${NON_SEED_USERS})
|
||||
OR "listingId" NOT IN ${SEED_LISTING_IDS};
|
||||
DELETE FROM "UsageRecord" WHERE "subscriptionId" IN (
|
||||
SELECT s.id FROM "Subscription" s
|
||||
JOIN "User" u ON s."userId" = u.id
|
||||
|
||||
Reference in New Issue
Block a user