"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
require("dotenv/config");
const drizzle_orm_1 = require("drizzle-orm");
const bcryptjs_1 = __importDefault(require("bcryptjs"));
const index_js_1 = require("./index.js");
const schema_js_1 = require("./schema.js");
const lookupUpdateSet = {
    name: (0, drizzle_orm_1.sql) `values(name)`,
    slug: (0, drizzle_orm_1.sql) `values(slug)`,
    isActive: (0, drizzle_orm_1.sql) `values(is_active)`,
    updatedAt: (0, drizzle_orm_1.sql) `CURRENT_TIMESTAMP`,
};
const upsertRows = async (table, rows, set) => {
    if (rows.length === 0)
        return;
    await index_js_1.db
        .insert(table)
        .values(rows)
        .onDuplicateKeyUpdate({ set });
};
const getIdMap = async (table) => {
    const rows = await index_js_1.db.select({ id: table.id, slug: table.slug }).from(table);
    return new Map(rows.map((row) => [row.slug, row.id]));
};
const requiredId = (map, slug) => {
    const value = map.get(slug);
    if (!value)
        throw new Error(`Missing seed value for slug: ${slug}`);
    return value;
};
const run = async () => {
    const adminEmail = process.env.SEED_ADMIN_EMAIL || "test@astavisioningosys.com";
    const adminPassword = process.env.SEED_ADMIN_PASSWORD || "AstaVision@123";
    const passwordHash = await bcryptjs_1.default.hash(adminPassword, 10);
    await upsertRows(schema_js_1.staffUsers, [
        {
            name: "Admin",
            email: adminEmail,
            passwordHash,
            role: "admin",
            isActive: true,
            emailVerifiedAt: new Date(),
        },
    ], {
        name: (0, drizzle_orm_1.sql) `values(name)`,
        passwordHash: (0, drizzle_orm_1.sql) `values(password_hash)`,
        role: (0, drizzle_orm_1.sql) `values(role)`,
        isActive: (0, drizzle_orm_1.sql) `values(is_active)`,
        emailVerifiedAt: (0, drizzle_orm_1.sql) `values(email_verified_at)`,
        updatedAt: (0, drizzle_orm_1.sql) `CURRENT_TIMESTAMP`,
    });
    await upsertRows(schema_js_1.customers, [
        {
            email: "customer@example.com",
            name: "Sample Customer",
            phoneNumber: "+9779800000000",
            emailVerifiedAt: new Date(),
        },
    ], {
        name: (0, drizzle_orm_1.sql) `values(name)`,
        phoneNumber: (0, drizzle_orm_1.sql) `values(phone_number)`,
        emailVerifiedAt: (0, drizzle_orm_1.sql) `values(email_verified_at)`,
        updatedAt: (0, drizzle_orm_1.sql) `CURRENT_TIMESTAMP`,
    });
    await upsertRows(schema_js_1.brands, [
        { name: "Miu Miu", slug: "miu-miu" },
        { name: "Fendi", slug: "fendi" },
        { name: "Gucci", slug: "gucci" },
        { name: "Ray-Ban", slug: "ray-ban" },
        { name: "Prada", slug: "prada" },
        { name: "Versace", slug: "versace" },
        { name: "DICR", slug: "dicr" },
        { name: "Oakley", slug: "oakley" },
        { name: "Fastrack", slug: "fastrack" },
        { name: "Generic / Private Label", slug: "generic-private-label" },
    ], lookupUpdateSet);
    await upsertRows(schema_js_1.productTypes, [
        { name: "Sunglass", slug: "sunglass" },
        { name: "Eyeglass", slug: "eyeglass" },
        { name: "Sport Glass", slug: "sport-glass" },
        { name: "Wedding Glass", slug: "wedding-glass" },
        { name: "Formal Glass", slug: "formal-glass" },
        { name: "Party Glass", slug: "party-glass" },
    ], lookupUpdateSet);
    await upsertRows(schema_js_1.mediaAssets, [
        {
            ownerType: "product_type",
            ownerId: requiredId(await getIdMap(schema_js_1.productTypes), "sunglass"),
            url: "/uploads/seed/types/sunglass.png",
            fileName: "sunglass.png",
            mimeType: "image/png",
            altText: "Sunglass",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "product_type",
            ownerId: requiredId(await getIdMap(schema_js_1.productTypes), "eyeglass"),
            url: "/uploads/seed/types/eyeglass.png",
            fileName: "eyeglass.png",
            mimeType: "image/png",
            altText: "Eyeglass",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "product_type",
            ownerId: requiredId(await getIdMap(schema_js_1.productTypes), "sport-glass"),
            url: "/uploads/seed/types/sportglass.png",
            fileName: "sportglass.png",
            mimeType: "image/png",
            altText: "Sport Glass",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "product_type",
            ownerId: requiredId(await getIdMap(schema_js_1.productTypes), "wedding-glass"),
            url: "/uploads/seed/types/weedingglass.png",
            fileName: "weedingglass.png",
            mimeType: "image/png",
            altText: "Wedding Glass",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "product_type",
            ownerId: requiredId(await getIdMap(schema_js_1.productTypes), "formal-glass"),
            url: "/uploads/seed/types/formalglasss.png",
            fileName: "formalglasss.png",
            mimeType: "image/png",
            altText: "Formal Glass",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "product_type",
            ownerId: requiredId(await getIdMap(schema_js_1.productTypes), "party-glass"),
            url: "/uploads/seed/types/partyglass.png",
            fileName: "formalglasss.png",
            mimeType: "image/png",
            altText: "Party Glass",
            sortOrder: 0,
            isPrimary: true,
        }
    ], {
        fileName: (0, drizzle_orm_1.sql) `values(file_name)`,
        mimeType: (0, drizzle_orm_1.sql) `values(mime_type)`,
        altText: (0, drizzle_orm_1.sql) `values(alt_text)`,
        sortOrder: (0, drizzle_orm_1.sql) `values(sort_order)`,
        isPrimary: (0, drizzle_orm_1.sql) `values(is_primary)`,
        updatedAt: (0, drizzle_orm_1.sql) `CURRENT_TIMESTAMP`,
    });
    console.log("Seeding banners...");
    await upsertRows(schema_js_1.banners, [
        {
            title: "Premium Sunglasses",
            subtitle: "Protect your eyes in style with our curated sunglass collection",
            imageUrl: "/uploads/seed/cover/sunglass.png",
            linkUrl: "/products/type/sunglass",
            linkLabel: "Shop Sunglasses",
            isActive: true,
            sortOrder: 0,
        },
        {
            title: "Crystal Clear Eyeglasses",
            subtitle: "Precision-crafted frames for every prescription",
            imageUrl: "/uploads/seed/cover/eyeglass.png",
            linkUrl: "/products/type/eyeglass",
            linkLabel: "Shop Eyeglasses",
            isActive: true,
            sortOrder: 1,
        },
        {
            title: "Sport Performance",
            subtitle: "High-performance frames built for active lifestyles",
            imageUrl: "/uploads/seed/cover/sport.png",
            linkUrl: "/products/type/sport-glass",
            linkLabel: "Shop Sport",
            isActive: true,
            sortOrder: 2,
        },
        {
            title: "Formal Elegance",
            subtitle: "Sophisticated frames for the boardroom and beyond",
            imageUrl: "/uploads/seed/cover/formalglass.png",
            linkUrl: "/products/type/formal-glass",
            linkLabel: "Shop Formal",
            isActive: true,
            sortOrder: 3,
        },
    ], {
        title: (0, drizzle_orm_1.sql) `values(title)`,
        subtitle: (0, drizzle_orm_1.sql) `values(subtitle)`,
        imageUrl: (0, drizzle_orm_1.sql) `values(image_url)`,
        linkUrl: (0, drizzle_orm_1.sql) `values(link_url)`,
        linkLabel: (0, drizzle_orm_1.sql) `values(link_label)`,
        isActive: (0, drizzle_orm_1.sql) `values(is_active)`,
        sortOrder: (0, drizzle_orm_1.sql) `values(sort_order)`,
        updatedAt: (0, drizzle_orm_1.sql) `CURRENT_TIMESTAMP`,
    });
    const productTypeIds = await getIdMap(schema_js_1.productTypes);
    await upsertRows(schema_js_1.occasions, [
        { name: "Wedding", slug: "wedding" },
        { name: "Formal", slug: "formal" },
        { name: "Party", slug: "party" },
    ], lookupUpdateSet);
    await upsertRows(schema_js_1.collections, [
        { name: "Driving", slug: "driving" },
        { name: "Cycling", slug: "cycling" },
        { name: "Running", slug: "running" },
    ], lookupUpdateSet);
    await upsertRows(schema_js_1.frameShapes, [
        { name: "Round", slug: "round" },
        { name: "Aviator", slug: "aviator" },
        { name: "Cat Eye", slug: "cat-eye" },
        { name: "Clubmaster", slug: "clubmaster" },
        { name: "Geometric", slug: "geometric" },
        { name: "Rectangle", slug: "rectangle" },
        { name: "Square", slug: "square" },
    ], lookupUpdateSet);
    await upsertRows(schema_js_1.faceShapes, [
        { name: "Round", slug: "round" },
        { name: "Oval", slug: "oval" },
        { name: "Heart", slug: "heart" },
        { name: "Square", slug: "square" },
        { name: "Oblong", slug: "oblong" },
        { name: "Diamond", slug: "diamond" },
    ], lookupUpdateSet);
    await upsertRows(schema_js_1.genders, [
        { name: "Men", slug: "men" },
        { name: "Women", slug: "women" },
        { name: "Unisex", slug: "unisex" },
        { name: "Teen", slug: "teen" },
        { name: "Kids", slug: "kids" },
    ], lookupUpdateSet);
    await upsertRows(schema_js_1.frameColors, [
        { name: "Black", slug: "black", hexCode: "#000000" },
        { name: "Grey", slug: "grey", hexCode: "#808080" },
        { name: "Transparent", slug: "transparent", hexCode: null },
        { name: "Gold", slug: "gold", hexCode: "#D4AF37" },
        { name: "Silver", slug: "silver", hexCode: "#C0C0C0" },
        { name: "Pink", slug: "pink", hexCode: "#FFC0CB" },
    ], {
        ...lookupUpdateSet,
        hexCode: (0, drizzle_orm_1.sql) `values(hex_code)`,
    });
    await upsertRows(schema_js_1.lensFeatures, [
        {
            name: "Custom / Power Lenses",
            slug: "custom-power-lenses",
            description: "Prescription lens support.",
        },
        {
            name: "Blue Light Blocking / Blue Cut",
            slug: "blue-light-blocking-blue-cut",
            description: "Helps reduce screen-related blue light exposure.",
        },
        {
            name: "Anti-Reflection (AR)",
            slug: "anti-reflection-ar",
            description: "Reduces glare from light sources.",
        },
        {
            name: "Polarized",
            slug: "polarized",
            description: "Reduces reflected glare for driving and outdoor use.",
        },
        {
            name: "Photochromic / Transition",
            slug: "photochromic-transition",
            description: "Darkens outdoors and clears indoors.",
        },
    ], {
        ...lookupUpdateSet,
        description: (0, drizzle_orm_1.sql) `values(description)`,
    });
    await upsertRows(schema_js_1.ageGroups, [
        { name: "Under 5", slug: "under-5", minAge: 0, maxAge: 4, sortOrder: 1 },
        { name: "5 - 10", slug: "5-10", minAge: 5, maxAge: 10, sortOrder: 2 },
        { name: "10 - 20", slug: "10-20", minAge: 10, maxAge: 20, sortOrder: 3 },
        { name: "20 - 30", slug: "20-30", minAge: 20, maxAge: 30, sortOrder: 4 },
        { name: "30+", slug: "30-plus", minAge: 30, maxAge: null, sortOrder: 5 },
    ], {
        ...lookupUpdateSet,
        minAge: (0, drizzle_orm_1.sql) `values(min_age)`,
        maxAge: (0, drizzle_orm_1.sql) `values(max_age)`,
        sortOrder: (0, drizzle_orm_1.sql) `values(sort_order)`,
    });
    await upsertRows(schema_js_1.sizes, [
        { name: "S", slug: "s", sortOrder: 1 },
        { name: "M", slug: "m", sortOrder: 2 },
        { name: "L", slug: "l", sortOrder: 3 },
    ], {
        ...lookupUpdateSet,
        sortOrder: (0, drizzle_orm_1.sql) `values(sort_order)`,
    });
    await upsertRows(schema_js_1.priceRanges, [
        {
            name: "NPR 1,000 - 2,000",
            slug: "1000-2000",
            minPrice: 1000,
            maxPrice: 2000,
            sortOrder: 1,
        },
        {
            name: "NPR 2,000 - 4,000",
            slug: "2000-4000",
            minPrice: 2000,
            maxPrice: 4000,
            sortOrder: 2,
        },
        {
            name: "NPR 4,000 - 6,000",
            slug: "4000-6000",
            minPrice: 4000,
            maxPrice: 6000,
            sortOrder: 3,
        },
        {
            name: "NPR 6,000+",
            slug: "6000-plus",
            minPrice: 6000,
            maxPrice: null,
            sortOrder: 4,
        },
    ], {
        ...lookupUpdateSet,
        minPrice: (0, drizzle_orm_1.sql) `values(min_price)`,
        maxPrice: (0, drizzle_orm_1.sql) `values(max_price)`,
        sortOrder: (0, drizzle_orm_1.sql) `values(sort_order)`,
    });
    const brandIds = await getIdMap(schema_js_1.brands);
    const collectionIds = await getIdMap(schema_js_1.collections);
    const frameShapeIds = await getIdMap(schema_js_1.frameShapes);
    const frameColorIds = await getIdMap(schema_js_1.frameColors);
    const ageGroupIds = await getIdMap(schema_js_1.ageGroups);
    const sizeIds = await getIdMap(schema_js_1.sizes);
    await upsertRows(schema_js_1.products, [
        {
            sku: "GUCCI-NEW-SUNGOLD",
            name: "Gucci New Sunglass Gold",
            slug: "gucci-new-sunglass-gold",
            description: "Premium Gucci sunglasses with gold frame and tinted lenses. Perfect for fashion-forward individuals.",
            brandId: requiredId(brandIds, "gucci"),
            productTypeId: requiredId(productTypeIds, "sunglass"),
            collectionId: null,
            frameShapeId: requiredId(frameShapeIds, "cat-eye"),
            frameColorId: requiredId(frameColorIds, "gold"),
            ageGroupId: requiredId(ageGroupIds, "20-30"),
            sizeId: requiredId(sizeIds, "m"),
            basePrice: 12000,
            discountPercent: 10,
            salePrice: 10800,
            stockQuantity: 8,
            status: "active",
            isFeatured: true,
            averageRating: "4.70",
            ratingCount: 12,
        },
        {
            sku: "GUCCI-SUN-BLACK",
            name: "Gucci Classic Sunglass Black",
            slug: "gucci-classic-sunglass-black",
            description: "Timeless Gucci sunglasses with black frame. Elegant design for everyday wear.",
            brandId: requiredId(brandIds, "gucci"),
            productTypeId: requiredId(productTypeIds, "sunglass"),
            collectionId: null,
            frameShapeId: requiredId(frameShapeIds, "round"),
            frameColorId: requiredId(frameColorIds, "black"),
            ageGroupId: requiredId(ageGroupIds, "20-30"),
            sizeId: requiredId(sizeIds, "m"),
            basePrice: 9500,
            discountPercent: 15,
            salePrice: 8075,
            stockQuantity: 12,
            status: "active",
            isFeatured: true,
            averageRating: "4.50",
            ratingCount: 8,
        },
        {
            sku: "OK-META-HSTN-BLK",
            name: "Oakley Meta HSTN Black",
            slug: "oakley-meta-hstn-black",
            description: "Oakley Meta HSTN sport glasses with Prizm lens technology. Ideal for active lifestyle and outdoor sports.",
            brandId: requiredId(brandIds, "oakley"),
            productTypeId: requiredId(productTypeIds, "sport-glass"),
            collectionId: requiredId(collectionIds, "running"),
            frameShapeId: requiredId(frameShapeIds, "rectangle"),
            frameColorId: requiredId(frameColorIds, "black"),
            ageGroupId: requiredId(ageGroupIds, "20-30"),
            sizeId: requiredId(sizeIds, "l"),
            basePrice: 8500,
            discountPercent: 8,
            salePrice: 7820,
            stockQuantity: 15,
            status: "active",
            isFeatured: true,
            averageRating: "4.80",
            ratingCount: 22,
        },
        {
            sku: "PRADA-SUN-BLACK",
            name: "Prada Cat Eye Sunglass",
            slug: "prada-cat-eye-sunglass",
            description: "Sophisticated Prada cat eye sunglasses. A statement piece for the modern woman.",
            brandId: requiredId(brandIds, "prada"),
            productTypeId: requiredId(productTypeIds, "sunglass"),
            collectionId: null,
            frameShapeId: requiredId(frameShapeIds, "cat-eye"),
            frameColorId: requiredId(frameColorIds, "black"),
            ageGroupId: requiredId(ageGroupIds, "20-30"),
            sizeId: requiredId(sizeIds, "m"),
            basePrice: 11000,
            discountPercent: 12,
            salePrice: 9680,
            stockQuantity: 10,
            status: "active",
            isFeatured: true,
            averageRating: "4.60",
            ratingCount: 15,
        },
        {
            sku: "RB-EYE-ROUND-TR",
            name: "Ray-Ban Round Eyeglasses",
            slug: "ray-ban-round-eyeglasses",
            description: "Classic Ray-Ban round eyeglasses with transparent frame. Perfect for daily wear and screen protection.",
            brandId: requiredId(brandIds, "ray-ban"),
            productTypeId: requiredId(productTypeIds, "eyeglass"),
            collectionId: null,
            frameShapeId: requiredId(frameShapeIds, "round"),
            frameColorId: requiredId(frameColorIds, "transparent"),
            ageGroupId: requiredId(ageGroupIds, "20-30"),
            sizeId: requiredId(sizeIds, "m"),
            basePrice: 5500,
            discountPercent: 10,
            salePrice: 4950,
            stockQuantity: 20,
            status: "active",
            isFeatured: true,
            averageRating: "4.40",
            ratingCount: 18,
        },
        {
            sku: "RB-META-SKYLER",
            name: "Ray-Ban Meta Skyler Black",
            slug: "ray-ban-meta-skyler-black",
            description: "Ray-Ban Meta Skyler smart glasses with built-in technology. Style meets innovation.",
            brandId: requiredId(brandIds, "ray-ban"),
            productTypeId: requiredId(productTypeIds, "sunglass"),
            collectionId: null,
            frameShapeId: requiredId(frameShapeIds, "square"),
            frameColorId: requiredId(frameColorIds, "black"),
            ageGroupId: requiredId(ageGroupIds, "20-30"),
            sizeId: requiredId(sizeIds, "m"),
            basePrice: 15000,
            discountPercent: 5,
            salePrice: 14250,
            stockQuantity: 6,
            status: "active",
            isFeatured: true,
            averageRating: "4.90",
            ratingCount: 25,
        },
        {
            sku: "RB-AVIATOR-GOLD-M",
            name: "Ray-Ban Aviator Classic Gold",
            slug: "ray-ban-aviator-classic-gold",
            description: "Iconic Ray-Ban aviator sunglasses with gold frame and classic green lenses. Timeless style for any occasion.",
            brandId: requiredId(brandIds, "ray-ban"),
            productTypeId: requiredId(productTypeIds, "sunglass"),
            collectionId: null,
            frameShapeId: requiredId(frameShapeIds, "aviator"),
            frameColorId: requiredId(frameColorIds, "gold"),
            ageGroupId: requiredId(ageGroupIds, "20-30"),
            sizeId: requiredId(sizeIds, "m"),
            basePrice: 6500,
            discountPercent: 10,
            salePrice: 5850,
            stockQuantity: 15,
            status: "active",
            isFeatured: true,
            averageRating: "4.80",
            ratingCount: 30,
        },
        {
            sku: "VS-EYE-GOLD-W",
            name: "Versace Eyewear Gold",
            slug: "versace-eyewear-gold",
            description: "Luxurious Versace eyeglasses with gold accents. Make a bold statement with every look.",
            brandId: requiredId(brandIds, "versace"),
            productTypeId: requiredId(productTypeIds, "eyeglass"),
            collectionId: null,
            frameShapeId: requiredId(frameShapeIds, "cat-eye"),
            frameColorId: requiredId(frameColorIds, "gold"),
            ageGroupId: requiredId(ageGroupIds, "30-plus"),
            sizeId: requiredId(sizeIds, "m"),
            basePrice: 13000,
            discountPercent: 8,
            salePrice: 11960,
            stockQuantity: 7,
            status: "active",
            isFeatured: false,
            averageRating: "4.70",
            ratingCount: 10,
        },
        {
            sku: "VS-SUN-AVIATOR",
            name: "Versace Aviator Sunglass Gold",
            slug: "versace-aviator-sunglass-gold",
            description: "Versace aviator sunglasses with gold frame. Timeless design meets luxury craftsmanship.",
            brandId: requiredId(brandIds, "versace"),
            productTypeId: requiredId(productTypeIds, "sunglass"),
            collectionId: null,
            frameShapeId: requiredId(frameShapeIds, "aviator"),
            frameColorId: requiredId(frameColorIds, "gold"),
            ageGroupId: requiredId(ageGroupIds, "20-30"),
            sizeId: requiredId(sizeIds, "m"),
            basePrice: 10500,
            discountPercent: 10,
            salePrice: 9450,
            stockQuantity: 9,
            status: "active",
            isFeatured: false,
            averageRating: "4.50",
            ratingCount: 14,
        },
    ], {
        name: (0, drizzle_orm_1.sql) `values(name)`,
        description: (0, drizzle_orm_1.sql) `values(description)`,
        brandId: (0, drizzle_orm_1.sql) `values(brand_id)`,
        productTypeId: (0, drizzle_orm_1.sql) `values(product_type_id)`,
        collectionId: (0, drizzle_orm_1.sql) `values(collection_id)`,
        frameShapeId: (0, drizzle_orm_1.sql) `values(frame_shape_id)`,
        frameColorId: (0, drizzle_orm_1.sql) `values(frame_color_id)`,
        ageGroupId: (0, drizzle_orm_1.sql) `values(age_group_id)`,
        sizeId: (0, drizzle_orm_1.sql) `values(size_id)`,
        basePrice: (0, drizzle_orm_1.sql) `values(base_price)`,
        discountPercent: (0, drizzle_orm_1.sql) `values(discount_percent)`,
        salePrice: (0, drizzle_orm_1.sql) `values(sale_price)`,
        stockQuantity: (0, drizzle_orm_1.sql) `values(stock_quantity)`,
        status: (0, drizzle_orm_1.sql) `values(status)`,
        isFeatured: (0, drizzle_orm_1.sql) `values(is_featured)`,
        averageRating: (0, drizzle_orm_1.sql) `values(average_rating)`,
        ratingCount: (0, drizzle_orm_1.sql) `values(rating_count)`,
        updatedAt: (0, drizzle_orm_1.sql) `CURRENT_TIMESTAMP`,
    });
    const productIds = await getIdMap(schema_js_1.products);
    const genderIds = await getIdMap(schema_js_1.genders);
    const faceShapeIds = await getIdMap(schema_js_1.faceShapes);
    const lensFeatureIds = await getIdMap(schema_js_1.lensFeatures);
    const occasionIds = await getIdMap(schema_js_1.occasions);
    await upsertRows(schema_js_1.productGenders, [
        {
            productId: requiredId(productIds, "gucci-new-sunglass-gold"),
            genderId: requiredId(genderIds, "women"),
        },
        {
            productId: requiredId(productIds, "gucci-classic-sunglass-black"),
            genderId: requiredId(genderIds, "unisex"),
        },
        {
            productId: requiredId(productIds, "oakley-meta-hstn-black"),
            genderId: requiredId(genderIds, "men"),
        },
        {
            productId: requiredId(productIds, "oakley-meta-hstn-black"),
            genderId: requiredId(genderIds, "unisex"),
        },
        {
            productId: requiredId(productIds, "prada-cat-eye-sunglass"),
            genderId: requiredId(genderIds, "women"),
        },
        {
            productId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            genderId: requiredId(genderIds, "unisex"),
        },
        {
            productId: requiredId(productIds, "ray-ban-meta-skyler-black"),
            genderId: requiredId(genderIds, "unisex"),
        },
        {
            productId: requiredId(productIds, "versace-eyewear-gold"),
            genderId: requiredId(genderIds, "women"),
        },
        {
            productId: requiredId(productIds, "versace-aviator-sunglass-gold"),
            genderId: requiredId(genderIds, "unisex"),
        },
    ], { productId: (0, drizzle_orm_1.sql) `product_id` });
    await upsertRows(schema_js_1.productFaceShapes, [
        {
            productId: requiredId(productIds, "gucci-new-sunglass-gold"),
            faceShapeId: requiredId(faceShapeIds, "oval"),
        },
        {
            productId: requiredId(productIds, "gucci-new-sunglass-gold"),
            faceShapeId: requiredId(faceShapeIds, "heart"),
        },
        {
            productId: requiredId(productIds, "gucci-classic-sunglass-black"),
            faceShapeId: requiredId(faceShapeIds, "square"),
        },
        {
            productId: requiredId(productIds, "gucci-classic-sunglass-black"),
            faceShapeId: requiredId(faceShapeIds, "round"),
        },
        {
            productId: requiredId(productIds, "oakley-meta-hstn-black"),
            faceShapeId: requiredId(faceShapeIds, "round"),
        },
        {
            productId: requiredId(productIds, "oakley-meta-hstn-black"),
            faceShapeId: requiredId(faceShapeIds, "oval"),
        },
        {
            productId: requiredId(productIds, "prada-cat-eye-sunglass"),
            faceShapeId: requiredId(faceShapeIds, "oval"),
        },
        {
            productId: requiredId(productIds, "prada-cat-eye-sunglass"),
            faceShapeId: requiredId(faceShapeIds, "oblong"),
        },
        {
            productId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            faceShapeId: requiredId(faceShapeIds, "square"),
        },
        {
            productId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            faceShapeId: requiredId(faceShapeIds, "diamond"),
        },
        {
            productId: requiredId(productIds, "ray-ban-meta-skyler-black"),
            faceShapeId: requiredId(faceShapeIds, "oval"),
        },
        {
            productId: requiredId(productIds, "ray-ban-meta-skyler-black"),
            faceShapeId: requiredId(faceShapeIds, "heart"),
        },
        {
            productId: requiredId(productIds, "versace-eyewear-gold"),
            faceShapeId: requiredId(faceShapeIds, "oval"),
        },
        {
            productId: requiredId(productIds, "versace-aviator-sunglass-gold"),
            faceShapeId: requiredId(faceShapeIds, "round"),
        },
        {
            productId: requiredId(productIds, "versace-aviator-sunglass-gold"),
            faceShapeId: requiredId(faceShapeIds, "square"),
        },
    ], { productId: (0, drizzle_orm_1.sql) `product_id` });
    await upsertRows(schema_js_1.productLensFeatures, [
        {
            productId: requiredId(productIds, "gucci-new-sunglass-gold"),
            lensFeatureId: requiredId(lensFeatureIds, "polarized"),
        },
        {
            productId: requiredId(productIds, "gucci-classic-sunglass-black"),
            lensFeatureId: requiredId(lensFeatureIds, "polarized"),
        },
        {
            productId: requiredId(productIds, "oakley-meta-hstn-black"),
            lensFeatureId: requiredId(lensFeatureIds, "polarized"),
        },
        {
            productId: requiredId(productIds, "oakley-meta-hstn-black"),
            lensFeatureId: requiredId(lensFeatureIds, "photochromic-transition"),
        },
        {
            productId: requiredId(productIds, "prada-cat-eye-sunglass"),
            lensFeatureId: requiredId(lensFeatureIds, "polarized"),
        },
        {
            productId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            lensFeatureId: requiredId(lensFeatureIds, "blue-light-blocking-blue-cut"),
        },
        {
            productId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            lensFeatureId: requiredId(lensFeatureIds, "anti-reflection-ar"),
        },
        {
            productId: requiredId(productIds, "ray-ban-meta-skyler-black"),
            lensFeatureId: requiredId(lensFeatureIds, "polarized"),
        },
        {
            productId: requiredId(productIds, "versace-eyewear-gold"),
            lensFeatureId: requiredId(lensFeatureIds, "anti-reflection-ar"),
        },
        {
            productId: requiredId(productIds, "versace-aviator-sunglass-gold"),
            lensFeatureId: requiredId(lensFeatureIds, "polarized"),
        },
    ], { productId: (0, drizzle_orm_1.sql) `product_id` });
    await upsertRows(schema_js_1.productOccasions, [
        {
            productId: requiredId(productIds, "gucci-new-sunglass-gold"),
            occasionId: requiredId(occasionIds, "party"),
        },
        {
            productId: requiredId(productIds, "gucci-classic-sunglass-black"),
            occasionId: requiredId(occasionIds, "formal"),
        },
        {
            productId: requiredId(productIds, "oakley-meta-hstn-black"),
            occasionId: requiredId(occasionIds, "party"),
        },
        {
            productId: requiredId(productIds, "prada-cat-eye-sunglass"),
            occasionId: requiredId(occasionIds, "party"),
        },
        {
            productId: requiredId(productIds, "prada-cat-eye-sunglass"),
            occasionId: requiredId(occasionIds, "formal"),
        },
        {
            productId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            occasionId: requiredId(occasionIds, "formal"),
        },
        {
            productId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            occasionId: requiredId(occasionIds, "wedding"),
        },
        {
            productId: requiredId(productIds, "ray-ban-meta-skyler-black"),
            occasionId: requiredId(occasionIds, "party"),
        },
        {
            productId: requiredId(productIds, "versace-eyewear-gold"),
            occasionId: requiredId(occasionIds, "formal"),
        },
        {
            productId: requiredId(productIds, "versace-aviator-sunglass-gold"),
            occasionId: requiredId(occasionIds, "party"),
        },
    ], { productId: (0, drizzle_orm_1.sql) `product_id` });
    await upsertRows(schema_js_1.mediaAssets, [
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "gucci-new-sunglass-gold"),
            url: "/uploads/seed/products/Gucci New Sunglass1.png",
            fileName: "Gucci New Sunglass1.png",
            mimeType: "image/png",
            altText: "Gucci New Sunglass Gold front view",
            sortOrder: 1,
            isPrimary: true,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "gucci-new-sunglass-gold"),
            url: "/uploads/seed/products/Gucci New Sunglass2.png",
            fileName: "Gucci New Sunglass2.png",
            mimeType: "image/png",
            altText: "Gucci New Sunglass Gold side view",
            sortOrder: 2,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "gucci-new-sunglass-gold"),
            url: "/uploads/seed/products/Gucci New Sunglass3.png",
            fileName: "Gucci New Sunglass3.png",
            mimeType: "image/png",
            altText: "Gucci New Sunglass Gold angled view",
            sortOrder: 3,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "gucci-classic-sunglass-black"),
            url: "/uploads/seed/products/Gucci Classic Sunglass Black1.png",
            fileName: "Gucci Classic Sunglass Black1.png",
            mimeType: "image/png",
            altText: "Gucci Classic Sunglass Black front view",
            sortOrder: 1,
            isPrimary: true,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "gucci-classic-sunglass-black"),
            url: "/uploads/seed/products/Gucci Classic Sunglass Black2.png",
            fileName: "Gucci Classic Sunglass Black2.png",
            mimeType: "image/png",
            altText: "Gucci Classic Sunglass Black side view",
            sortOrder: 2,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "gucci-classic-sunglass-black"),
            url: "/uploads/seed/products/Gucci Classic Sunglass Black3.png",
            fileName: "Gucci Classic Sunglass Black3.png",
            mimeType: "image/png",
            altText: "Gucci Classic Sunglass Black angled view",
            sortOrder: 3,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "gucci-classic-sunglass-black"),
            url: "/uploads/seed/products/Gucci Classic Sunglass Black4.png",
            fileName: "Gucci Classic Sunglass Black4.png",
            mimeType: "image/png",
            altText: "Gucci Classic Sunglass Black detail view",
            sortOrder: 4,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "gucci-classic-sunglass-black"),
            url: "/uploads/seed/products/Gucci Classic Sunglass Black5.png",
            fileName: "Gucci Classic Sunglass Black5.png",
            mimeType: "image/png",
            altText: "Gucci Classic Sunglass Black lifestyle view",
            sortOrder: 5,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "oakley-meta-hstn-black"),
            url: "/uploads/seed/products/Oakley Meta HSTN Black1.png",
            fileName: "Oakley Meta HSTN Black1.png",
            mimeType: "image/png",
            altText: "Oakley Meta HSTN Black front view",
            sortOrder: 1,
            isPrimary: true,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "oakley-meta-hstn-black"),
            url: "/uploads/seed/products/Oakley Meta HSTN Black2.png",
            fileName: "Oakley Meta HSTN Black2.png",
            mimeType: "image/png",
            altText: "Oakley Meta HSTN Black side view",
            sortOrder: 2,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "oakley-meta-hstn-black"),
            url: "/uploads/seed/products/Oakley Meta HSTN Black3.png",
            fileName: "Oakley Meta HSTN Black3.png",
            mimeType: "image/png",
            altText: "Oakley Meta HSTN Black back view",
            sortOrder: 3,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "oakley-meta-hstn-black"),
            url: "/uploads/seed/products/Oakley Meta HSTN Black4.png",
            fileName: "Oakley Meta HSTN Black4.png",
            mimeType: "image/png",
            altText: "Oakley Meta HSTN Black detail view",
            sortOrder: 4,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "oakley-meta-hstn-black"),
            url: "/uploads/seed/products/Oakley Meta HSTN Black5.png",
            fileName: "Oakley Meta HSTN Black5.png",
            mimeType: "image/png",
            altText: "Oakley Meta HSTN Black lifestyle view",
            sortOrder: 5,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "prada-cat-eye-sunglass"),
            url: "/uploads/seed/products/Prada Cat Eye Sunglass1.png",
            fileName: "Prada Cat Eye Sunglass1.png",
            mimeType: "image/png",
            altText: "Prada Cat Eye Sunglass front view",
            sortOrder: 1,
            isPrimary: true,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "prada-cat-eye-sunglass"),
            url: "/uploads/seed/products/Prada Cat Eye Sunglass3.png",
            fileName: "Prada Cat Eye Sunglass3.png",
            mimeType: "image/png",
            altText: "Prada Cat Eye Sunglass back view",
            sortOrder: 2,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "prada-cat-eye-sunglass"),
            url: "/uploads/seed/products/Prada Cat Eye Sunglass4.png",
            fileName: "Prada Cat Eye Sunglass4.png",
            mimeType: "image/png",
            altText: "Prada Cat Eye Sunglass detail view",
            sortOrder: 3,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "prada-cat-eye-sunglass"),
            url: "/uploads/seed/products/Prada Cat Eye Sunglass5.png",
            fileName: "Prada Cat Eye Sunglass5.png",
            mimeType: "image/png",
            altText: "Prada Cat Eye Sunglass on model",
            sortOrder: 4,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            url: "/uploads/seed/products/rayban-eyeglass1.png",
            fileName: "rayban-eyeglass1.png",
            mimeType: "image/png",
            altText: "Ray-Ban Round Eyeglasses front view",
            sortOrder: 1,
            isPrimary: true,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            url: "/uploads/seed/products/rayban-eyeglass2.png",
            fileName: "rayban-eyeglass2.png",
            mimeType: "image/png",
            altText: "Ray-Ban Round Eyeglasses side view",
            sortOrder: 2,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            url: "/uploads/seed/products/rayban-eyeglass3.png",
            fileName: "rayban-eyeglass3.png",
            mimeType: "image/png",
            altText: "Ray-Ban Round Eyeglasses back view",
            sortOrder: 3,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "ray-ban-round-eyeglasses"),
            url: "/uploads/seed/products/rayban-eyeglass4.png",
            fileName: "rayban-eyeglass4.png",
            mimeType: "image/png",
            altText: "Ray-Ban Round Eyeglasses detail view",
            sortOrder: 4,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "versace-eyewear-gold"),
            url: "/uploads/seed/products/Versace Eyewear1.png",
            fileName: "Versace Eyewear1.png",
            mimeType: "image/png",
            altText: "Versace Eyewear Gold front view",
            sortOrder: 1,
            isPrimary: true,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "versace-eyewear-gold"),
            url: "/uploads/seed/products/Versace Eyewear2.png",
            fileName: "Versace Eyewear2.png",
            mimeType: "image/png",
            altText: "Versace Eyewear Gold side view",
            sortOrder: 2,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "versace-eyewear-gold"),
            url: "/uploads/seed/products/Versace Eyewear3.png",
            fileName: "Versace Eyewear3.png",
            mimeType: "image/png",
            altText: "Versace Eyewear Gold back view",
            sortOrder: 3,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "versace-eyewear-gold"),
            url: "/uploads/seed/products/Versace Eyewear4.png",
            fileName: "Versace Eyewear4.png",
            mimeType: "image/png",
            altText: "Versace Eyewear Gold detail view",
            sortOrder: 4,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "versace-aviator-sunglass-gold"),
            url: "/uploads/seed/products/Versace Sunglass1.png",
            fileName: "Versace Sunglass1.png",
            mimeType: "image/png",
            altText: "Versace Aviator Sunglass Gold front view",
            sortOrder: 1,
            isPrimary: true,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "versace-aviator-sunglass-gold"),
            url: "/uploads/seed/products/Versace Sunglass2.png",
            fileName: "Versace Sunglass2.png",
            mimeType: "image/png",
            altText: "Versace Aviator Sunglass Gold side view",
            sortOrder: 2,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "versace-aviator-sunglass-gold"),
            url: "/uploads/seed/products/Versace Sunglass3.png",
            fileName: "Versace Sunglass3.png",
            mimeType: "image/png",
            altText: "Versace Aviator Sunglass Gold back view",
            sortOrder: 3,
            isPrimary: false,
        },
        {
            ownerType: "product",
            ownerId: requiredId(productIds, "versace-aviator-sunglass-gold"),
            url: "/uploads/seed/products/Versace Sunglass4.png",
            fileName: "Versace Sunglass4.png",
            mimeType: "image/png",
            altText: "Versace Aviator Sunglass Gold detail view",
            sortOrder: 4,
            isPrimary: false,
        },
    ], {
        fileName: (0, drizzle_orm_1.sql) `values(file_name)`,
        mimeType: (0, drizzle_orm_1.sql) `values(mime_type)`,
        altText: (0, drizzle_orm_1.sql) `values(alt_text)`,
        sortOrder: (0, drizzle_orm_1.sql) `values(sort_order)`,
        isPrimary: (0, drizzle_orm_1.sql) `values(is_primary)`,
        updatedAt: (0, drizzle_orm_1.sql) `CURRENT_TIMESTAMP`,
    });
    await upsertRows(schema_js_1.mediaAssets, [
        {
            ownerType: "brand",
            ownerId: requiredId(brandIds, "miu-miu"),
            url: "/uploads/seed/brands/miu-miu-logo.png",
            fileName: "miu-miu-logo.png",
            mimeType: "image/png",
            altText: "Miu Miu logo",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "brand",
            ownerId: requiredId(brandIds, "fendi"),
            url: "/uploads/seed/brands/fendi.png",
            fileName: "fendi.png",
            mimeType: "image/png",
            altText: "Fendi logo",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "brand",
            ownerId: requiredId(brandIds, "gucci"),
            url: "/uploads/seed/brands/gucci.png",
            fileName: "gucci.png",
            mimeType: "image/png",
            altText: "Gucci logo",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "brand",
            ownerId: requiredId(brandIds, "ray-ban"),
            url: "/uploads/seed/brands/rayban.png",
            fileName: "rayban.png",
            mimeType: "image/png",
            altText: "Ray-Ban logo",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "brand",
            ownerId: requiredId(brandIds, "prada"),
            url: "/uploads/seed/brands/Prada.png",
            fileName: "Prada.png",
            mimeType: "image/png",
            altText: "Prada logo",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "brand",
            ownerId: requiredId(brandIds, "versace"),
            url: "/uploads/seed/brands/versace.png",
            fileName: "versace.png",
            mimeType: "image/png",
            altText: "Versace logo",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "brand",
            ownerId: requiredId(brandIds, "oakley"),
            url: "/uploads/seed/brands/oakley.png",
            fileName: "oakley.png",
            mimeType: "image/png",
            altText: "Oakley logo",
            sortOrder: 0,
            isPrimary: true,
        },
    ], {
        fileName: (0, drizzle_orm_1.sql) `values(file_name)`,
        mimeType: (0, drizzle_orm_1.sql) `values(mime_type)`,
        altText: (0, drizzle_orm_1.sql) `values(alt_text)`,
        sortOrder: (0, drizzle_orm_1.sql) `values(sort_order)`,
        isPrimary: (0, drizzle_orm_1.sql) `values(is_primary)`,
        updatedAt: (0, drizzle_orm_1.sql) `CURRENT_TIMESTAMP`,
    });
    await upsertRows(schema_js_1.mediaAssets, [
        {
            ownerType: "frame_shape",
            ownerId: requiredId(frameShapeIds, "round"),
            url: "/uploads/seed/shapes/round.webp",
            fileName: "round.webp",
            mimeType: "image/webp",
            altText: "Round frame shape",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "frame_shape",
            ownerId: requiredId(frameShapeIds, "aviator"),
            url: "/uploads/seed/shapes/aviator.webp",
            fileName: "aviator.webp",
            mimeType: "image/webp",
            altText: "Aviator frame shape",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "frame_shape",
            ownerId: requiredId(frameShapeIds, "cat-eye"),
            url: "/uploads/seed/shapes/cat-eye.webp",
            fileName: "cat-eye.webp",
            mimeType: "image/webp",
            altText: "Cat Eye frame shape",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "frame_shape",
            ownerId: requiredId(frameShapeIds, "clubmaster"),
            url: "/uploads/seed/shapes/clubmaster.webp",
            fileName: "clubmaster.webp",
            mimeType: "image/webp",
            altText: "Clubmaster frame shape",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "frame_shape",
            ownerId: requiredId(frameShapeIds, "geometric"),
            url: "/uploads/seed/shapes/geometric.webp",
            fileName: "geometric.webp",
            mimeType: "image/webp",
            altText: "Geometric frame shape",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "frame_shape",
            ownerId: requiredId(frameShapeIds, "rectangle"),
            url: "/uploads/seed/shapes/rectangle.webp",
            fileName: "rectangle.webp",
            mimeType: "image/webp",
            altText: "Rectangle frame shape",
            sortOrder: 0,
            isPrimary: true,
        },
        {
            ownerType: "frame_shape",
            ownerId: requiredId(frameShapeIds, "square"),
            url: "/uploads/seed/shapes/square.webp",
            fileName: "square.webp",
            mimeType: "image/webp",
            altText: "Square frame shape",
            sortOrder: 0,
            isPrimary: true,
        },
    ], {
        fileName: (0, drizzle_orm_1.sql) `values(file_name)`,
        mimeType: (0, drizzle_orm_1.sql) `values(mime_type)`,
        altText: (0, drizzle_orm_1.sql) `values(alt_text)`,
        sortOrder: (0, drizzle_orm_1.sql) `values(sort_order)`,
        isPrimary: (0, drizzle_orm_1.sql) `values(is_primary)`,
        updatedAt: (0, drizzle_orm_1.sql) `CURRENT_TIMESTAMP`,
    });
    const customerRows = await index_js_1.db.select({ id: schema_js_1.customers.id }).from(schema_js_1.customers);
    const sampleCustomer = customerRows[0];
    if (!sampleCustomer)
        throw new Error("Sample customer was not created.");
    await upsertRows(schema_js_1.orders, [
        {
            orderNumber: "SEED-ORDER-0001",
            customerId: sampleCustomer.id,
            status: "pending",
            fulfillmentMethod: "delivery",
            contactPhone: "+9779800000000",
            deliveryAddress: "Narayangrah, Chitwan, Nepal",
            subtotal: 5850,
            totalDiscount: 650,
            totalAmount: 5850,
            paymentMethod: "cash_on_delivery",
            paymentStatus: "pending",
            customerNotes: "Seed order for admin dashboard testing.",
        },
    ], {
        status: (0, drizzle_orm_1.sql) `values(status)`,
        fulfillmentMethod: (0, drizzle_orm_1.sql) `values(fulfillment_method)`,
        contactPhone: (0, drizzle_orm_1.sql) `values(contact_phone)`,
        deliveryAddress: (0, drizzle_orm_1.sql) `values(delivery_address)`,
        subtotal: (0, drizzle_orm_1.sql) `values(subtotal)`,
        totalDiscount: (0, drizzle_orm_1.sql) `values(total_discount)`,
        totalAmount: (0, drizzle_orm_1.sql) `values(total_amount)`,
        paymentMethod: (0, drizzle_orm_1.sql) `values(payment_method)`,
        paymentStatus: (0, drizzle_orm_1.sql) `values(payment_status)`,
        customerNotes: (0, drizzle_orm_1.sql) `values(customer_notes)`,
        updatedAt: (0, drizzle_orm_1.sql) `CURRENT_TIMESTAMP`,
    });
    const orderRows = await index_js_1.db
        .select({ id: schema_js_1.orders.id, orderNumber: schema_js_1.orders.orderNumber })
        .from(schema_js_1.orders);
    const seedOrder = orderRows.find((order) => order.orderNumber === "SEED-ORDER-0001");
    if (!seedOrder)
        throw new Error("Seed order was not created.");
    await upsertRows(schema_js_1.orderItems, [
        {
            orderId: seedOrder.id,
            productId: requiredId(productIds, "ray-ban-aviator-classic-gold"),
            productName: "Ray-Ban Aviator Classic Gold",
            sku: "RB-AVIATOR-GOLD-M",
            quantity: 1,
            unitPrice: 5850,
            discountAmount: 650,
            lineTotal: 5850,
        },
    ], { orderId: (0, drizzle_orm_1.sql) `order_id` });
    console.log("Seeding client reviews...");
    await index_js_1.db.delete(schema_js_1.clientReviews);
    await index_js_1.db.insert(schema_js_1.clientReviews).values([
        {
            clientName: "Anjali Sharma",
            reviewText: "Been getting my glasses from Sumit Traders for years, always top notch service! Just tagged @sumit_traders on my Facebook post and everyone loved my new frames.",
            starRating: 5,
            sortOrder: 0,
            isActive: true,
        },
        {
            clientName: "Arun Shrestha",
            reviewText: "Went to check out the new Ray-Ban collection and the staff gave me solid recommendations. @sumit_traders really carries premium brands with unmatched quality.",
            starRating: 4,
            sortOrder: 1,
            isActive: true,
        },
        {
            clientName: "Asha Rai",
            reviewText: "First time ordering online from @sumit_traders — super fast delivery! The frame quality and price are both amazing. Highly recommend.",
            starRating: 5,
            sortOrder: 2,
            isActive: true,
        },
        {
            clientName: "Binod Tamang",
            reviewText: "Picked up some sunglasses from @sumit_traders last week. Posted on Facebook and so many people asked where I got them. Great service and quality as always.",
            starRating: 4,
            sortOrder: 3,
            isActive: true,
        },
        {
            clientName: "Bina Gurung",
            reviewText: "Got my prescription glasses made at @sumit_traders for the office. Perfect fitting and an amazing frame collection. Highly recommend to everyone.",
            starRating: 5,
            sortOrder: 4,
            isActive: true,
        },
    ]);
    console.log("Seed complete.");
    console.log(`Admin: ${adminEmail} / ${adminPassword}`);
    process.exit(0);
};
run().catch((err) => {
    console.error("Seed failed:", err);
    process.exit(1);
});
//# sourceMappingURL=seed.js.map