const db = require('../models'); const Users = db.users; const Admins = db.admins; const Announcements = db.announcements; const Appointments = db.appointments; const Comments = db.comments; const Discussions = db.discussions; const Events = db.events; const Medications = db.medications; const Profiles = db.profiles; const Records = db.records; const Registrations = db.registrations; const WellnessCheckIns = db.wellness_check_ins; const AdminsData = [ { admin_username: 'superuser1', password: 'superPass123', super_access: 'TRUE', admin_role: 'System Manager', }, { admin_username: 'moderator1', password: 'modPass456', super_access: 'FALSE', admin_role: 'Content Moderator', }, { admin_username: 'editor1', password: 'editPass789', super_access: 'TRUE', admin_role: 'Content Editor', }, { admin_username: 'support1', password: 'supportPass321', super_access: 'FALSE', admin_role: 'Support Specialist', }, ]; const AnnouncementsData = [ { title: 'System Update', content: 'The system will be updated on 2023-11-15.', created_date: new Date('2023-10-01'), // type code here for "relation_one" field }, { title: 'New Features', content: 'Check out the new features added this month.', created_date: new Date('2023-10-05'), // type code here for "relation_one" field }, { title: 'Maintenance Notice', content: 'Scheduled maintenance on 2023-11-20.', created_date: new Date('2023-10-10'), // type code here for "relation_one" field }, { title: 'Event Reminder', content: "Don't forget to register for upcoming events.", created_date: new Date('2023-10-15'), // type code here for "relation_one" field }, ]; const AppointmentsData = [ { appointment_type: 'Therapy', appointment_date: new Date('2023-11-25'), description: 'Annual check-up', // type code here for "relation_one" field }, { appointment_type: 'HealthScreening', appointment_date: new Date('2023-12-01'), description: 'Knee therapy session', // type code here for "relation_one" field }, { appointment_type: 'HealthScreening', appointment_date: new Date('2023-12-10'), description: 'Mental health counseling', // type code here for "relation_one" field }, { appointment_type: 'Therapy', appointment_date: new Date('2023-12-15'), description: 'Follow-up screening', // type code here for "relation_one" field }, ]; const CommentsData = [ { // type code here for "relation_one" field // type code here for "relation_one" field comment_text: 'Meditation helps reduce stress.', comment_date: new Date('2023-10-06'), }, { // type code here for "relation_one" field // type code here for "relation_one" field comment_text: 'Exercise is also beneficial.', comment_date: new Date('2023-10-07'), }, { // type code here for "relation_one" field // type code here for "relation_one" field comment_text: 'Include more vegetables in your diet.', comment_date: new Date('2023-10-08'), }, { // type code here for "relation_one" field // type code here for "relation_one" field comment_text: 'Consistency is key to fitness.', comment_date: new Date('2023-10-09'), }, ]; const DiscussionsData = [ { topic: 'Managing Stress', created_date: new Date('2023-10-01'), // type code here for "relation_one" field }, { topic: 'Healthy Eating Tips', created_date: new Date('2023-10-02'), // type code here for "relation_one" field }, { topic: 'Exercise Routines', created_date: new Date('2023-10-03'), // type code here for "relation_one" field }, { topic: 'Mental Health Awareness', created_date: new Date('2023-10-04'), // type code here for "relation_one" field }, ]; const EventsData = [ { event_title: 'Wellness Workshop', event_desc: 'A workshop on mental health', event_date: new Date('2023-11-10'), event_location: 'Community Center', event_duration: '02:00:00', event_spots: 30, }, { event_title: 'Yoga Class', event_desc: 'Beginner yoga session', event_date: new Date('2023-11-15'), event_location: 'Local Gym', event_duration: '01:30:00', event_spots: 20, }, { event_title: 'Nutrition Seminar', event_desc: 'Healthy eating tips', event_date: new Date('2023-11-20'), event_location: 'Health Clinic', event_duration: '01:00:00', event_spots: 25, }, { event_title: 'Fitness Bootcamp', event_desc: 'Outdoor fitness activities', event_date: new Date('2023-11-25'), event_location: 'City Park', event_duration: '03:00:00', event_spots: 50, }, ]; const MedicationsData = [ { medication_name: 'Paracetamol', dosage: '500mg', frequency: 'Twice daily', start_date: new Date('2023-10-01'), end_date: new Date('2023-10-10'), reminder_time: '08:00:00', // type code here for "relation_one" field }, { medication_name: 'Ibuprofen', dosage: '200mg', frequency: 'Once daily', start_date: new Date('2023-10-05'), end_date: new Date('2023-10-15'), reminder_time: '09:00:00', // type code here for "relation_one" field }, { medication_name: 'Vitamin D', dosage: '1000 IU', frequency: 'Once daily', start_date: new Date('2023-10-10'), end_date: new Date('2023-11-10'), reminder_time: '10:00:00', // type code here for "relation_one" field }, { medication_name: 'Aspirin', dosage: '81mg', frequency: 'Once daily', start_date: new Date('2023-10-15'), end_date: new Date('2023-11-15'), reminder_time: '11:00:00', // type code here for "relation_one" field }, ]; const ProfilesData = [ { full_name: 'John Doe', nick_name: 'Johnny', gender: 'Male', language: 'English', birth_date: new Date('1990-05-15'), phone_number: '1234567890', // type code here for "relation_one" field }, { full_name: 'Jane Smith', nick_name: 'Janey', gender: 'Female', language: 'Spanish', birth_date: new Date('1985-08-22'), phone_number: '0987654321', // type code here for "relation_one" field }, { full_name: 'Michael Brown', nick_name: 'Mike', gender: 'Male', language: 'French', birth_date: new Date('1978-11-30'), phone_number: '1122334455', // type code here for "relation_one" field }, { full_name: 'Emily Jones', nick_name: 'Em', gender: 'Female', language: 'German', birth_date: new Date('1992-03-10'), phone_number: '2233445566', // type code here for "relation_one" field }, ]; const RecordsData = [ { doctor_name: 'Dr. Smith', type: 'Health Screening', assessment: 'Normal', diagnosis: 'Healthy', prescription: 'Vitamin C', record_date: new Date('2023-10-01'), // type code here for "relation_one" field }, { doctor_name: 'Dr. Johnson', type: 'Rehabilitation', assessment: 'Improved mobility', diagnosis: 'Recovery', prescription: 'Physical therapy', record_date: new Date('2023-09-15'), // type code here for "relation_one" field }, { doctor_name: 'Dr. Lee', type: 'Therapy', assessment: 'Reduced anxiety', diagnosis: 'Stable', prescription: 'Counseling', record_date: new Date('2023-08-20'), // type code here for "relation_one" field }, { doctor_name: 'Dr. Kim', type: 'Health Screening', assessment: 'High cholesterol', diagnosis: 'Hyperlipidemia', prescription: 'Dietary changes', record_date: new Date('2023-07-10'), // type code here for "relation_one" field }, ]; const RegistrationsData = [ { full_name: 'John Doe', email_address: 'john.doe@example.com', phone_number: '1234567890', registration_date: new Date('2023-10-01'), special_req: 'None', // type code here for "relation_one" field // type code here for "relation_one" field }, { full_name: 'Jane Smith', email_address: 'jane.smith@example.com', phone_number: '0987654321', registration_date: new Date('2023-10-02'), special_req: 'Vegan meal', // type code here for "relation_one" field // type code here for "relation_one" field }, { full_name: 'Michael Brown', email_address: 'michael.brown@example.com', phone_number: '1122334455', registration_date: new Date('2023-10-03'), special_req: 'Wheelchair access', // type code here for "relation_one" field // type code here for "relation_one" field }, { full_name: 'Emily Jones', email_address: 'emily.jones@example.com', phone_number: '2233445566', registration_date: new Date('2023-10-04'), special_req: 'Sign language interpreter', // type code here for "relation_one" field // type code here for "relation_one" field }, ]; const WellnessCheckInsData = [ { check_in_date: new Date('2023-10-01'), mood: 'Happy', energy_level: 8, sleep_hours: 7.5, notes: 'Feeling great today.', // type code here for "relation_one" field }, { check_in_date: new Date('2023-10-02'), mood: 'Tired', energy_level: 5, sleep_hours: 6, notes: 'Need more rest.', // type code here for "relation_one" field }, { check_in_date: new Date('2023-10-03'), mood: 'Anxious', energy_level: 4, sleep_hours: 5.5, notes: 'Work stress.', // type code here for "relation_one" field }, { check_in_date: new Date('2023-10-04'), mood: 'Relaxed', energy_level: 7, sleep_hours: 8, notes: 'Good day overall.', // type code here for "relation_one" field }, ]; // Similar logic for "relation_many" async function associateAnnouncementWithUser() { const relatedUser0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Announcement0 = await Announcements.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Announcement0?.setUser) { await Announcement0.setUser(relatedUser0); } const relatedUser1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Announcement1 = await Announcements.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Announcement1?.setUser) { await Announcement1.setUser(relatedUser1); } const relatedUser2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Announcement2 = await Announcements.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Announcement2?.setUser) { await Announcement2.setUser(relatedUser2); } const relatedUser3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Announcement3 = await Announcements.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Announcement3?.setUser) { await Announcement3.setUser(relatedUser3); } } async function associateAppointmentWithUser() { const relatedUser0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Appointment0 = await Appointments.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Appointment0?.setUser) { await Appointment0.setUser(relatedUser0); } const relatedUser1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Appointment1 = await Appointments.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Appointment1?.setUser) { await Appointment1.setUser(relatedUser1); } const relatedUser2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Appointment2 = await Appointments.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Appointment2?.setUser) { await Appointment2.setUser(relatedUser2); } const relatedUser3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Appointment3 = await Appointments.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Appointment3?.setUser) { await Appointment3.setUser(relatedUser3); } } async function associateCommentWithDiscussion() { const relatedDiscussion0 = await Discussions.findOne({ offset: Math.floor(Math.random() * (await Discussions.count())), }); const Comment0 = await Comments.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Comment0?.setDiscussion) { await Comment0.setDiscussion(relatedDiscussion0); } const relatedDiscussion1 = await Discussions.findOne({ offset: Math.floor(Math.random() * (await Discussions.count())), }); const Comment1 = await Comments.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Comment1?.setDiscussion) { await Comment1.setDiscussion(relatedDiscussion1); } const relatedDiscussion2 = await Discussions.findOne({ offset: Math.floor(Math.random() * (await Discussions.count())), }); const Comment2 = await Comments.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Comment2?.setDiscussion) { await Comment2.setDiscussion(relatedDiscussion2); } const relatedDiscussion3 = await Discussions.findOne({ offset: Math.floor(Math.random() * (await Discussions.count())), }); const Comment3 = await Comments.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Comment3?.setDiscussion) { await Comment3.setDiscussion(relatedDiscussion3); } } async function associateCommentWithUser() { const relatedUser0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Comment0 = await Comments.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Comment0?.setUser) { await Comment0.setUser(relatedUser0); } const relatedUser1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Comment1 = await Comments.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Comment1?.setUser) { await Comment1.setUser(relatedUser1); } const relatedUser2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Comment2 = await Comments.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Comment2?.setUser) { await Comment2.setUser(relatedUser2); } const relatedUser3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Comment3 = await Comments.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Comment3?.setUser) { await Comment3.setUser(relatedUser3); } } async function associateDiscussionWithUser() { const relatedUser0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Discussion0 = await Discussions.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Discussion0?.setUser) { await Discussion0.setUser(relatedUser0); } const relatedUser1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Discussion1 = await Discussions.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Discussion1?.setUser) { await Discussion1.setUser(relatedUser1); } const relatedUser2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Discussion2 = await Discussions.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Discussion2?.setUser) { await Discussion2.setUser(relatedUser2); } const relatedUser3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Discussion3 = await Discussions.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Discussion3?.setUser) { await Discussion3.setUser(relatedUser3); } } async function associateMedicationWithUser() { const relatedUser0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Medication0 = await Medications.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Medication0?.setUser) { await Medication0.setUser(relatedUser0); } const relatedUser1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Medication1 = await Medications.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Medication1?.setUser) { await Medication1.setUser(relatedUser1); } const relatedUser2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Medication2 = await Medications.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Medication2?.setUser) { await Medication2.setUser(relatedUser2); } const relatedUser3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Medication3 = await Medications.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Medication3?.setUser) { await Medication3.setUser(relatedUser3); } } async function associateProfileWithUser() { const relatedUser0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Profile0 = await Profiles.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Profile0?.setUser) { await Profile0.setUser(relatedUser0); } const relatedUser1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Profile1 = await Profiles.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Profile1?.setUser) { await Profile1.setUser(relatedUser1); } const relatedUser2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Profile2 = await Profiles.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Profile2?.setUser) { await Profile2.setUser(relatedUser2); } const relatedUser3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Profile3 = await Profiles.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Profile3?.setUser) { await Profile3.setUser(relatedUser3); } } async function associateRecordWithUser() { const relatedUser0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Record0 = await Records.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Record0?.setUser) { await Record0.setUser(relatedUser0); } const relatedUser1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Record1 = await Records.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Record1?.setUser) { await Record1.setUser(relatedUser1); } const relatedUser2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Record2 = await Records.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Record2?.setUser) { await Record2.setUser(relatedUser2); } const relatedUser3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Record3 = await Records.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Record3?.setUser) { await Record3.setUser(relatedUser3); } } async function associateRegistrationWithUser() { const relatedUser0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Registration0 = await Registrations.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Registration0?.setUser) { await Registration0.setUser(relatedUser0); } const relatedUser1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Registration1 = await Registrations.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Registration1?.setUser) { await Registration1.setUser(relatedUser1); } const relatedUser2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Registration2 = await Registrations.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Registration2?.setUser) { await Registration2.setUser(relatedUser2); } const relatedUser3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const Registration3 = await Registrations.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Registration3?.setUser) { await Registration3.setUser(relatedUser3); } } async function associateRegistrationWithEvent() { const relatedEvent0 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Registration0 = await Registrations.findOne({ order: [['id', 'ASC']], offset: 0, }); if (Registration0?.setEvent) { await Registration0.setEvent(relatedEvent0); } const relatedEvent1 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Registration1 = await Registrations.findOne({ order: [['id', 'ASC']], offset: 1, }); if (Registration1?.setEvent) { await Registration1.setEvent(relatedEvent1); } const relatedEvent2 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Registration2 = await Registrations.findOne({ order: [['id', 'ASC']], offset: 2, }); if (Registration2?.setEvent) { await Registration2.setEvent(relatedEvent2); } const relatedEvent3 = await Events.findOne({ offset: Math.floor(Math.random() * (await Events.count())), }); const Registration3 = await Registrations.findOne({ order: [['id', 'ASC']], offset: 3, }); if (Registration3?.setEvent) { await Registration3.setEvent(relatedEvent3); } } async function associateWellnessCheckInWithUser() { const relatedUser0 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const WellnessCheckIn0 = await WellnessCheckIns.findOne({ order: [['id', 'ASC']], offset: 0, }); if (WellnessCheckIn0?.setUser) { await WellnessCheckIn0.setUser(relatedUser0); } const relatedUser1 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const WellnessCheckIn1 = await WellnessCheckIns.findOne({ order: [['id', 'ASC']], offset: 1, }); if (WellnessCheckIn1?.setUser) { await WellnessCheckIn1.setUser(relatedUser1); } const relatedUser2 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const WellnessCheckIn2 = await WellnessCheckIns.findOne({ order: [['id', 'ASC']], offset: 2, }); if (WellnessCheckIn2?.setUser) { await WellnessCheckIn2.setUser(relatedUser2); } const relatedUser3 = await Users.findOne({ offset: Math.floor(Math.random() * (await Users.count())), }); const WellnessCheckIn3 = await WellnessCheckIns.findOne({ order: [['id', 'ASC']], offset: 3, }); if (WellnessCheckIn3?.setUser) { await WellnessCheckIn3.setUser(relatedUser3); } } module.exports = { up: async (queryInterface, Sequelize) => { await Admins.bulkCreate(AdminsData); await Announcements.bulkCreate(AnnouncementsData); await Appointments.bulkCreate(AppointmentsData); await Comments.bulkCreate(CommentsData); await Discussions.bulkCreate(DiscussionsData); await Events.bulkCreate(EventsData); await Medications.bulkCreate(MedicationsData); await Profiles.bulkCreate(ProfilesData); await Records.bulkCreate(RecordsData); await Registrations.bulkCreate(RegistrationsData); await WellnessCheckIns.bulkCreate(WellnessCheckInsData); await Promise.all([ // Similar logic for "relation_many" await associateAnnouncementWithUser(), await associateAppointmentWithUser(), await associateCommentWithDiscussion(), await associateCommentWithUser(), await associateDiscussionWithUser(), await associateMedicationWithUser(), await associateProfileWithUser(), await associateRecordWithUser(), await associateRegistrationWithUser(), await associateRegistrationWithEvent(), await associateWellnessCheckInWithUser(), ]); }, down: async (queryInterface, Sequelize) => { await queryInterface.bulkDelete('admins', null, {}); await queryInterface.bulkDelete('announcements', null, {}); await queryInterface.bulkDelete('appointments', null, {}); await queryInterface.bulkDelete('comments', null, {}); await queryInterface.bulkDelete('discussions', null, {}); await queryInterface.bulkDelete('events', null, {}); await queryInterface.bulkDelete('medications', null, {}); await queryInterface.bulkDelete('profiles', null, {}); await queryInterface.bulkDelete('records', null, {}); await queryInterface.bulkDelete('registrations', null, {}); await queryInterface.bulkDelete('wellness_check_ins', null, {}); }, };