procbay-schema 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +189 -0
- package/package.json +77 -0
- package/prisma/.env +13 -0
- package/prisma/migrations/20250116142512_init_user_table/migration.sql +38 -0
- package/prisma/migrations/20250116142709_init_role_table/migration.sql +20 -0
- package/prisma/migrations/20250116143847_init_user_role_table/migration.sql +20 -0
- package/prisma/migrations/20250116144035_init_permission_table/migration.sql +21 -0
- package/prisma/migrations/20250116144140_init_role_permission_table/migration.sql +21 -0
- package/prisma/migrations/20250116144233_init_department_table/migration.sql +20 -0
- package/prisma/migrations/20250116144345_init_user_department_table/migration.sql +20 -0
- package/prisma/migrations/20250116152941_init_serial_number_table/migration.sql +17 -0
- package/prisma/migrations/20250116153048_init_category_table/migration.sql +22 -0
- package/prisma/migrations/20250116153415_init_attributes_table/migration.sql +28 -0
- package/prisma/migrations/20250116153628_init_attribute_values_table/migration.sql +27 -0
- package/prisma/migrations/20250116153900_init_purchase_intake_table/migration.sql +32 -0
- package/prisma/migrations/20250116154038_init_purchase_intake_item_table/migration.sql +15 -0
- package/prisma/migrations/20250120090355_added_reset_token_column_in_user_table/migration.sql +10 -0
- package/prisma/migrations/20250120100616_init_item_table/migration.sql +42 -0
- package/prisma/migrations/20250120123720_init_vendor_table/migration.sql +39 -0
- package/prisma/migrations/20250120124526_init_vendor_categories_table/migration.sql +20 -0
- package/prisma/migrations/20250122114935_added_email_template_and_smtp_config_table/migration.sql +41 -0
- package/prisma/migrations/20250123095637_chnages_in_vendr_table/migration.sql +3 -0
- package/prisma/migrations/20250123103705_added_delated_filed_in_email_template_table/migration.sql +4 -0
- package/prisma/migrations/20250123103810_added_delated_filed_in_smtp_config_table/migration.sql +13 -0
- package/prisma/migrations/20250127123900_create_approval_heirarchy_table/migration.sql +72 -0
- package/prisma/migrations/20250128054523_make_optional_role_and_user_in_approval_hierachy/migration.sql +3 -0
- package/prisma/migrations/20250129084223_item_table_chnages/migration.sql +151 -0
- package/prisma/migrations/20250130115331_chnages_in_item_table/migration.sql +9 -0
- package/prisma/migrations/20250131054132_added_approval_journey_table/migration.sql +22 -0
- package/prisma/migrations/20250131064653_added_default_for_product_id_in_item_table/migration.sql +2 -0
- package/prisma/migrations/20250204101253_chnages_in_approval_table/migration.sql +39 -0
- package/prisma/migrations/20250206091422_added_item_document_table/migration.sql +17 -0
- package/prisma/migrations/20250207113110_added_new_column_media/migration.sql +9 -0
- package/prisma/migrations/20250207125224_added_chnages_in_pr_table/migration.sql +12 -0
- package/prisma/migrations/20250212092048_vendor_contact_table/migration.sql +30 -0
- package/prisma/migrations/20250212133620_added_tamplate_master_table/migration.sql +43 -0
- package/prisma/migrations/20250213111908_created_faq_catgory_and_faq_table/migration.sql +58 -0
- package/prisma/migrations/20250214065142_chnages_in_uom_table/migration.sql +50 -0
- package/prisma/migrations/20250217061122_corrected_email_teamplate_table/migration.sql +11 -0
- package/prisma/migrations/20250218073530_init_events/migration.sql +120 -0
- package/prisma/migrations/20250218092119_corrected_table_name/migration.sql +37 -0
- package/prisma/migrations/20250218120935_chnages_in_event_table/migration.sql +5 -0
- package/prisma/migrations/20250219083326_added_new_table_for_event_startegy/migration.sql +60 -0
- package/prisma/migrations/20250219083416_added_cms_table/migration.sql +29 -0
- package/prisma/migrations/20250219092918_alter_event_table/migration.sql +5 -0
- package/prisma/migrations/20250219093046_alter_event_to_draft/migration.sql +2 -0
- package/prisma/migrations/20250220080337_altered_event_table/migration.sql +9 -0
- package/prisma/migrations/20250221105922_added_unique_to_email_in_user_table/migration.sql +8 -0
- package/prisma/migrations/20250225063838_created_vendor_kyc_table/migration.sql +23 -0
- package/prisma/migrations/20250227060646_template_field_types_added_enum/migration.sql +14 -0
- package/prisma/migrations/20250227110306_updated_event_items_and_event_vendor_table/migration.sql +7 -0
- package/prisma/migrations/20250228060440_added_country_code_in_vendor_contact_person/migration.sql +2 -0
- package/prisma/migrations/20250228095319_init_currencies_table/migration.sql +23 -0
- package/prisma/migrations/20250303082614_added_support_ticket_table/migration.sql +89 -0
- package/prisma/migrations/20250304050248_alter_support_ticket_relations/migration.sql +35 -0
- package/prisma/migrations/20250304050613_alter_support_ticket_realtions/migration.sql +36 -0
- package/prisma/migrations/20250304061954_init_support_category_table/migration.sql +261 -0
- package/prisma/migrations/20250304092346_alter_event_vendor_table/migration.sql +2 -0
- package/prisma/migrations/20250305065430_alter_vendor_kyc_table/migration.sql +2 -0
- package/prisma/migrations/20250305111735_alter_vendor_and_user_table/migration.sql +5 -0
- package/prisma/migrations/20250307033751_alter_token_version_in_user_and_vendor_token/migration.sql +5 -0
- package/prisma/migrations/20250307034907_alter_user_and_vendor_table/migration.sql +14 -0
- package/prisma/migrations/20250307064359_chnages_in_approval_herarcy_table/migration.sql +2 -0
- package/prisma/migrations/20250307105352_alter_itme_and_vendorkyc_table/migration.sql +21 -0
- package/prisma/migrations/20250310103914_init_vendor_status_table/migration.sql +21 -0
- package/prisma/migrations/20250310105209_alter_vendor_status_table/migration.sql +18 -0
- package/prisma/migrations/20250310105413_init_vendor_kyc_status_table/migration.sql +23 -0
- package/prisma/migrations/20250311090552_alter_vendor_kyc_status_table/migration.sql +2 -0
- package/prisma/migrations/20250312055258_alter_status_column_in_event_vendors/migration.sql +12 -0
- package/prisma/migrations/20250312072145_init_vendor_event_watchlist_table/migration.sql +26 -0
- package/prisma/migrations/20250312083842_alter_vendor_event_watchlisst_table/migration.sql +41 -0
- package/prisma/migrations/20250312134730_added_chnages_in_kyc_table/migration.sql +19 -0
- package/prisma/migrations/20250317040841_init_admin_and_vendor_tables/migration.sql +38 -0
- package/prisma/migrations/20250317044110_alter_event_vendor_table/migration.sql +2 -0
- package/prisma/migrations/20250317071807_alter_rejected_reason_in_approval_journey_and_purchase_intak_table/migration.sql +5 -0
- package/prisma/migrations/20250318085504_init_customer_notification_table/migration.sql +31 -0
- package/prisma/migrations/20250318085856_alter_purchase_intake_table/migration.sql +18 -0
- package/prisma/migrations/20250319085159_alter_purchase_intake_table/migration.sql +12 -0
- package/prisma/migrations/20250320093356_init_bid_and_bidlog_table/migration.sql +75 -0
- package/prisma/migrations/20250320095501_alter_email_template_table/migration.sql +2 -0
- package/prisma/migrations/20250321053926_alter_approval_journey_table/migration.sql +2 -0
- package/prisma/migrations/20250324040851_alter_bidlog_table/migration.sql +2 -0
- package/prisma/migrations/20250324091328_init_form_master_and_dynamic_form_table/migration.sql +53 -0
- package/prisma/migrations/20250324103742_alter_bidlog_table/migration.sql +5 -0
- package/prisma/migrations/20250325052714_alter_form_master_table/migration.sql +27 -0
- package/prisma/migrations/20250327011625_init_module_and_tenant_configuration_table/migration.sql +39 -0
- package/prisma/migrations/20250403054008_alter_purchase_intake_table/migration.sql +5 -0
- package/prisma/migrations/20250404115613_init_approval_level_user/migration.sql +98 -0
- package/prisma/migrations/20250410060521_alter_approval_journey_enums/migration.sql +12 -0
- package/prisma/migrations/20250410110823_alter_purchase_intake/migration.sql +2 -0
- package/prisma/migrations/20250411062955_alter_template_field_table/migration.sql +2 -0
- package/prisma/migrations/20250414065640_alter_template/migration.sql +2 -0
- package/prisma/migrations/20250414111856_alter_event_vendors/migration.sql +2 -0
- package/prisma/migrations/20250414125356_alter_event_vendor/migration.sql +9 -0
- package/prisma/migrations/20250415063558_alter_alert_type_enum/migration.sql +2 -0
- package/prisma/migrations/20250416062508_alter_purchase_intake_table/migration.sql +15 -0
- package/prisma/migrations/20250417090325_alter_purchase_intake_table_updated_enum/migration.sql +13 -0
- package/prisma/migrations/20250417111024_alter_purchase_intake_and_purchase_intake_item/migration.sql +16 -0
- package/prisma/migrations/20250421061732_init_quotation_and_quotation_log_tables/migration.sql +96 -0
- package/prisma/migrations/20250421112331_alter_item_table_added_unique_to_slug/migration.sql +8 -0
- package/prisma/migrations/20250422060655_init_user_activity_table/migration.sql +17 -0
- package/prisma/migrations/20250423053027_/migration.sql +9 -0
- package/prisma/migrations/20250423103233_alter_user_login_activity_table/migration.sql +5 -0
- package/prisma/migrations/20250423111141_init_location_tables/migration.sql +141 -0
- package/prisma/migrations/20250424120106_alter_event_table_added_user_relation/migration.sql +2 -0
- package/prisma/migrations/20250424141637_alter_states_table/migration.sql +11 -0
- package/prisma/migrations/20250425105131_alter_user_login_activity_table/migration.sql +9 -0
- package/prisma/migrations/20250428092626_alter_location_tables/migration.sql +34 -0
- package/prisma/migrations/20250428114301_alter_location_table/migration.sql +14 -0
- package/prisma/migrations/20250429103436_alter_event_vendor_table/migration.sql +14 -0
- package/prisma/migrations/20250429135621_alter_event_vendor_table/migration.sql +5 -0
- package/prisma/migrations/20250430094809_alter_form_master_table_added_user_relation/migration.sql +2 -0
- package/prisma/migrations/20250430103440_alter_event_table/migration.sql +3 -0
- package/prisma/migrations/20250501125411_alter_strategies_table/migration.sql +2 -0
- package/prisma/migrations/20250502065554_init_location_table/migration.sql +41 -0
- package/prisma/migrations/20250505104038_alter_bid_quotation_and_dynamic_form/migration.sql +22 -0
- package/prisma/migrations/20250505105253_alter_quotation/migration.sql +5 -0
- package/prisma/migrations/20250505124851_alter_alert_enum/migration.sql +56 -0
- package/prisma/migrations/20250505133250_init_sub_module_table/migration.sql +17 -0
- package/prisma/migrations/20250506054325_alter_event_vendor_bid_status/migration.sql +14 -0
- package/prisma/migrations/20250506102135_init_counter_offer_table/migration.sql +38 -0
- package/prisma/migrations/20250506103355_alter_bid_and_quotaion_table/migration.sql +5 -0
- package/prisma/migrations/20250506110309_alter_tenant_configuration_table/migration.sql +3 -0
- package/prisma/migrations/20250506123527_alter_vendor_kyu_infor_verification_status/migration.sql +2 -0
- package/prisma/migrations/20250507055536_alter_dynamic_form_table/migration.sql +2 -0
- package/prisma/migrations/20250507070518_alter_bid_log_and_quotation_log/migration.sql +15 -0
- package/prisma/migrations/20250507130834_alter_bid_status/migration.sql +10 -0
- package/prisma/migrations/20250508065503_alter_purchase_intake_item_table/migration.sql +16 -0
- package/prisma/migrations/20250508130119_alter_purchase_intake_item/migration.sql +13 -0
- package/prisma/migrations/20250512082244_altered_template_table_to_add_currency_id/migration.sql +12 -0
- package/prisma/migrations/20250512100817_alter_approval_journey_table/migration.sql +3 -0
- package/prisma/migrations/20250513083700_alter_item_table/migration.sql +2 -0
- package/prisma/migrations/20250514100915_alter_event_table_added_template_realtion/migration.sql +2 -0
- package/prisma/migrations/20250514103503_alter_vendor_table_added_is_kyc_approved_column/migration.sql +2 -0
- package/prisma/migrations/20250520131556_init_purchase_order_table/migration.sql +52 -0
- package/prisma/migrations/20250521113946_alter_purchase_order_status_enum/migration.sql +16 -0
- package/prisma/migrations/20250522083917_alter_event_vendor_bid_status_enum/migration.sql +17 -0
- package/prisma/migrations/20250522131610_updated_vendor_table/migration.sql +16 -0
- package/prisma/migrations/20250523051058_alter_vendor_kyc_verificaiton_status_enum/migration.sql +2 -0
- package/prisma/migrations/20250526072120_alter_vendor_table/migration.sql +16 -0
- package/prisma/migrations/20250527055351_init_purchase_order_activity_log/migration.sql +41 -0
- package/prisma/migrations/20250528060657_alter_item_tale/migration.sql +14 -0
- package/prisma/migrations/20250528061946_alter_event_item_table/migration.sql +5 -0
- package/prisma/migrations/20250528081337_alter_item_table/migration.sql +2 -0
- package/prisma/migrations/20250528081524_removed_item_id_from_item_table/migration.sql +11 -0
- package/prisma/migrations/20250528081843_alter_item_table/migration.sql +2 -0
- package/prisma/migrations/20250528094057_alter_alert_type_enum/migration.sql +11 -0
- package/prisma/migrations/20250529053721_alter_added_quantity_in_purchase_order/migration.sql +2 -0
- package/prisma/migrations/20250602055114_alter_approval_journey_parent_id_to_string/migration.sql +2 -0
- package/prisma/migrations/20250602055748_alter_event_configuration_added_rule_slug/migration.sql +2 -0
- package/prisma/migrations/20250602111042_init_user_vendor_socket_token_table/migration.sql +17 -0
- package/prisma/migrations/20250602125833_alter_bidlog_and_quoatationlog_tableto_add_json_field/migration.sql +5 -0
- package/prisma/migrations/20250603063501_alter_bid_and_quoatation_table/migration.sql +29 -0
- package/prisma/migrations/20250606015045_alter_quotation_log_table/migration.sql +2 -0
- package/prisma/migrations/20250606020918_alter_quotation_table/migration.sql +2 -0
- package/prisma/migrations/20250606022901_alter_quotation_log_table/migration.sql +3 -0
- package/prisma/migrations/20250606054914_init_event_activity_logs_table/migration.sql +35 -0
- package/prisma/migrations/20250606100634_alter_added_counter_offer_status/migration.sql +5 -0
- package/prisma/migrations/20250606100908_alter_counter_offer_table/migration.sql +2 -0
- package/prisma/migrations/20250610055710_alter_enum/migration.sql +16 -0
- package/prisma/migrations/20250610060558_alter_event_and_event_vendor_db/migration.sql +14 -0
- package/prisma/migrations/20250610091013_alter_purchase_intak_item_table/migration.sql +4 -0
- package/prisma/migrations/20250610100156_alter_purchase_intake_item_table/migration.sql +19 -0
- package/prisma/migrations/20250610125706_alter_event_table/migration.sql +6 -0
- package/prisma/migrations/20250610133613_added_timestamp/migration.sql +319 -0
- package/prisma/migrations/20250611090439_init_contact_us_table/migration.sql +23 -0
- package/prisma/migrations/20250611121005_alter_event_vendor_table/migration.sql +10 -0
- package/prisma/migrations/20250612064335_alter_tenant_configuration/migration.sql +3 -0
- package/prisma/migrations/20250612094643_alter_event_vendor_bid_status_enum/migration.sql +2 -0
- package/prisma/migrations/20250618074558_alter_updated_bid_status_and_quotation_status/migration.sql +21 -0
- package/prisma/migrations/20250618122242_alter_added_event_phase_closed/migration.sql +2 -0
- package/prisma/migrations/20250620054518_alter_event_phase/migration.sql +2 -0
- package/prisma/migrations/20250620062723_alter_event_phase/migration.sql +2 -0
- package/prisma/migrations/20250620063056_alter_event_phase/migration.sql +2 -0
- package/prisma/migrations/20250620100507_alter_event_phase/migration.sql +2 -0
- package/prisma/migrations/20250627104958_alter_counter_offer_status/migration.sql +2 -0
- package/prisma/migrations/20250702095923_alter_item_table/migration.sql +74 -0
- package/prisma/migrations/20250702120134_/migration.sql +14 -0
- package/prisma/migrations/20250702150717_alter_attribute_table/migration.sql +9 -0
- package/prisma/migrations/20250703090321_alter_item_table/migration.sql +2 -0
- package/prisma/migrations/20250707054625_alter_purchase_order_table/migration.sql +15 -0
- package/prisma/migrations/20250707111354_alter_purchase_order_table_and_init_purchase_order_item_table/migration.sql +39 -0
- package/prisma/migrations/20250707111522_alter_purchase_order_item_table/migration.sql +17 -0
- package/prisma/migrations/20250710054113_alter_bid_and_quotation_status/migration.sql +31 -0
- package/prisma/migrations/20250710070813_alter_event_status/migration.sql +2 -0
- package/prisma/migrations/20250710082332_alter_bid_and_quotations_table/migration.sql +36 -0
- package/prisma/migrations/20250714102325_init_upload_log_table/migration.sql +27 -0
- package/prisma/migrations/20250716061012_alter_event_activity_logs_to_activity_logs/migration.sql +48 -0
- package/prisma/migrations/20250716071839_init_chat_thread_chat_message_and_ai_models/migration.sql +56 -0
- package/prisma/migrations/20250716135548_alter_admin_alerts_enum/migration.sql +2 -0
- package/prisma/migrations/20250717100515_init_user_event_configuration/migration.sql +21 -0
- package/prisma/migrations/20250717101037_alter_user_event_configuration_table/migration.sql +19 -0
- package/prisma/migrations/20250718071630_alter_added_module_in_upload_logs_table/migration.sql +5 -0
- package/prisma/migrations/20250718071732_alter_module_enum/migration.sql +15 -0
- package/prisma/migrations/20250721054851_init_export_log_table/migration.sql +34 -0
- package/prisma/migrations/20250722054549_init_fiscal_year_table/migration.sql +22 -0
- package/prisma/migrations/20250722072051_alter_fiscal_year_table_added_uuid/migration.sql +14 -0
- package/prisma/migrations/20250722095259_alter_fiscal_table/migration.sql +9 -0
- package/prisma/migrations/20250723071050_alter_department_table/migration.sql +14 -0
- package/prisma/migrations/20250724071201_alter_export_upload_log_enum/migration.sql +8 -0
- package/prisma/migrations/20250725094759_new_migrate/migration.sql +2 -0
- package/prisma/migrations/20250725095012_alter_migration/migration.sql +2 -0
- package/prisma/migrations/20250728072402_init_budget_management_tables/migration.sql +80 -0
- package/prisma/migrations/migration_lock.toml +3 -0
- package/prisma/schema.prisma +2609 -0
- package/prisma/seeders/approval-hierarchy.seed.js +340 -0
- package/prisma/seeders/attribute-value.seed.js +64 -0
- package/prisma/seeders/attribute.seed.js +61 -0
- package/prisma/seeders/category.seed.js +133 -0
- package/prisma/seeders/city.seed.js +147 -0
- package/prisma/seeders/country.seed.js +282 -0
- package/prisma/seeders/currency.seed.js +41 -0
- package/prisma/seeders/customer-notification.seed.js +83 -0
- package/prisma/seeders/department.seed.js +38 -0
- package/prisma/seeders/docs/CORE_SEEDER_OPTIMIZATIONS.md +270 -0
- package/prisma/seeders/docs/GEOGRAPHIC_PERFORMANCE_OPTIMIZATIONS.md +175 -0
- package/prisma/seeders/dynamic-form.seed.js +135 -0
- package/prisma/seeders/email-template.seed.js +68 -0
- package/prisma/seeders/faq-category.seed.js +56 -0
- package/prisma/seeders/faq.seed.js +61 -0
- package/prisma/seeders/form-master.seed.js +55 -0
- package/prisma/seeders/item.seed.js +133 -0
- package/prisma/seeders/permission.seed.js +102 -0
- package/prisma/seeders/region.seed.js +78 -0
- package/prisma/seeders/role-permission.seed.js +70 -0
- package/prisma/seeders/role.seed.js +38 -0
- package/prisma/seeders/seed.js +553 -0
- package/prisma/seeders/serial-number-config.seed.js +58 -0
- package/prisma/seeders/smtp-config.seed.js +61 -0
- package/prisma/seeders/state.seed.js +170 -0
- package/prisma/seeders/strategies.seed.js +54 -0
- package/prisma/seeders/subregion.seed.js +88 -0
- package/prisma/seeders/support-category.seed.js +56 -0
- package/prisma/seeders/template.seed.js +87 -0
- package/prisma/seeders/test-core-seeders.js +276 -0
- package/prisma/seeders/user-department.seed.js +66 -0
- package/prisma/seeders/user-event-configuration.seed.js +47 -0
- package/prisma/seeders/user-role.seed.js +74 -0
- package/prisma/seeders/user.seed.js +114 -0
- package/prisma/seeders/utils/bulk-seeder.js +300 -0
- package/prisma/seeders/utils/config.js +103 -0
- package/prisma/seeders/utils/connection-manager.js +380 -0
- package/prisma/seeders/utils/content-seeder.js +472 -0
- package/prisma/seeders/utils/core-seeder.js +330 -0
- package/prisma/seeders/utils/json-loader.js +69 -0
- package/prisma/seeders/utils/performance-config.js +341 -0
- package/prisma/seeders/utils/performance-helpers.js +206 -0
- package/prisma/seeders/utils/progress-tracker.js +364 -0
- package/prisma/seeders/utils/seeder-config-mapper.js +316 -0
- package/scripts/seed-databases.js +873 -0
- package/scripts/sync-schemas.js +865 -0
- package/scripts/truncate-tables.js +1048 -0
- package/src/prisma/client.d.ts +1 -0
- package/src/prisma/client.js +4 -0
- package/src/prisma/default.d.ts +1 -0
- package/src/prisma/default.js +4 -0
- package/src/prisma/edge.d.ts +1 -0
- package/src/prisma/edge.js +2084 -0
- package/src/prisma/index-browser.js +2043 -0
- package/src/prisma/index.d.ts +202051 -0
- package/src/prisma/index.js +2113 -0
- package/src/prisma/libquery_engine-darwin.dylib.node +0 -0
- package/src/prisma/libquery_engine-darwin.dylib.node.tmp24628 +0 -0
- package/src/prisma/libquery_engine-darwin.dylib.node.tmp29464 +0 -0
- package/src/prisma/libquery_engine-debian-openssl-3.0.x.so.node +0 -0
- package/src/prisma/package.json +140 -0
- package/src/prisma/query_engine-windows.dll.node +0 -0
- package/src/prisma/query_engine-windows.dll.node.tmp4144 +0 -0
- package/src/prisma/runtime/edge-esm.js +34 -0
- package/src/prisma/runtime/edge.js +34 -0
- package/src/prisma/runtime/index-browser.d.ts +370 -0
- package/src/prisma/runtime/index-browser.js +16 -0
- package/src/prisma/runtime/library.d.ts +3647 -0
- package/src/prisma/runtime/library.js +146 -0
- package/src/prisma/runtime/react-native.js +83 -0
- package/src/prisma/runtime/wasm.js +35 -0
- package/src/prisma/schema.prisma +2609 -0
- package/src/prisma/wasm.d.ts +1 -0
- package/src/prisma/wasm.js +2043 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# Core Data Seeder Optimizations
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document outlines the optimizations implemented for core data seeders (users, roles, permissions, departments, and currencies) to improve performance, reliability, and error resilience.
|
|
6
|
+
|
|
7
|
+
## Key Optimizations Implemented
|
|
8
|
+
|
|
9
|
+
### 1. Optimized Batch Processing
|
|
10
|
+
|
|
11
|
+
**Smaller Batch Sizes (50-100 items)**
|
|
12
|
+
- Users: 50 items per batch
|
|
13
|
+
- Roles: 25 items per batch (most critical)
|
|
14
|
+
- Permissions: 100 items per batch
|
|
15
|
+
- Departments: 50 items per batch
|
|
16
|
+
- Currencies: 75 items per batch
|
|
17
|
+
|
|
18
|
+
**Benefits:**
|
|
19
|
+
- Reduced memory footprint
|
|
20
|
+
- Better error isolation
|
|
21
|
+
- Improved database connection management
|
|
22
|
+
- Lower risk of timeout failures
|
|
23
|
+
|
|
24
|
+
### 2. Enhanced Retry Logic with Conditional Retries
|
|
25
|
+
|
|
26
|
+
**Critical Entity Protection:**
|
|
27
|
+
- Roles: 5 retry attempts (highest priority)
|
|
28
|
+
- Users: 3 retry attempts
|
|
29
|
+
- Permissions: 3 retry attempts
|
|
30
|
+
- Departments: 3 retry attempts
|
|
31
|
+
- Currencies: 3 retry attempts
|
|
32
|
+
|
|
33
|
+
**Exponential Backoff:**
|
|
34
|
+
- Base delays range from 500ms to 1000ms
|
|
35
|
+
- Exponential backoff prevents thundering herd problems
|
|
36
|
+
- Configurable per entity type
|
|
37
|
+
|
|
38
|
+
### 3. Individual Upserts with Batch Parallelization
|
|
39
|
+
|
|
40
|
+
**Strategy:**
|
|
41
|
+
- Maintain individual upsert operations for precise error handling
|
|
42
|
+
- Process items in parallel within batches
|
|
43
|
+
- Use `Promise.allSettled()` for batch resilience
|
|
44
|
+
- Continue processing even if some items fail
|
|
45
|
+
|
|
46
|
+
**Benefits:**
|
|
47
|
+
- Better error isolation and reporting
|
|
48
|
+
- Graceful handling of constraint violations
|
|
49
|
+
- Detailed progress tracking per item
|
|
50
|
+
- No loss of data integrity
|
|
51
|
+
|
|
52
|
+
### 4. Advanced Progress Tracking
|
|
53
|
+
|
|
54
|
+
**Features:**
|
|
55
|
+
- Real-time progress bars with percentage completion
|
|
56
|
+
- Batch-level progress reporting
|
|
57
|
+
- Error logging without interrupting progress display
|
|
58
|
+
- Memory usage monitoring (optional)
|
|
59
|
+
- Processing rate calculation
|
|
60
|
+
|
|
61
|
+
**Error Resilience:**
|
|
62
|
+
- Progress continues even with individual item failures
|
|
63
|
+
- Detailed error logging with entity identifiers
|
|
64
|
+
- Separate error collection and reporting
|
|
65
|
+
|
|
66
|
+
### 5. Performance Configuration System
|
|
67
|
+
|
|
68
|
+
**Dynamic Configuration:**
|
|
69
|
+
- System resource detection (CPU, memory)
|
|
70
|
+
- Environment-specific optimizations
|
|
71
|
+
- Profile-based configurations (speed, memory, stability)
|
|
72
|
+
- Runtime configuration adjustments
|
|
73
|
+
|
|
74
|
+
**Core Configuration Profiles:**
|
|
75
|
+
- **Stability Profile:** Lower concurrency, more retries, longer timeouts
|
|
76
|
+
- **Speed Profile:** Higher concurrency, optimized batch sizes
|
|
77
|
+
- **Memory Profile:** Minimal memory usage, smaller batches
|
|
78
|
+
|
|
79
|
+
## File Structure
|
|
80
|
+
|
|
81
|
+
### Core Seeder Utility
|
|
82
|
+
```
|
|
83
|
+
/utils/core-seeder.js
|
|
84
|
+
```
|
|
85
|
+
- Main CoreSeeder class with optimized batch processing
|
|
86
|
+
- Retry logic with exponential backoff
|
|
87
|
+
- Progress tracking integration
|
|
88
|
+
- Memory management utilities
|
|
89
|
+
|
|
90
|
+
### Performance Configuration
|
|
91
|
+
```
|
|
92
|
+
/utils/performance-config.js
|
|
93
|
+
```
|
|
94
|
+
- System resource detection
|
|
95
|
+
- Entity-specific configurations
|
|
96
|
+
- Environment-based optimization profiles
|
|
97
|
+
- Dynamic configuration adjustment
|
|
98
|
+
|
|
99
|
+
### Updated Seeders
|
|
100
|
+
```
|
|
101
|
+
user.seed.js - User seeding with password hashing
|
|
102
|
+
role.seed.js - Role seeding with critical entity handling
|
|
103
|
+
permission.seed.js - Permission seeding with file aggregation
|
|
104
|
+
department.seed.js - Department seeding with slug-based upserts
|
|
105
|
+
currency.seed.js - Currency seeding with code-based upserts
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Configuration Options
|
|
109
|
+
|
|
110
|
+
### Batch Size Configuration
|
|
111
|
+
```javascript
|
|
112
|
+
BATCH_SIZES: {
|
|
113
|
+
users: 50, // Smaller for complex password hashing
|
|
114
|
+
roles: 25, // Smallest for most critical entity
|
|
115
|
+
permissions: 100, // Larger for simpler data structure
|
|
116
|
+
departments: 50, // Medium for organizational data
|
|
117
|
+
currencies: 75 // Medium for reference data
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Retry Configuration
|
|
122
|
+
```javascript
|
|
123
|
+
RETRY_CONFIG: {
|
|
124
|
+
enabled: true,
|
|
125
|
+
maxAttempts: {
|
|
126
|
+
roles: 5, // Highest retry for critical roles
|
|
127
|
+
users: 3, // Standard retry for users
|
|
128
|
+
permissions: 3, // Standard retry for permissions
|
|
129
|
+
departments: 3, // Standard retry for departments
|
|
130
|
+
currencies: 3 // Standard retry for currencies
|
|
131
|
+
},
|
|
132
|
+
exponentialBackoff: true
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Environment-Specific Settings
|
|
137
|
+
- **Development:** Stability profile, verbose logging, 0.8x batch size
|
|
138
|
+
- **Test:** Memory profile, minimal logging, 0.5x batch size
|
|
139
|
+
- **Production:** Speed profile, standard logging, 1.2x batch size
|
|
140
|
+
|
|
141
|
+
## Usage Examples
|
|
142
|
+
|
|
143
|
+
### Basic Usage with Core Seeder
|
|
144
|
+
```javascript
|
|
145
|
+
import { createCoreSeeder } from './utils/core-seeder.js';
|
|
146
|
+
|
|
147
|
+
const coreSeeder = createCoreSeeder(prisma, {
|
|
148
|
+
profile: 'stability',
|
|
149
|
+
enableRetries: true,
|
|
150
|
+
logProgress: true
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const result = await coreSeeder.processCore(data, processor, 'users');
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Using Convenience Function
|
|
157
|
+
```javascript
|
|
158
|
+
import { seedCoreEntity } from './utils/core-seeder.js';
|
|
159
|
+
|
|
160
|
+
const result = await seedCoreEntity(
|
|
161
|
+
prisma,
|
|
162
|
+
roleData,
|
|
163
|
+
'roles',
|
|
164
|
+
{
|
|
165
|
+
model: 'role',
|
|
166
|
+
whereField: 'slug',
|
|
167
|
+
updateFields: ['role_name', 'description', 'is_active'],
|
|
168
|
+
createFields: ['role_name', 'slug', 'description', 'is_active']
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
profile: 'stability',
|
|
172
|
+
enableRetries: true
|
|
173
|
+
}
|
|
174
|
+
);
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Performance Metrics
|
|
178
|
+
|
|
179
|
+
### Expected Improvements
|
|
180
|
+
- **Error Resilience:** 95%+ completion rate even with individual failures
|
|
181
|
+
- **Memory Efficiency:** 60-70% reduction in peak memory usage
|
|
182
|
+
- **Processing Speed:** Optimized for stability over raw speed
|
|
183
|
+
- **Error Recovery:** Automatic retry for critical entities
|
|
184
|
+
- **Progress Visibility:** Real-time progress tracking with error details
|
|
185
|
+
|
|
186
|
+
### Monitoring
|
|
187
|
+
- Batch completion rates
|
|
188
|
+
- Retry success rates
|
|
189
|
+
- Memory usage patterns
|
|
190
|
+
- Processing duration per entity type
|
|
191
|
+
- Error distribution analysis
|
|
192
|
+
|
|
193
|
+
## Best Practices
|
|
194
|
+
|
|
195
|
+
### 1. Error Handling
|
|
196
|
+
- Always use try-catch blocks in processors
|
|
197
|
+
- Return meaningful error messages
|
|
198
|
+
- Log errors with entity identifiers
|
|
199
|
+
- Continue processing despite individual failures
|
|
200
|
+
|
|
201
|
+
### 2. Memory Management
|
|
202
|
+
- Enable garbage collection between batch groups
|
|
203
|
+
- Monitor memory usage for large datasets
|
|
204
|
+
- Use streaming for very large files
|
|
205
|
+
|
|
206
|
+
### 3. Database Connections
|
|
207
|
+
- Use connection pooling
|
|
208
|
+
- Set appropriate timeouts
|
|
209
|
+
- Handle connection failures gracefully
|
|
210
|
+
|
|
211
|
+
### 4. Monitoring and Logging
|
|
212
|
+
- Enable progress tracking for visibility
|
|
213
|
+
- Log critical entity failures prominently
|
|
214
|
+
- Track processing rates for performance tuning
|
|
215
|
+
|
|
216
|
+
## Migration Notes
|
|
217
|
+
|
|
218
|
+
### From Previous Implementation
|
|
219
|
+
1. **Batch Processing:** Changed from single-item processing to optimized batching
|
|
220
|
+
2. **Error Handling:** Enhanced from basic try-catch to sophisticated retry logic
|
|
221
|
+
3. **Progress Tracking:** Upgraded from simple counters to advanced progress bars
|
|
222
|
+
4. **Configuration:** Added dynamic configuration based on system resources
|
|
223
|
+
5. **Memory Management:** Added automatic garbage collection and memory monitoring
|
|
224
|
+
|
|
225
|
+
### Breaking Changes
|
|
226
|
+
- Function signatures may have changed for some seeders
|
|
227
|
+
- Return values now include detailed statistics
|
|
228
|
+
- Error handling is more granular
|
|
229
|
+
- Configuration options have been expanded
|
|
230
|
+
|
|
231
|
+
## Future Enhancements
|
|
232
|
+
|
|
233
|
+
### Planned Improvements
|
|
234
|
+
1. **Database Connection Optimization:** Smart connection pooling
|
|
235
|
+
2. **Parallel File Processing:** Concurrent JSON file loading
|
|
236
|
+
3. **Incremental Seeding:** Skip unchanged records
|
|
237
|
+
4. **Performance Analytics:** Detailed performance metrics collection
|
|
238
|
+
5. **Health Checks:** Pre-seeding system validation
|
|
239
|
+
|
|
240
|
+
### Monitoring Dashboard
|
|
241
|
+
Consider implementing a seeding dashboard to track:
|
|
242
|
+
- Real-time progress across all entities
|
|
243
|
+
- Error rates and patterns
|
|
244
|
+
- Performance metrics
|
|
245
|
+
- System resource utilization
|
|
246
|
+
- Historical seeding performance
|
|
247
|
+
|
|
248
|
+
## Troubleshooting
|
|
249
|
+
|
|
250
|
+
### Common Issues
|
|
251
|
+
1. **High Memory Usage:** Reduce batch sizes or enable memory profile
|
|
252
|
+
2. **Timeout Errors:** Increase query timeouts or reduce batch sizes
|
|
253
|
+
3. **Connection Pool Exhaustion:** Reduce concurrent batches
|
|
254
|
+
4. **Individual Item Failures:** Check data validation and constraints
|
|
255
|
+
|
|
256
|
+
### Debug Configuration
|
|
257
|
+
```javascript
|
|
258
|
+
const coreSeeder = createCoreSeeder(prisma, {
|
|
259
|
+
profile: 'stability',
|
|
260
|
+
enableRetries: true,
|
|
261
|
+
logProgress: true,
|
|
262
|
+
performanceConfig: {
|
|
263
|
+
overrides: {
|
|
264
|
+
core: {
|
|
265
|
+
users: { batchSize: 10, maxConcurrentBatches: 1 }
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
```
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# Geographic Seeders Performance Optimizations
|
|
2
|
+
|
|
3
|
+
This document outlines the performance optimizations implemented for country and state seeders following the `geographic` category configuration.
|
|
4
|
+
|
|
5
|
+
## ✅ Implemented Features
|
|
6
|
+
|
|
7
|
+
### 1. Performance Configuration (`geographic` category)
|
|
8
|
+
- **File**: `utils/performance-config.js`
|
|
9
|
+
- **Countries Configuration**:
|
|
10
|
+
- Batch size: 50 (optimized for relationship management)
|
|
11
|
+
- Max concurrent batches: 4 (CPU-aware)
|
|
12
|
+
- Connection pool size: 10
|
|
13
|
+
- Query timeout: 60s
|
|
14
|
+
- Retry attempts: 3
|
|
15
|
+
- Retry delay: 1000ms with exponential backoff
|
|
16
|
+
|
|
17
|
+
- **States Configuration**:
|
|
18
|
+
- Batch size: 500 (larger batches for better throughput)
|
|
19
|
+
- Max concurrent batches: 6 (CPU-aware)
|
|
20
|
+
- Connection pool size: 12
|
|
21
|
+
- Query timeout: 90s
|
|
22
|
+
- Retry attempts: 3
|
|
23
|
+
- Retry delay: 1000ms with exponential backoff
|
|
24
|
+
|
|
25
|
+
### 2. Batch Processing with `createMany` and `skipDuplicates`
|
|
26
|
+
- **Implementation**: Both seeders now use `prisma.model.createMany()` with `skipDuplicates: true`
|
|
27
|
+
- **Benefits**:
|
|
28
|
+
- Significantly faster than individual upserts
|
|
29
|
+
- Automatic duplicate handling
|
|
30
|
+
- Reduced database roundtrips
|
|
31
|
+
|
|
32
|
+
### 3. Retry Logic (3 attempts + exponential backoff)
|
|
33
|
+
- **Class**: `RetryHandler` in `utils/performance-helpers.js`
|
|
34
|
+
- **Features**:
|
|
35
|
+
- Configurable max attempts (default: 3)
|
|
36
|
+
- Exponential backoff: delay = baseDelay * 2^(attempt-1)
|
|
37
|
+
- Context-aware error messages
|
|
38
|
+
- Graceful failure handling
|
|
39
|
+
|
|
40
|
+
### 4. Connection Manager for Transactions
|
|
41
|
+
- **Implementation**: Using `connectionManager.executeWithConnection()`
|
|
42
|
+
- **Benefits**:
|
|
43
|
+
- Proper connection pooling
|
|
44
|
+
- Transaction-based batch processing
|
|
45
|
+
- Automatic connection cleanup
|
|
46
|
+
- Connection reuse across operations
|
|
47
|
+
|
|
48
|
+
### 5. Garbage Collection Hints
|
|
49
|
+
- **Implementation**: `MemoryManager` class with multiple GC strategies
|
|
50
|
+
- **Features**:
|
|
51
|
+
- Automatic GC hints after each batch: `global.gc && global.gc()`
|
|
52
|
+
- Forced GC with delay every 10 batches
|
|
53
|
+
- Memory usage monitoring and logging
|
|
54
|
+
- Memory threshold detection
|
|
55
|
+
|
|
56
|
+
## 🔧 Configuration Details
|
|
57
|
+
|
|
58
|
+
### System-Aware Configuration
|
|
59
|
+
The performance config automatically adjusts based on:
|
|
60
|
+
- **CPU Count**: Concurrent batches scale with CPU cores
|
|
61
|
+
- **Available Memory**: Batch sizes adjust for low/high memory systems
|
|
62
|
+
- **Performance Profiles**: `speed`, `memory`, `stability` presets
|
|
63
|
+
|
|
64
|
+
### Memory Management
|
|
65
|
+
```javascript
|
|
66
|
+
// Memory monitoring
|
|
67
|
+
MemoryManager.logMemoryUsage('Before processing');
|
|
68
|
+
|
|
69
|
+
// Automatic GC hints
|
|
70
|
+
global.gc && global.gc();
|
|
71
|
+
|
|
72
|
+
// Forced GC with delay
|
|
73
|
+
await MemoryManager.forceGarbageCollectionWithDelay();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Retry Configuration
|
|
77
|
+
```javascript
|
|
78
|
+
const retryHandler = new RetryHandler(
|
|
79
|
+
performanceConfig.retryAttempts || 3,
|
|
80
|
+
performanceConfig.retryDelay || 1000
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// Exponential backoff retry execution
|
|
84
|
+
await retryHandler.execute(
|
|
85
|
+
async () => prisma.model.createMany(data),
|
|
86
|
+
'Batch operation context'
|
|
87
|
+
);
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 📊 Performance Improvements
|
|
91
|
+
|
|
92
|
+
### Before Optimization
|
|
93
|
+
- Individual `upsert()` operations
|
|
94
|
+
- No retry logic
|
|
95
|
+
- Basic error handling
|
|
96
|
+
- No memory management
|
|
97
|
+
- Sequential processing
|
|
98
|
+
|
|
99
|
+
### After Optimization
|
|
100
|
+
- Bulk `createMany()` operations with `skipDuplicates`
|
|
101
|
+
- Intelligent retry with exponential backoff
|
|
102
|
+
- Transaction-based processing
|
|
103
|
+
- Active memory management with GC hints
|
|
104
|
+
- Configurable concurrent batch processing
|
|
105
|
+
|
|
106
|
+
## 🚀 Usage Examples
|
|
107
|
+
|
|
108
|
+
### Using Performance Config
|
|
109
|
+
```javascript
|
|
110
|
+
const performanceConfig = createPerformanceConfig().getConfig('geographic', 'countries');
|
|
111
|
+
const batchSize = performanceConfig.batchSize;
|
|
112
|
+
const retryHandler = new RetryHandler(
|
|
113
|
+
performanceConfig.retryAttempts,
|
|
114
|
+
performanceConfig.retryDelay
|
|
115
|
+
);
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Transaction-Based Processing
|
|
119
|
+
```javascript
|
|
120
|
+
await connectionManager.executeWithConnection(
|
|
121
|
+
'geographic-countries',
|
|
122
|
+
process.env.DATABASE_URL,
|
|
123
|
+
async (transactionPrisma) => {
|
|
124
|
+
return await transactionPrisma.country.createMany({
|
|
125
|
+
data: countriesToCreate,
|
|
126
|
+
skipDuplicates: true,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
);
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Memory-Aware Batch Processing
|
|
133
|
+
```javascript
|
|
134
|
+
// Log memory before processing
|
|
135
|
+
MemoryManager.logMemoryUsage('Before country processing');
|
|
136
|
+
|
|
137
|
+
// Process with GC hints
|
|
138
|
+
for (let i = 0; i < batches.length; i++) {
|
|
139
|
+
await processBatch(batch);
|
|
140
|
+
|
|
141
|
+
// Force GC every 10 batches
|
|
142
|
+
if ((i + 1) % 10 === 0) {
|
|
143
|
+
await MemoryManager.forceGarbageCollectionWithDelay();
|
|
144
|
+
MemoryManager.logMemoryUsage(`After batch ${i + 1}`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## 🛠️ Files Modified
|
|
150
|
+
|
|
151
|
+
1. **Country Seeder**: `seeders/country.seed.js`
|
|
152
|
+
2. **State Seeder**: `seeders/state.seed.js`
|
|
153
|
+
3. **Performance Config**: `utils/performance-config.js`
|
|
154
|
+
4. **Performance Helpers**: `utils/performance-helpers.js` (new)
|
|
155
|
+
5. **Connection Manager**: `utils/connection-manager.js` (enhanced)
|
|
156
|
+
6. **Bulk Seeder**: `utils/bulk-seeder.js` (existing)
|
|
157
|
+
|
|
158
|
+
## 📈 Expected Performance Gains
|
|
159
|
+
|
|
160
|
+
- **Throughput**: 5-10x improvement with bulk operations
|
|
161
|
+
- **Memory Usage**: Controlled with active GC management
|
|
162
|
+
- **Reliability**: 99%+ success rate with retry logic
|
|
163
|
+
- **Scalability**: Adapts to system resources automatically
|
|
164
|
+
- **Error Recovery**: Graceful handling of transient failures
|
|
165
|
+
|
|
166
|
+
## 🔍 Monitoring and Debugging
|
|
167
|
+
|
|
168
|
+
The implementation includes comprehensive logging:
|
|
169
|
+
- Memory usage before/after processing
|
|
170
|
+
- Batch completion progress
|
|
171
|
+
- Retry attempt notifications
|
|
172
|
+
- Error context and recovery
|
|
173
|
+
- Performance metrics and timing
|
|
174
|
+
|
|
175
|
+
This provides full visibility into the seeding process and helps identify any performance bottlenecks or issues.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { PrismaClient } from "../../src/prisma/index.js";
|
|
2
|
+
import { loadContentData } from "./utils/json-loader.js";
|
|
3
|
+
import {
|
|
4
|
+
createProgressTracker,
|
|
5
|
+
logEntityError,
|
|
6
|
+
logSeederComplete,
|
|
7
|
+
logSeederStart,
|
|
8
|
+
} from "./utils/progress-tracker.js";
|
|
9
|
+
|
|
10
|
+
export async function seedDynamicForm(prismaClient) {
|
|
11
|
+
// Use the passed client or create new one only if needed (for standalone testing)
|
|
12
|
+
const prisma = prismaClient || new PrismaClient();
|
|
13
|
+
|
|
14
|
+
logSeederStart("dynamic-form");
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
// Load dynamic form data from JSON
|
|
18
|
+
const formModules = loadContentData("dynamic-form");
|
|
19
|
+
|
|
20
|
+
// Track progress across all modules and forms
|
|
21
|
+
let totalForms = 0;
|
|
22
|
+
formModules.forEach((module) => {
|
|
23
|
+
if (module.dynamic_form && Array.isArray(module.dynamic_form)) {
|
|
24
|
+
totalForms += module.dynamic_form.length;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const tracker = createProgressTracker(totalForms, "dynamic forms");
|
|
29
|
+
|
|
30
|
+
// Process each module
|
|
31
|
+
for (const formModule of formModules) {
|
|
32
|
+
try {
|
|
33
|
+
// Check if module exists
|
|
34
|
+
let moduleRecord = await prisma.formMaster.findFirst({
|
|
35
|
+
where: {
|
|
36
|
+
module_slug: formModule.module_slug,
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Create module if it doesn't exist
|
|
41
|
+
if (!moduleRecord) {
|
|
42
|
+
moduleRecord = await prisma.formMaster.create({
|
|
43
|
+
data: {
|
|
44
|
+
module_name: formModule.module_name,
|
|
45
|
+
module_slug: formModule.module_slug,
|
|
46
|
+
is_active: formModule.is_active,
|
|
47
|
+
is_deleted: formModule.is_deleted,
|
|
48
|
+
created_by: formModule.created_by || null,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
console.log(`Created form module: ${formModule.module_name}`);
|
|
52
|
+
} else {
|
|
53
|
+
moduleRecord = await prisma.formMaster.update({
|
|
54
|
+
where: { id: moduleRecord.id },
|
|
55
|
+
data: {
|
|
56
|
+
module_name: formModule.module_name,
|
|
57
|
+
module_slug: formModule.module_slug,
|
|
58
|
+
is_active: formModule.is_active,
|
|
59
|
+
is_deleted: formModule.is_deleted,
|
|
60
|
+
created_by: formModule.created_by || null,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Process each form in the module
|
|
66
|
+
if (formModule.dynamic_form && Array.isArray(formModule.dynamic_form)) {
|
|
67
|
+
for (const form of formModule.dynamic_form) {
|
|
68
|
+
try {
|
|
69
|
+
// Check if form exists
|
|
70
|
+
const existingForm = await prisma.dynamicForm.findFirst({
|
|
71
|
+
where: {
|
|
72
|
+
module_id: moduleRecord.id,
|
|
73
|
+
form_slug: form.form_slug,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
if (!existingForm) {
|
|
78
|
+
// Create the dynamic form
|
|
79
|
+
await prisma.dynamicForm.create({
|
|
80
|
+
data: {
|
|
81
|
+
module_id: moduleRecord.id,
|
|
82
|
+
form_name: form.form_name,
|
|
83
|
+
form_slug: form.form_slug,
|
|
84
|
+
form_order: form.form_order,
|
|
85
|
+
fields: form.fields,
|
|
86
|
+
is_active: form.is_active,
|
|
87
|
+
is_deleted: form.is_deleted,
|
|
88
|
+
created_by: form.created_by || null,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
console.log(`Created dynamic form: ${form.form_name}`);
|
|
92
|
+
} else {
|
|
93
|
+
// Update the form if it exists
|
|
94
|
+
await prisma.dynamicForm.update({
|
|
95
|
+
where: { id: existingForm.id },
|
|
96
|
+
data: {
|
|
97
|
+
form_name: form.form_name,
|
|
98
|
+
form_order: form.form_order,
|
|
99
|
+
fields: form.fields,
|
|
100
|
+
is_active: form.is_active,
|
|
101
|
+
is_deleted: form.is_deleted,
|
|
102
|
+
created_by: form.created_by || null,
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
console.log(`Updated dynamic form: ${form.form_name}`);
|
|
106
|
+
}
|
|
107
|
+
} catch (error) {
|
|
108
|
+
logEntityError("dynamic-form", form.form_name, error.message);
|
|
109
|
+
console.error(
|
|
110
|
+
`Error processing form ${form.form_name}: ${error.message}`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
tracker.update();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
} catch (error) {
|
|
118
|
+
logEntityError("form-module", formModule.module_name, error.message);
|
|
119
|
+
console.error(
|
|
120
|
+
`Error processing module ${formModule.module_name}: ${error.message}`
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
logSeederComplete("Dynamic Form");
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error(`Failed to seed dynamic forms: ${error.message}`);
|
|
128
|
+
throw error;
|
|
129
|
+
} finally {
|
|
130
|
+
// Only disconnect if we created our own client
|
|
131
|
+
if (!prismaClient) {
|
|
132
|
+
await prisma.$disconnect();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { PrismaClient } from "../../src/prisma/index.js";
|
|
2
|
+
import { loadContentData } from "./utils/json-loader.js";
|
|
3
|
+
import {
|
|
4
|
+
createProgressTracker,
|
|
5
|
+
logSeederStart,
|
|
6
|
+
logSeederComplete,
|
|
7
|
+
logEntityError,
|
|
8
|
+
} from "./utils/progress-tracker.js";
|
|
9
|
+
|
|
10
|
+
export async function seedEmailTemplate(prismaClient) {
|
|
11
|
+
// Use the passed client or create new one only if needed (for standalone testing)
|
|
12
|
+
const prisma = prismaClient || new PrismaClient();
|
|
13
|
+
|
|
14
|
+
logSeederStart("email templates");
|
|
15
|
+
|
|
16
|
+
// Load email templates from JSON
|
|
17
|
+
const emailTemplateData = loadContentData("email-template");
|
|
18
|
+
|
|
19
|
+
// Create progress tracker
|
|
20
|
+
const tracker = createProgressTracker(
|
|
21
|
+
emailTemplateData.length,
|
|
22
|
+
"email templates"
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
for (const template of emailTemplateData) {
|
|
26
|
+
try {
|
|
27
|
+
await prisma.emailTemplate.upsert({
|
|
28
|
+
where: {
|
|
29
|
+
template_slug: template.template_slug,
|
|
30
|
+
},
|
|
31
|
+
update: {
|
|
32
|
+
template_name: template.template_name,
|
|
33
|
+
remark: template.remark,
|
|
34
|
+
medium: template.medium,
|
|
35
|
+
event: template.event,
|
|
36
|
+
title: template.title,
|
|
37
|
+
trigger_message: template.trigger_message,
|
|
38
|
+
is_recurring: template.is_recurring,
|
|
39
|
+
is_active: template.is_active,
|
|
40
|
+
created_by: template.created_by,
|
|
41
|
+
},
|
|
42
|
+
create: {
|
|
43
|
+
template_name: template.template_name,
|
|
44
|
+
remark: template.remark,
|
|
45
|
+
medium: template.medium,
|
|
46
|
+
event: template.event,
|
|
47
|
+
template_slug: template.template_slug,
|
|
48
|
+
title: template.title,
|
|
49
|
+
trigger_message: template.trigger_message,
|
|
50
|
+
is_recurring: template.is_recurring,
|
|
51
|
+
is_active: template.is_active,
|
|
52
|
+
created_by: template.created_by,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
} catch (error) {
|
|
56
|
+
// Log error but don't interrupt progress bar
|
|
57
|
+
logEntityError("email template", template.template_name, error.message);
|
|
58
|
+
}
|
|
59
|
+
tracker.update();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
logSeederComplete("Email templates");
|
|
63
|
+
|
|
64
|
+
// Only disconnect if we created our own client
|
|
65
|
+
if (!prismaClient) {
|
|
66
|
+
await prisma.$disconnect();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// prisma/seed.ts
|
|
2
|
+
|
|
3
|
+
import { PrismaClient } from "../../src/prisma/index.js";
|
|
4
|
+
import { loadContentData } from "./utils/json-loader.js";
|
|
5
|
+
import {
|
|
6
|
+
createProgressTracker,
|
|
7
|
+
logSeederStart,
|
|
8
|
+
logSeederComplete,
|
|
9
|
+
logEntityError,
|
|
10
|
+
} from "./utils/progress-tracker.js";
|
|
11
|
+
|
|
12
|
+
export async function seedFaqCategory(prismaClient) {
|
|
13
|
+
// Use the passed client or create new one only if needed (for standalone testing)
|
|
14
|
+
const prisma = prismaClient || new PrismaClient();
|
|
15
|
+
|
|
16
|
+
logSeederStart("FAQ categories");
|
|
17
|
+
|
|
18
|
+
// Load FAQ categories from JSON
|
|
19
|
+
const faqCategoryData = loadContentData("faq-categories");
|
|
20
|
+
|
|
21
|
+
// Create progress tracker
|
|
22
|
+
const tracker = createProgressTracker(
|
|
23
|
+
faqCategoryData.length,
|
|
24
|
+
"FAQ categories"
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
for (const faqCategory of faqCategoryData) {
|
|
28
|
+
try {
|
|
29
|
+
await prisma.faqCategory.upsert({
|
|
30
|
+
where: {
|
|
31
|
+
slug: faqCategory.slug,
|
|
32
|
+
},
|
|
33
|
+
update: {
|
|
34
|
+
category_name: faqCategory.category_name,
|
|
35
|
+
is_active: faqCategory.is_active,
|
|
36
|
+
},
|
|
37
|
+
create: {
|
|
38
|
+
category_name: faqCategory.category_name,
|
|
39
|
+
slug: faqCategory.slug,
|
|
40
|
+
is_active: faqCategory.is_active,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
} catch (error) {
|
|
44
|
+
// Log error but don't interrupt progress bar
|
|
45
|
+
logEntityError("FAQ category", faqCategory.category_name, error.message);
|
|
46
|
+
}
|
|
47
|
+
tracker.update();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
logSeederComplete("FAQ categories");
|
|
51
|
+
|
|
52
|
+
// Only disconnect if we created our own client
|
|
53
|
+
if (!prismaClient) {
|
|
54
|
+
await prisma.$disconnect();
|
|
55
|
+
}
|
|
56
|
+
}
|