39441-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-04-03 00:52:04 +00:00

2985 lines
61 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const VerificationRequests = db.verification_requests;
const Posts = db.posts;
const Comments = db.comments;
const Likes = db.likes;
const Follows = db.follows;
const Messages = db.messages;
const Reports = db.reports;
const ModerationActions = db.moderation_actions;
const LoginAuditEvents = db.login_audit_events;
const SiteSettings = db.site_settings;
const VerificationRequestsData = [
{
// type code here for "relation_one" field
"status": "rejected",
"note_to_admin": "Please verify my account. My parent can confirm.",
// type code here for "files" field
"reviewed_at": new Date('2026-04-01T12:10:00Z'),
// type code here for "relation_one" field
"admin_notes": "Waiting for additional confirmation.",
},
{
// type code here for "relation_one" field
"status": "approved",
"note_to_admin": "I want a verified badge for my book club posts.",
// type code here for "files" field
"reviewed_at": new Date('2026-03-11T16:40:00Z'),
// type code here for "relation_one" field
"admin_notes": "Approved based on consent and profile consistency.",
},
{
// type code here for "relation_one" field
"status": "rejected",
"note_to_admin": "Verified requested by parent.",
// type code here for "files" field
"reviewed_at": new Date('2026-01-10T14:15:00Z'),
// type code here for "relation_one" field
"admin_notes": "Approved and badge applied.",
},
];
const PostsData = [
{
// type code here for "relation_one" field
"caption": "My new sketch of a rocket ship.",
// type code here for "images" field
// type code here for "files" field
"visibility": "public",
"comments_enabled": true,
"published_at": new Date('2026-04-02T15:00:00Z'),
"moderation_status": "removed",
},
{
// type code here for "relation_one" field
"caption": "Built a cool bridge with blocks today.",
// type code here for "images" field
// type code here for "files" field
"visibility": "private",
"comments_enabled": true,
"published_at": new Date('2026-04-01T17:30:00Z'),
"moderation_status": "under_review",
},
{
// type code here for "relation_one" field
"caption": "Reading challenge: 10 pages a day.",
// type code here for "images" field
// type code here for "files" field
"visibility": "followers_only",
"comments_enabled": true,
"published_at": new Date('2026-03-28T10:10:00Z'),
"moderation_status": "under_review",
},
];
const CommentsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"body": "Great drawing! The flames look awesome.",
"posted_at": new Date('2026-04-02T16:05:00Z'),
"moderation_status": "under_review",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"body": "Nice build. How did you keep it balanced?",
"posted_at": new Date('2026-04-01T18:10:00Z'),
"moderation_status": "removed",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"body": "I can join! What book are you reading next?",
"posted_at": new Date('2026-03-28T11:00:00Z'),
"moderation_status": "under_review",
},
];
const LikesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"liked_at": new Date('2026-04-02T16:10:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"liked_at": new Date('2026-04-02T16:12:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"liked_at": new Date('2026-04-01T18:12:00Z'),
},
];
const FollowsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "accepted",
"requested_at": new Date('2026-03-20T09:00:00Z'),
"responded_at": new Date('2026-03-20T09:30:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "requested",
"requested_at": new Date('2026-03-21T10:00:00Z'),
"responded_at": new Date('2026-03-21T10:20:00Z'),
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"status": "accepted",
"requested_at": new Date('2026-04-01T09:40:00Z'),
"responded_at": new Date('2026-05-01T10:00:00Z'),
},
];
const MessagesData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"body": "Hi Zoe, want to share book recommendations?",
// type code here for "files" field
"sent_at": new Date('2026-04-02T17:00:00Z'),
"read_at": new Date('2026-04-02T17:10:00Z'),
"delivery_status": "delivered",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"body": "Sure! I am reading a mystery book right now.",
// type code here for "files" field
"sent_at": new Date('2026-04-02T17:12:00Z'),
"read_at": new Date('2026-04-02T17:20:00Z'),
"delivery_status": "delivered",
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"body": "Hey Avery, your rocket sketch is cool.",
// type code here for "files" field
"sent_at": new Date('2026-04-02T16:30:00Z'),
"read_at": new Date('2026-04-02T16:45:00Z'),
"delivery_status": "read",
},
];
const ReportsData = [
{
// type code here for "relation_one" field
"target_type": "user",
"target_reference": "post_4",
"reason": "inappropriate_content",
"details": "Please review wording to keep it friendly.",
"status": "investigating",
// type code here for "relation_one" field
"reported_at": new Date('2026-03-30T15:20:00Z'),
"resolved_at": new Date('2026-05-01T10:00:00Z'),
"resolution_notes": "Queued for review.",
},
{
// type code here for "relation_one" field
"target_type": "user",
"target_reference": "comment_5",
"reason": "bullying",
"details": "May need review for tone.",
"status": "dismissed",
// type code here for "relation_one" field
"reported_at": new Date('2026-03-30T15:18:00Z'),
"resolved_at": new Date('2026-05-01T10:00:00Z'),
"resolution_notes": "Moderator reviewing.",
},
{
// type code here for "relation_one" field
"target_type": "message",
"target_reference": "user_999",
"reason": "bullying",
"details": "Unknown account sent repeated messages.",
"status": "dismissed",
// type code here for "relation_one" field
"reported_at": new Date('2026-03-26T09:00:00Z'),
"resolved_at": new Date('2026-03-26T12:00:00Z'),
"resolution_notes": "No matching account found.",
},
];
const ModerationActionsData = [
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"action_type": "unverify",
"reason": "Reminder to use kind words in comments.",
"starts_at": new Date('2026-03-30T16:00:00Z'),
"ends_at": new Date('2026-03-30T16:30:00Z'),
"status": "reverted",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"action_type": "ban",
"reason": "Removed comment pending review.",
"starts_at": new Date('2026-03-30T15:16:00Z'),
"ends_at": new Date('2026-03-30T15:16:30Z'),
"status": "expired",
// type code here for "relation_one" field
},
{
// type code here for "relation_one" field
// type code here for "relation_one" field
"action_type": "ban",
"reason": "Verified after consent check.",
"starts_at": new Date('2026-01-10T14:16:00Z'),
"ends_at": new Date('2026-01-10T14:16:30Z'),
"status": "reverted",
// type code here for "relation_one" field
},
];
const LoginAuditEventsData = [
{
// type code here for "relation_one" field
"occurred_at": new Date('2026-04-02T18:05:00Z'),
"event_type": "login_failed",
"ip_address": "203.0.113.10",
"user_agent": "Chrome",
},
{
// type code here for "relation_one" field
"occurred_at": new Date('2026-04-03T08:12:00Z'),
"event_type": "password_reset_completed",
"ip_address": "203.0.113.11",
"user_agent": "Safari",
},
{
// type code here for "relation_one" field
"occurred_at": new Date('2026-04-01T19:40:00Z'),
"event_type": "password_reset_requested",
"ip_address": "203.0.113.12",
"user_agent": "Chrome",
},
];
const SiteSettingsData = [
{
"site_name": "App Preview Kids",
"terms_of_use": "Be kind. Do not share personal information. Follow the rules.",
"privacy_policy": "We protect your data and limit what is shared. Parents can request account changes.",
"max_user_age": 12,
"require_parental_consent": true,
"default_timeout_minutes": 30,
"auto_moderate_media": true,
"default_post_visibility": "private",
},
{
"site_name": "App Preview Kids - Spring",
"terms_of_use": "Use respectful language. Report problems. Keep content appropriate.",
"privacy_policy": "We collect minimal data for safety and account features.",
"max_user_age": 12,
"require_parental_consent": true,
"default_timeout_minutes": 20,
"auto_moderate_media": true,
"default_post_visibility": "private",
},
{
"site_name": "App Preview Kids - Summer",
"terms_of_use": "No bullying. No personal info. Have fun safely.",
"privacy_policy": "We use moderation tools to keep the community safe.",
"max_user_age": 12,
"require_parental_consent": true,
"default_timeout_minutes": 25,
"auto_moderate_media": true,
"default_post_visibility": "private",
},
];
// Similar logic for "relation_many"
async function associateVerificationRequestWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const VerificationRequest0 = await VerificationRequests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (VerificationRequest0?.setUser)
{
await
VerificationRequest0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const VerificationRequest1 = await VerificationRequests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (VerificationRequest1?.setUser)
{
await
VerificationRequest1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const VerificationRequest2 = await VerificationRequests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (VerificationRequest2?.setUser)
{
await
VerificationRequest2.
setUser(relatedUser2);
}
}
async function associateVerificationRequestWithReviewed_by() {
const relatedReviewed_by0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const VerificationRequest0 = await VerificationRequests.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (VerificationRequest0?.setReviewed_by)
{
await
VerificationRequest0.
setReviewed_by(relatedReviewed_by0);
}
const relatedReviewed_by1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const VerificationRequest1 = await VerificationRequests.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (VerificationRequest1?.setReviewed_by)
{
await
VerificationRequest1.
setReviewed_by(relatedReviewed_by1);
}
const relatedReviewed_by2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const VerificationRequest2 = await VerificationRequests.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (VerificationRequest2?.setReviewed_by)
{
await
VerificationRequest2.
setReviewed_by(relatedReviewed_by2);
}
}
async function associatePostWithAuthor() {
const relatedAuthor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Post0 = await Posts.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Post0?.setAuthor)
{
await
Post0.
setAuthor(relatedAuthor0);
}
const relatedAuthor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Post1 = await Posts.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Post1?.setAuthor)
{
await
Post1.
setAuthor(relatedAuthor1);
}
const relatedAuthor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Post2 = await Posts.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Post2?.setAuthor)
{
await
Post2.
setAuthor(relatedAuthor2);
}
}
async function associateCommentWithPost() {
const relatedPost0 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Comment0 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Comment0?.setPost)
{
await
Comment0.
setPost(relatedPost0);
}
const relatedPost1 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Comment1 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Comment1?.setPost)
{
await
Comment1.
setPost(relatedPost1);
}
const relatedPost2 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Comment2 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Comment2?.setPost)
{
await
Comment2.
setPost(relatedPost2);
}
}
async function associateCommentWithAuthor() {
const relatedAuthor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment0 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Comment0?.setAuthor)
{
await
Comment0.
setAuthor(relatedAuthor0);
}
const relatedAuthor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment1 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Comment1?.setAuthor)
{
await
Comment1.
setAuthor(relatedAuthor1);
}
const relatedAuthor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Comment2 = await Comments.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Comment2?.setAuthor)
{
await
Comment2.
setAuthor(relatedAuthor2);
}
}
async function associateLikeWithPost() {
const relatedPost0 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Like0 = await Likes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Like0?.setPost)
{
await
Like0.
setPost(relatedPost0);
}
const relatedPost1 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Like1 = await Likes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Like1?.setPost)
{
await
Like1.
setPost(relatedPost1);
}
const relatedPost2 = await Posts.findOne({
offset: Math.floor(Math.random() * (await Posts.count())),
});
const Like2 = await Likes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Like2?.setPost)
{
await
Like2.
setPost(relatedPost2);
}
}
async function associateLikeWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Like0 = await Likes.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Like0?.setUser)
{
await
Like0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Like1 = await Likes.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Like1?.setUser)
{
await
Like1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Like2 = await Likes.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Like2?.setUser)
{
await
Like2.
setUser(relatedUser2);
}
}
async function associateFollowWithFollower() {
const relatedFollower0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow0 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Follow0?.setFollower)
{
await
Follow0.
setFollower(relatedFollower0);
}
const relatedFollower1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow1 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Follow1?.setFollower)
{
await
Follow1.
setFollower(relatedFollower1);
}
const relatedFollower2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow2 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Follow2?.setFollower)
{
await
Follow2.
setFollower(relatedFollower2);
}
}
async function associateFollowWithFollowing() {
const relatedFollowing0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow0 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Follow0?.setFollowing)
{
await
Follow0.
setFollowing(relatedFollowing0);
}
const relatedFollowing1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow1 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Follow1?.setFollowing)
{
await
Follow1.
setFollowing(relatedFollowing1);
}
const relatedFollowing2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Follow2 = await Follows.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Follow2?.setFollowing)
{
await
Follow2.
setFollowing(relatedFollowing2);
}
}
async function associateMessageWithSender() {
const relatedSender0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message0 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Message0?.setSender)
{
await
Message0.
setSender(relatedSender0);
}
const relatedSender1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message1 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Message1?.setSender)
{
await
Message1.
setSender(relatedSender1);
}
const relatedSender2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message2 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Message2?.setSender)
{
await
Message2.
setSender(relatedSender2);
}
}
async function associateMessageWithRecipient() {
const relatedRecipient0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message0 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Message0?.setRecipient)
{
await
Message0.
setRecipient(relatedRecipient0);
}
const relatedRecipient1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message1 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Message1?.setRecipient)
{
await
Message1.
setRecipient(relatedRecipient1);
}
const relatedRecipient2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Message2 = await Messages.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Message2?.setRecipient)
{
await
Message2.
setRecipient(relatedRecipient2);
}
}
async function associateReportWithReporter() {
const relatedReporter0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report0 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Report0?.setReporter)
{
await
Report0.
setReporter(relatedReporter0);
}
const relatedReporter1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report1 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Report1?.setReporter)
{
await
Report1.
setReporter(relatedReporter1);
}
const relatedReporter2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report2 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Report2?.setReporter)
{
await
Report2.
setReporter(relatedReporter2);
}
}
async function associateReportWithAssigned_to() {
const relatedAssigned_to0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report0 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (Report0?.setAssigned_to)
{
await
Report0.
setAssigned_to(relatedAssigned_to0);
}
const relatedAssigned_to1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report1 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (Report1?.setAssigned_to)
{
await
Report1.
setAssigned_to(relatedAssigned_to1);
}
const relatedAssigned_to2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const Report2 = await Reports.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (Report2?.setAssigned_to)
{
await
Report2.
setAssigned_to(relatedAssigned_to2);
}
}
async function associateModerationActionWithActor() {
const relatedActor0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ModerationAction0 = await ModerationActions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ModerationAction0?.setActor)
{
await
ModerationAction0.
setActor(relatedActor0);
}
const relatedActor1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ModerationAction1 = await ModerationActions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ModerationAction1?.setActor)
{
await
ModerationAction1.
setActor(relatedActor1);
}
const relatedActor2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ModerationAction2 = await ModerationActions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ModerationAction2?.setActor)
{
await
ModerationAction2.
setActor(relatedActor2);
}
}
async function associateModerationActionWithSubject_user() {
const relatedSubject_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ModerationAction0 = await ModerationActions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ModerationAction0?.setSubject_user)
{
await
ModerationAction0.
setSubject_user(relatedSubject_user0);
}
const relatedSubject_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ModerationAction1 = await ModerationActions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ModerationAction1?.setSubject_user)
{
await
ModerationAction1.
setSubject_user(relatedSubject_user1);
}
const relatedSubject_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ModerationAction2 = await ModerationActions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ModerationAction2?.setSubject_user)
{
await
ModerationAction2.
setSubject_user(relatedSubject_user2);
}
}
async function associateModerationActionWithRelated_report() {
const relatedRelated_report0 = await Reports.findOne({
offset: Math.floor(Math.random() * (await Reports.count())),
});
const ModerationAction0 = await ModerationActions.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ModerationAction0?.setRelated_report)
{
await
ModerationAction0.
setRelated_report(relatedRelated_report0);
}
const relatedRelated_report1 = await Reports.findOne({
offset: Math.floor(Math.random() * (await Reports.count())),
});
const ModerationAction1 = await ModerationActions.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ModerationAction1?.setRelated_report)
{
await
ModerationAction1.
setRelated_report(relatedRelated_report1);
}
const relatedRelated_report2 = await Reports.findOne({
offset: Math.floor(Math.random() * (await Reports.count())),
});
const ModerationAction2 = await ModerationActions.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ModerationAction2?.setRelated_report)
{
await
ModerationAction2.
setRelated_report(relatedRelated_report2);
}
}
async function associateLoginAuditEventWithUser() {
const relatedUser0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const LoginAuditEvent0 = await LoginAuditEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (LoginAuditEvent0?.setUser)
{
await
LoginAuditEvent0.
setUser(relatedUser0);
}
const relatedUser1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const LoginAuditEvent1 = await LoginAuditEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (LoginAuditEvent1?.setUser)
{
await
LoginAuditEvent1.
setUser(relatedUser1);
}
const relatedUser2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const LoginAuditEvent2 = await LoginAuditEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (LoginAuditEvent2?.setUser)
{
await
LoginAuditEvent2.
setUser(relatedUser2);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await VerificationRequests.bulkCreate(VerificationRequestsData);
await Posts.bulkCreate(PostsData);
await Comments.bulkCreate(CommentsData);
await Likes.bulkCreate(LikesData);
await Follows.bulkCreate(FollowsData);
await Messages.bulkCreate(MessagesData);
await Reports.bulkCreate(ReportsData);
await ModerationActions.bulkCreate(ModerationActionsData);
await LoginAuditEvents.bulkCreate(LoginAuditEventsData);
await SiteSettings.bulkCreate(SiteSettingsData);
await Promise.all([
// Similar logic for "relation_many"
await associateVerificationRequestWithUser(),
await associateVerificationRequestWithReviewed_by(),
await associatePostWithAuthor(),
await associateCommentWithPost(),
await associateCommentWithAuthor(),
await associateLikeWithPost(),
await associateLikeWithUser(),
await associateFollowWithFollower(),
await associateFollowWithFollowing(),
await associateMessageWithSender(),
await associateMessageWithRecipient(),
await associateReportWithReporter(),
await associateReportWithAssigned_to(),
await associateModerationActionWithActor(),
await associateModerationActionWithSubject_user(),
await associateModerationActionWithRelated_report(),
await associateLoginAuditEventWithUser(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('verification_requests', null, {});
await queryInterface.bulkDelete('posts', null, {});
await queryInterface.bulkDelete('comments', null, {});
await queryInterface.bulkDelete('likes', null, {});
await queryInterface.bulkDelete('follows', null, {});
await queryInterface.bulkDelete('messages', null, {});
await queryInterface.bulkDelete('reports', null, {});
await queryInterface.bulkDelete('moderation_actions', null, {});
await queryInterface.bulkDelete('login_audit_events', null, {});
await queryInterface.bulkDelete('site_settings', null, {});
},
};