1087 lines
18 KiB
JavaScript
1087 lines
18 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Posts = db.posts;
|
|
|
|
const Tasks = db.tasks;
|
|
|
|
const Events = db.events;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const PostsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Q2 Product Roadmap",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Overview of planned product work for Q2.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published_at": new Date('2026-03-10T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Onboarding Improvements",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Proposed changes to the new user onboarding flow.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published_at": new Date('2026-02-05T14:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Maintenance Window Notice",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Scheduled maintenance for platform updates.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published_at": new Date('2026-04-01T22:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Content Guidelines",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Best practices and style guide for published content.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published_at": new Date('2026-01-20T08:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Beta Feature Feedback",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Collecting feedback from internal testers.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published_at": new Date('2020-01-01T00:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const TasksData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Resolve login bug",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Investigate and fix intermittent login failures.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "todo",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_date": new Date('2026-02-15T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": 1,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Prepare Q2 roadmap slides",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Create presentation slides for stakeholder review.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "done",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_date": new Date('2026-03-05T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": 2,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Publish onboarding article",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Finalize and publish the onboarding improvements article.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "in_progress",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_date": new Date('2026-02-20T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": 3,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Data backup verification",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Verify backups and restore process.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "done",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_date": new Date('2026-02-28T18:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": 1,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Customer ticket triage",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Review and triage incoming support tickets.",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "in_progress",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"due_date": new Date('2026-02-10T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"priority": 2,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const EventsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Weekly Product Sync",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Conference Room B",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-02-03T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-02-03T10:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Quarterly All Hands",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Main Auditorium",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-03-25T16:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-03-25T17:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Maintenance Window",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "N/A",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-04-01T22:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-04-02T02:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Content Review Workshop",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Room 12",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-02-18T13:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-02-18T15:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Support Training Session",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"location": "Training Room",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-02-12T11:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-02-12T13:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
const relatedAuthor3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Post3 = await Posts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Post3?.setAuthor)
|
|
{
|
|
await
|
|
Post3.
|
|
setAuthor(relatedAuthor3);
|
|
}
|
|
|
|
const relatedAuthor4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Post4 = await Posts.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Post4?.setAuthor)
|
|
{
|
|
await
|
|
Post4.
|
|
setAuthor(relatedAuthor4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateTaskWithAssignee() {
|
|
|
|
const relatedAssignee0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task0 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Task0?.setAssignee)
|
|
{
|
|
await
|
|
Task0.
|
|
setAssignee(relatedAssignee0);
|
|
}
|
|
|
|
const relatedAssignee1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task1 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Task1?.setAssignee)
|
|
{
|
|
await
|
|
Task1.
|
|
setAssignee(relatedAssignee1);
|
|
}
|
|
|
|
const relatedAssignee2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task2 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Task2?.setAssignee)
|
|
{
|
|
await
|
|
Task2.
|
|
setAssignee(relatedAssignee2);
|
|
}
|
|
|
|
const relatedAssignee3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task3 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Task3?.setAssignee)
|
|
{
|
|
await
|
|
Task3.
|
|
setAssignee(relatedAssignee3);
|
|
}
|
|
|
|
const relatedAssignee4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Task4 = await Tasks.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Task4?.setAssignee)
|
|
{
|
|
await
|
|
Task4.
|
|
setAssignee(relatedAssignee4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Posts.bulkCreate(PostsData);
|
|
|
|
|
|
|
|
|
|
await Tasks.bulkCreate(TasksData);
|
|
|
|
|
|
|
|
|
|
await Events.bulkCreate(EventsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associatePostWithAuthor(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateTaskWithAssignee(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('posts', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('tasks', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('events', null, {});
|
|
|
|
|
|
},
|
|
}; |