seed
This commit is contained in:
@@ -12,6 +12,7 @@ import { Permission, PermissionTitles } from '../common/enums/permission.enum';
|
||||
import { PaymentMethod } from '../modules/payments/entities/payment-method.entity';
|
||||
import { RestaurantPaymentMethod } from '../modules/payments/entities/restaurant-payment-method.entity';
|
||||
import { ShipmentMethod } from '../modules/shipments/entities/shipment-method.entity';
|
||||
import { RestaurantShipmentMethod } from '../modules/shipments/entities/restaurant-shipment-method.entity';
|
||||
import { Schedule } from '../modules/restaurants/entities/schedule.entity';
|
||||
|
||||
export class DatabaseSeeder extends Seeder {
|
||||
@@ -275,6 +276,34 @@ export class DatabaseSeeder extends Seeder {
|
||||
|
||||
await em.flush();
|
||||
|
||||
// 5.5.5. Create Restaurant Shipment Methods
|
||||
const allRestaurantsForShipments = await em.find(Restaurant, {});
|
||||
const allShipmentMethods = await em.find(ShipmentMethod, { isActive: true });
|
||||
|
||||
for (const restaurant of allRestaurantsForShipments) {
|
||||
if (!restaurant) continue;
|
||||
|
||||
for (const shipmentMethod of allShipmentMethods) {
|
||||
const existing = await em.findOne(RestaurantShipmentMethod, {
|
||||
restaurant: { id: restaurant.id },
|
||||
shipmentMethod: { id: shipmentMethod.id },
|
||||
});
|
||||
|
||||
if (!existing) {
|
||||
const restaurantShipmentMethod = em.create(RestaurantShipmentMethod, {
|
||||
restaurant,
|
||||
shipmentMethod,
|
||||
isActive: true,
|
||||
price: 0,
|
||||
minOrderPrice: 0,
|
||||
});
|
||||
em.persist(restaurantShipmentMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await em.flush();
|
||||
|
||||
// 5.6. Create Schedules for all Restaurants
|
||||
// For each restaurant, create 3 schedules per day (breakfast, lunch, dinner) for all 7 days
|
||||
const allRestaurantsForSchedules = await em.find(Restaurant, {});
|
||||
|
||||
Reference in New Issue
Block a user