38255-vm/backend/src/db/seeders/20231127130745-sample-data.js
2026-02-06 22:07:52 +00:00

2309 lines
44 KiB
JavaScript

const db = require('../models');
const Users = db.users;
const Categories = db.categories;
const ContentItems = db.content_items;
const ImportJobs = db.import_jobs;
const PublishBatches = db.publish_batches;
const WelcomeUpdates = db.welcome_updates;
const SiteSettings = db.site_settings;
const ContentEvents = db.content_events;
const CategoriesData = [
{
"name": "Add-Ons",
"slug": "add-ons",
"description": "Gameplay enhancements and behavior packs for Minecraft Bedrock.",
"sort_order": 1,
"is_active": true,
},
{
"name": "Worlds",
"slug": "worlds",
"description": "Custom maps, survival spawns, and adventure worlds.",
"sort_order": 2,
"is_active": true,
},
{
"name": "SkinPacks",
"slug": "skinpacks",
"description": "Character skins and themed skin collections.",
"sort_order": 3,
"is_active": true,
},
];
const ContentItemsData = [
{
"name": "Aurora Survival Add-On",
"description": "Adds ambient effects, improved nights, and lightweight survival enhancements.",
"version": "1.4.2",
"content_type": "worlds",
// type code here for "relation_one" field
"availability_status": "not_available",
// type code here for "images" field
"download_url": "https://downloads.zyronixmc.example/aurora-survival-addon-1.4.2.mcaddon",
"trailer_youtube_url": "https://www.youtube.com/watch?v=9bZkp7q19f0",
"has_trailer": true,
"source_page_url": "https://marketplace.example/items/aurora-survival-addon",
"published_at": new Date('2026-01-15T14:00:00Z'),
"last_updated_at": new Date('2026-01-30T18:20:00Z'),
"is_published": true,
"downloads_count": 12450,
"views_count": 48210,
// type code here for "relation_one" field
},
{
"name": "Sky Islands Adventure World",
"description": "A handcrafted sky-islands map with quests, hidden loot, and balanced progression.",
"version": "2.0.0",
"content_type": "add_ons",
// type code here for "relation_one" field
"availability_status": "not_available",
// type code here for "images" field
"download_url": "https://downloads.zyronixmc.example/sky-islands-adventure-world-2.0.0.mcworld",
"trailer_youtube_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"has_trailer": true,
"source_page_url": "https://marketplace.example/items/sky-islands-adventure-world",
"published_at": new Date('2026-01-10T10:00:00Z'),
"last_updated_at": new Date('2026-01-28T16:05:00Z'),
"is_published": true,
"downloads_count": 8920,
"views_count": 30110,
// type code here for "relation_one" field
},
{
"name": "Neon City Texture Pack",
"description": "High-contrast neon textures with clean UI elements for a futuristic look.",
"version": "1.1.7",
"content_type": "worlds",
// type code here for "relation_one" field
"availability_status": "not_available",
// type code here for "images" field
"download_url": "https://downloads.zyronixmc.example/neon-city-texture-pack-1.1.7.mcpack",
"trailer_youtube_url": "https://www.youtube.com/watch?v=3JZ_D3ELwOQ",
"has_trailer": true,
"source_page_url": "https://mods.example/neon-city-texture-pack",
"published_at": new Date('2026-01-20T09:30:00Z'),
"last_updated_at": new Date('2026-02-01T11:45:00Z'),
"is_published": true,
"downloads_count": 15670,
"views_count": 54990,
// type code here for "relation_one" field
},
];
const ImportJobsData = [
{
// type code here for "relation_one" field
"source_url": "https://marketplace.example/items/aurora-survival-addon",
"status": "failed",
"error_message": "None",
"fetched_name": "Aurora Survival Add-On",
"fetched_description": "Adds ambient effects, improved nights, and lightweight survival enhancements.",
"fetched_version": "1.4.2",
// type code here for "images" field
"fetched_trailer_youtube_url": "https://www.youtube.com/watch?v=9bZkp7q19f0",
"suggested_content_type": "worlds",
// type code here for "relation_one" field
// type code here for "relation_one" field
"started_at": new Date('2026-01-14T13:50:00Z'),
"finished_at": new Date('2026-01-14T13:52:30Z'),
},
{
// type code here for "relation_one" field
"source_url": "https://marketplace.example/items/sky-islands-adventure-world",
"status": "queued",
"error_message": "None",
"fetched_name": "Sky Islands Adventure World",
"fetched_description": "A handcrafted sky-islands map with quests, hidden loot, and balanced progression.",
"fetched_version": "2.0.0",
// type code here for "images" field
"fetched_trailer_youtube_url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
"suggested_content_type": "worlds",
// type code here for "relation_one" field
// type code here for "relation_one" field
"started_at": new Date('2026-01-09T09:10:00Z'),
"finished_at": new Date('2026-01-09T09:12:40Z'),
},
{
// type code here for "relation_one" field
"source_url": "https://mods.example/neon-city-texture-pack",
"status": "failed",
"error_message": "None",
"fetched_name": "Neon City Texture Pack",
"fetched_description": "High-contrast neon textures with clean UI elements for a futuristic look.",
"fetched_version": "1.1.7",
// type code here for "images" field
"fetched_trailer_youtube_url": "https://www.youtube.com/watch?v=3JZ_D3ELwOQ",
"suggested_content_type": "add_ons",
// type code here for "relation_one" field
// type code here for "relation_one" field
"started_at": new Date('2026-01-19T08:25:00Z'),
"finished_at": new Date('2026-01-19T08:26:55Z'),
},
];
const PublishBatchesData = [
{
// type code here for "relation_one" field
"status": "published",
"started_at": new Date('2026-01-05T11:50:00Z'),
"finished_at": new Date('2026-01-05T11:55:00Z'),
"notes": "Initial launch content set",
// type code here for "relation_many" field
},
{
// type code here for "relation_one" field
"status": "publishing",
"started_at": new Date('2026-01-20T09:10:00Z'),
"finished_at": new Date('2026-01-20T09:12:00Z'),
"notes": "Added texture pack highlights",
// type code here for "relation_many" field
},
{
// type code here for "relation_one" field
"status": "draft",
"started_at": new Date('2026-01-28T15:55:00Z'),
"finished_at": new Date('2026-01-28T16:00:00Z'),
"notes": "Routine metadata updates and fixes",
// type code here for "relation_many" field
},
];
const WelcomeUpdatesData = [
{
"version_label": "1.0.0",
"message": "Welcome to ZyronixMC Content Hub. Browse, watch trailers, and download your favorite Bedrock content.",
"is_active": false,
"starts_at": new Date('2026-01-05T00:00:00Z'),
"ends_at": new Date('2026-01-12T00:00:00Z'),
// type code here for "relation_one" field
},
{
"version_label": "1.1.0",
"message": "New category pages and faster global search. Thanks for supporting ZyronixMC.",
"is_active": false,
"starts_at": new Date('2026-01-20T00:00:00Z'),
"ends_at": new Date('2026-01-27T00:00:00Z'),
// type code here for "relation_one" field
},
{
"version_label": "1.2.0",
"message": "Improved content cards and smoother dark mode transitions.",
"is_active": true,
"starts_at": new Date('2026-02-01T00:00:00Z'),
"ends_at": new Date('2026-02-15T00:00:00Z'),
// type code here for "relation_one" field
},
];
const SiteSettingsData = [
{
"site_name": "ZyronixMC",
"logo_text": "ZyronixMC",
// type code here for "images" field
"telegram_channel_url": "https://t.me/ZyronixMC",
"default_dark_mode": true,
"footer_cta_label": "Join Our Telegram Channel",
},
{
"site_name": "ZyronixMC Staging",
"logo_text": "ZyronixMC",
// type code here for "images" field
"telegram_channel_url": "https://t.me/ZyronixMC",
"default_dark_mode": true,
"footer_cta_label": "Join Our Telegram Channel",
},
{
"site_name": "ZyronixMC QA",
"logo_text": "ZyronixMC",
// type code here for "images" field
"telegram_channel_url": "https://t.me/ZyronixMC",
"default_dark_mode": true,
"footer_cta_label": "Join Our Telegram Channel",
},
];
const ContentEventsData = [
{
// type code here for "relation_one" field
"event_type": "download",
"visitor_session_key": "sess_9f3a2c7b1d",
"visitor_ip_hash": "ip_6f2a9c1e3b",
"user_agent": "Mozilla/5.0 Windows NT 10.0 Chrome/121.0",
"occurred_at": new Date('2026-02-05T09:15:10Z'),
"referrer_url": "https://zyronixmc.example/add-ons",
},
{
// type code here for "relation_one" field
"event_type": "view",
"visitor_session_key": "sess_9f3a2c7b1d",
"visitor_ip_hash": "ip_6f2a9c1e3b",
"user_agent": "Mozilla/5.0 Windows NT 10.0 Chrome/121.0",
"occurred_at": new Date('2026-02-05T09:16:02Z'),
"referrer_url": "https://zyronixmc.example/add-ons",
},
{
// type code here for "relation_one" field
"event_type": "view",
"visitor_session_key": "sess_1a7d4c2e8f",
"visitor_ip_hash": "ip_1c7e3a9b2d",
"user_agent": "Mozilla/5.0 iPhone OS 17_2 Safari/605.1.15",
"occurred_at": new Date('2026-02-05T18:40:44Z'),
"referrer_url": "https://zyronixmc.example/worlds",
},
];
// Similar logic for "relation_many"
async function associateContentItemWithCategory() {
const relatedCategory0 = await Categories.findOne({
offset: Math.floor(Math.random() * (await Categories.count())),
});
const ContentItem0 = await ContentItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ContentItem0?.setCategory)
{
await
ContentItem0.
setCategory(relatedCategory0);
}
const relatedCategory1 = await Categories.findOne({
offset: Math.floor(Math.random() * (await Categories.count())),
});
const ContentItem1 = await ContentItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ContentItem1?.setCategory)
{
await
ContentItem1.
setCategory(relatedCategory1);
}
const relatedCategory2 = await Categories.findOne({
offset: Math.floor(Math.random() * (await Categories.count())),
});
const ContentItem2 = await ContentItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ContentItem2?.setCategory)
{
await
ContentItem2.
setCategory(relatedCategory2);
}
}
async function associateContentItemWithCreated_by_user() {
const relatedCreated_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ContentItem0 = await ContentItems.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ContentItem0?.setCreated_by_user)
{
await
ContentItem0.
setCreated_by_user(relatedCreated_by_user0);
}
const relatedCreated_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ContentItem1 = await ContentItems.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ContentItem1?.setCreated_by_user)
{
await
ContentItem1.
setCreated_by_user(relatedCreated_by_user1);
}
const relatedCreated_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ContentItem2 = await ContentItems.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ContentItem2?.setCreated_by_user)
{
await
ContentItem2.
setCreated_by_user(relatedCreated_by_user2);
}
}
async function associateImportJobWithRequested_by_user() {
const relatedRequested_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ImportJob0 = await ImportJobs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ImportJob0?.setRequested_by_user)
{
await
ImportJob0.
setRequested_by_user(relatedRequested_by_user0);
}
const relatedRequested_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ImportJob1 = await ImportJobs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ImportJob1?.setRequested_by_user)
{
await
ImportJob1.
setRequested_by_user(relatedRequested_by_user1);
}
const relatedRequested_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const ImportJob2 = await ImportJobs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ImportJob2?.setRequested_by_user)
{
await
ImportJob2.
setRequested_by_user(relatedRequested_by_user2);
}
}
async function associateImportJobWithSuggested_category() {
const relatedSuggested_category0 = await Categories.findOne({
offset: Math.floor(Math.random() * (await Categories.count())),
});
const ImportJob0 = await ImportJobs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ImportJob0?.setSuggested_category)
{
await
ImportJob0.
setSuggested_category(relatedSuggested_category0);
}
const relatedSuggested_category1 = await Categories.findOne({
offset: Math.floor(Math.random() * (await Categories.count())),
});
const ImportJob1 = await ImportJobs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ImportJob1?.setSuggested_category)
{
await
ImportJob1.
setSuggested_category(relatedSuggested_category1);
}
const relatedSuggested_category2 = await Categories.findOne({
offset: Math.floor(Math.random() * (await Categories.count())),
});
const ImportJob2 = await ImportJobs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ImportJob2?.setSuggested_category)
{
await
ImportJob2.
setSuggested_category(relatedSuggested_category2);
}
}
async function associateImportJobWithDraft_content_item() {
const relatedDraft_content_item0 = await ContentItems.findOne({
offset: Math.floor(Math.random() * (await ContentItems.count())),
});
const ImportJob0 = await ImportJobs.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ImportJob0?.setDraft_content_item)
{
await
ImportJob0.
setDraft_content_item(relatedDraft_content_item0);
}
const relatedDraft_content_item1 = await ContentItems.findOne({
offset: Math.floor(Math.random() * (await ContentItems.count())),
});
const ImportJob1 = await ImportJobs.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ImportJob1?.setDraft_content_item)
{
await
ImportJob1.
setDraft_content_item(relatedDraft_content_item1);
}
const relatedDraft_content_item2 = await ContentItems.findOne({
offset: Math.floor(Math.random() * (await ContentItems.count())),
});
const ImportJob2 = await ImportJobs.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ImportJob2?.setDraft_content_item)
{
await
ImportJob2.
setDraft_content_item(relatedDraft_content_item2);
}
}
async function associatePublishBatcheWithPublished_by_user() {
const relatedPublished_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PublishBatche0 = await PublishBatches.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (PublishBatche0?.setPublished_by_user)
{
await
PublishBatche0.
setPublished_by_user(relatedPublished_by_user0);
}
const relatedPublished_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PublishBatche1 = await PublishBatches.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (PublishBatche1?.setPublished_by_user)
{
await
PublishBatche1.
setPublished_by_user(relatedPublished_by_user1);
}
const relatedPublished_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const PublishBatche2 = await PublishBatches.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (PublishBatche2?.setPublished_by_user)
{
await
PublishBatche2.
setPublished_by_user(relatedPublished_by_user2);
}
}
// Similar logic for "relation_many"
async function associateWelcomeUpdateWithCreated_by_user() {
const relatedCreated_by_user0 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WelcomeUpdate0 = await WelcomeUpdates.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (WelcomeUpdate0?.setCreated_by_user)
{
await
WelcomeUpdate0.
setCreated_by_user(relatedCreated_by_user0);
}
const relatedCreated_by_user1 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WelcomeUpdate1 = await WelcomeUpdates.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (WelcomeUpdate1?.setCreated_by_user)
{
await
WelcomeUpdate1.
setCreated_by_user(relatedCreated_by_user1);
}
const relatedCreated_by_user2 = await Users.findOne({
offset: Math.floor(Math.random() * (await Users.count())),
});
const WelcomeUpdate2 = await WelcomeUpdates.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (WelcomeUpdate2?.setCreated_by_user)
{
await
WelcomeUpdate2.
setCreated_by_user(relatedCreated_by_user2);
}
}
async function associateContentEventWithContent_item() {
const relatedContent_item0 = await ContentItems.findOne({
offset: Math.floor(Math.random() * (await ContentItems.count())),
});
const ContentEvent0 = await ContentEvents.findOne({
order: [['id', 'ASC']],
offset: 0
});
if (ContentEvent0?.setContent_item)
{
await
ContentEvent0.
setContent_item(relatedContent_item0);
}
const relatedContent_item1 = await ContentItems.findOne({
offset: Math.floor(Math.random() * (await ContentItems.count())),
});
const ContentEvent1 = await ContentEvents.findOne({
order: [['id', 'ASC']],
offset: 1
});
if (ContentEvent1?.setContent_item)
{
await
ContentEvent1.
setContent_item(relatedContent_item1);
}
const relatedContent_item2 = await ContentItems.findOne({
offset: Math.floor(Math.random() * (await ContentItems.count())),
});
const ContentEvent2 = await ContentEvents.findOne({
order: [['id', 'ASC']],
offset: 2
});
if (ContentEvent2?.setContent_item)
{
await
ContentEvent2.
setContent_item(relatedContent_item2);
}
}
module.exports = {
up: async (queryInterface, Sequelize) => {
await Categories.bulkCreate(CategoriesData);
await ContentItems.bulkCreate(ContentItemsData);
await ImportJobs.bulkCreate(ImportJobsData);
await PublishBatches.bulkCreate(PublishBatchesData);
await WelcomeUpdates.bulkCreate(WelcomeUpdatesData);
await SiteSettings.bulkCreate(SiteSettingsData);
await ContentEvents.bulkCreate(ContentEventsData);
await Promise.all([
// Similar logic for "relation_many"
await associateContentItemWithCategory(),
await associateContentItemWithCreated_by_user(),
await associateImportJobWithRequested_by_user(),
await associateImportJobWithSuggested_category(),
await associateImportJobWithDraft_content_item(),
await associatePublishBatcheWithPublished_by_user(),
// Similar logic for "relation_many"
await associateWelcomeUpdateWithCreated_by_user(),
await associateContentEventWithContent_item(),
]);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.bulkDelete('categories', null, {});
await queryInterface.bulkDelete('content_items', null, {});
await queryInterface.bulkDelete('import_jobs', null, {});
await queryInterface.bulkDelete('publish_batches', null, {});
await queryInterface.bulkDelete('welcome_updates', null, {});
await queryInterface.bulkDelete('site_settings', null, {});
await queryInterface.bulkDelete('content_events', null, {});
},
};