824 lines
19 KiB
JavaScript
824 lines
19 KiB
JavaScript
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
const Categories = db.categories;
|
|
|
|
const Menus = db.menus;
|
|
|
|
const Products = db.products;
|
|
|
|
const QrCodes = db.qr_codes;
|
|
|
|
const Organizations = db.organizations;
|
|
|
|
const CategoriesData = [
|
|
{
|
|
name: 'Appetizers',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Main Courses',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Desserts',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Beverages',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Salads',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const MenusData = [
|
|
{
|
|
name: 'Main Menu',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Lunch Specials',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Dinner Menu',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Weekend Brunch',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Kids Menu',
|
|
|
|
// type code here for "relation_many" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const ProductsData = [
|
|
{
|
|
name: 'Caesar Salad',
|
|
|
|
description: 'Fresh romaine lettuce with Caesar dressing',
|
|
|
|
price: 7.99,
|
|
|
|
// type code here for "images" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Grilled Chicken',
|
|
|
|
description: 'Juicy grilled chicken breast',
|
|
|
|
price: 12.99,
|
|
|
|
// type code here for "images" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Chocolate Cake',
|
|
|
|
description: 'Rich chocolate cake with ganache',
|
|
|
|
price: 5.99,
|
|
|
|
// type code here for "images" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Lemonade',
|
|
|
|
description: 'Refreshing homemade lemonade',
|
|
|
|
price: 2.99,
|
|
|
|
// type code here for "images" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
name: 'Pasta Primavera',
|
|
|
|
description: 'Pasta with fresh vegetables',
|
|
|
|
price: 10.99,
|
|
|
|
// type code here for "images" field
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const QrCodesData = [
|
|
{
|
|
code: 'QR12345',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
code: 'QR67890',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
code: 'QR11223',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
code: 'QR44556',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
|
|
{
|
|
code: 'QR77889',
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
// type code here for "relation_one" field
|
|
},
|
|
];
|
|
|
|
const OrganizationsData = [
|
|
{
|
|
name: 'Louis Victor de Broglie',
|
|
},
|
|
|
|
{
|
|
name: 'Alfred Kinsey',
|
|
},
|
|
|
|
{
|
|
name: 'Albrecht von Haller',
|
|
},
|
|
|
|
{
|
|
name: 'William Herschel',
|
|
},
|
|
|
|
{
|
|
name: 'Carl Linnaeus',
|
|
},
|
|
];
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateUserWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User0 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (User0?.setOrganization) {
|
|
await User0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User1 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (User1?.setOrganization) {
|
|
await User1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User2 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (User2?.setOrganization) {
|
|
await User2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User3 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (User3?.setOrganization) {
|
|
await User3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const User4 = await Users.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (User4?.setOrganization) {
|
|
await User4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateCategoryWithMenu() {
|
|
const relatedMenu0 = await Menus.findOne({
|
|
offset: Math.floor(Math.random() * (await Menus.count())),
|
|
});
|
|
const Category0 = await Categories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Category0?.setMenu) {
|
|
await Category0.setMenu(relatedMenu0);
|
|
}
|
|
|
|
const relatedMenu1 = await Menus.findOne({
|
|
offset: Math.floor(Math.random() * (await Menus.count())),
|
|
});
|
|
const Category1 = await Categories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Category1?.setMenu) {
|
|
await Category1.setMenu(relatedMenu1);
|
|
}
|
|
|
|
const relatedMenu2 = await Menus.findOne({
|
|
offset: Math.floor(Math.random() * (await Menus.count())),
|
|
});
|
|
const Category2 = await Categories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Category2?.setMenu) {
|
|
await Category2.setMenu(relatedMenu2);
|
|
}
|
|
|
|
const relatedMenu3 = await Menus.findOne({
|
|
offset: Math.floor(Math.random() * (await Menus.count())),
|
|
});
|
|
const Category3 = await Categories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Category3?.setMenu) {
|
|
await Category3.setMenu(relatedMenu3);
|
|
}
|
|
|
|
const relatedMenu4 = await Menus.findOne({
|
|
offset: Math.floor(Math.random() * (await Menus.count())),
|
|
});
|
|
const Category4 = await Categories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Category4?.setMenu) {
|
|
await Category4.setMenu(relatedMenu4);
|
|
}
|
|
}
|
|
|
|
async function associateCategoryWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Category0 = await Categories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Category0?.setOrganization) {
|
|
await Category0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Category1 = await Categories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Category1?.setOrganization) {
|
|
await Category1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Category2 = await Categories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Category2?.setOrganization) {
|
|
await Category2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Category3 = await Categories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Category3?.setOrganization) {
|
|
await Category3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Category4 = await Categories.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Category4?.setOrganization) {
|
|
await Category4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
async function associateMenuWithOwner() {
|
|
const relatedOwner0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Menu0 = await Menus.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Menu0?.setOwner) {
|
|
await Menu0.setOwner(relatedOwner0);
|
|
}
|
|
|
|
const relatedOwner1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Menu1 = await Menus.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Menu1?.setOwner) {
|
|
await Menu1.setOwner(relatedOwner1);
|
|
}
|
|
|
|
const relatedOwner2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Menu2 = await Menus.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Menu2?.setOwner) {
|
|
await Menu2.setOwner(relatedOwner2);
|
|
}
|
|
|
|
const relatedOwner3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Menu3 = await Menus.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Menu3?.setOwner) {
|
|
await Menu3.setOwner(relatedOwner3);
|
|
}
|
|
|
|
const relatedOwner4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Menu4 = await Menus.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Menu4?.setOwner) {
|
|
await Menu4.setOwner(relatedOwner4);
|
|
}
|
|
}
|
|
|
|
async function associateMenuWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Menu0 = await Menus.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Menu0?.setOrganization) {
|
|
await Menu0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Menu1 = await Menus.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Menu1?.setOrganization) {
|
|
await Menu1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Menu2 = await Menus.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Menu2?.setOrganization) {
|
|
await Menu2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Menu3 = await Menus.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Menu3?.setOrganization) {
|
|
await Menu3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Menu4 = await Menus.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Menu4?.setOrganization) {
|
|
await Menu4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateProductWithCategory() {
|
|
const relatedCategory0 = await Categories.findOne({
|
|
offset: Math.floor(Math.random() * (await Categories.count())),
|
|
});
|
|
const Product0 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Product0?.setCategory) {
|
|
await Product0.setCategory(relatedCategory0);
|
|
}
|
|
|
|
const relatedCategory1 = await Categories.findOne({
|
|
offset: Math.floor(Math.random() * (await Categories.count())),
|
|
});
|
|
const Product1 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Product1?.setCategory) {
|
|
await Product1.setCategory(relatedCategory1);
|
|
}
|
|
|
|
const relatedCategory2 = await Categories.findOne({
|
|
offset: Math.floor(Math.random() * (await Categories.count())),
|
|
});
|
|
const Product2 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Product2?.setCategory) {
|
|
await Product2.setCategory(relatedCategory2);
|
|
}
|
|
|
|
const relatedCategory3 = await Categories.findOne({
|
|
offset: Math.floor(Math.random() * (await Categories.count())),
|
|
});
|
|
const Product3 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Product3?.setCategory) {
|
|
await Product3.setCategory(relatedCategory3);
|
|
}
|
|
|
|
const relatedCategory4 = await Categories.findOne({
|
|
offset: Math.floor(Math.random() * (await Categories.count())),
|
|
});
|
|
const Product4 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Product4?.setCategory) {
|
|
await Product4.setCategory(relatedCategory4);
|
|
}
|
|
}
|
|
|
|
async function associateProductWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Product0 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (Product0?.setOrganization) {
|
|
await Product0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Product1 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (Product1?.setOrganization) {
|
|
await Product1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Product2 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (Product2?.setOrganization) {
|
|
await Product2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Product3 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (Product3?.setOrganization) {
|
|
await Product3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const Product4 = await Products.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (Product4?.setOrganization) {
|
|
await Product4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
async function associateQrCodeWithMenu() {
|
|
const relatedMenu0 = await Menus.findOne({
|
|
offset: Math.floor(Math.random() * (await Menus.count())),
|
|
});
|
|
const QrCode0 = await QrCodes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (QrCode0?.setMenu) {
|
|
await QrCode0.setMenu(relatedMenu0);
|
|
}
|
|
|
|
const relatedMenu1 = await Menus.findOne({
|
|
offset: Math.floor(Math.random() * (await Menus.count())),
|
|
});
|
|
const QrCode1 = await QrCodes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (QrCode1?.setMenu) {
|
|
await QrCode1.setMenu(relatedMenu1);
|
|
}
|
|
|
|
const relatedMenu2 = await Menus.findOne({
|
|
offset: Math.floor(Math.random() * (await Menus.count())),
|
|
});
|
|
const QrCode2 = await QrCodes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (QrCode2?.setMenu) {
|
|
await QrCode2.setMenu(relatedMenu2);
|
|
}
|
|
|
|
const relatedMenu3 = await Menus.findOne({
|
|
offset: Math.floor(Math.random() * (await Menus.count())),
|
|
});
|
|
const QrCode3 = await QrCodes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (QrCode3?.setMenu) {
|
|
await QrCode3.setMenu(relatedMenu3);
|
|
}
|
|
|
|
const relatedMenu4 = await Menus.findOne({
|
|
offset: Math.floor(Math.random() * (await Menus.count())),
|
|
});
|
|
const QrCode4 = await QrCodes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (QrCode4?.setMenu) {
|
|
await QrCode4.setMenu(relatedMenu4);
|
|
}
|
|
}
|
|
|
|
async function associateQrCodeWithOrganization() {
|
|
const relatedOrganization0 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const QrCode0 = await QrCodes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0,
|
|
});
|
|
if (QrCode0?.setOrganization) {
|
|
await QrCode0.setOrganization(relatedOrganization0);
|
|
}
|
|
|
|
const relatedOrganization1 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const QrCode1 = await QrCodes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1,
|
|
});
|
|
if (QrCode1?.setOrganization) {
|
|
await QrCode1.setOrganization(relatedOrganization1);
|
|
}
|
|
|
|
const relatedOrganization2 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const QrCode2 = await QrCodes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2,
|
|
});
|
|
if (QrCode2?.setOrganization) {
|
|
await QrCode2.setOrganization(relatedOrganization2);
|
|
}
|
|
|
|
const relatedOrganization3 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const QrCode3 = await QrCodes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3,
|
|
});
|
|
if (QrCode3?.setOrganization) {
|
|
await QrCode3.setOrganization(relatedOrganization3);
|
|
}
|
|
|
|
const relatedOrganization4 = await Organizations.findOne({
|
|
offset: Math.floor(Math.random() * (await Organizations.count())),
|
|
});
|
|
const QrCode4 = await QrCodes.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4,
|
|
});
|
|
if (QrCode4?.setOrganization) {
|
|
await QrCode4.setOrganization(relatedOrganization4);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
await Categories.bulkCreate(CategoriesData);
|
|
|
|
await Menus.bulkCreate(MenusData);
|
|
|
|
await Products.bulkCreate(ProductsData);
|
|
|
|
await QrCodes.bulkCreate(QrCodesData);
|
|
|
|
await Organizations.bulkCreate(OrganizationsData);
|
|
|
|
await Promise.all([
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateUserWithOrganization(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateCategoryWithMenu(),
|
|
|
|
await associateCategoryWithOrganization(),
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
await associateMenuWithOwner(),
|
|
|
|
await associateMenuWithOrganization(),
|
|
|
|
await associateProductWithCategory(),
|
|
|
|
await associateProductWithOrganization(),
|
|
|
|
await associateQrCodeWithMenu(),
|
|
|
|
await associateQrCodeWithOrganization(),
|
|
]);
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
await queryInterface.bulkDelete('categories', null, {});
|
|
|
|
await queryInterface.bulkDelete('menus', null, {});
|
|
|
|
await queryInterface.bulkDelete('products', null, {});
|
|
|
|
await queryInterface.bulkDelete('qr_codes', null, {});
|
|
|
|
await queryInterface.bulkDelete('organizations', null, {});
|
|
},
|
|
};
|