Skip to content

Implement Advanced Database Seeding System #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

AlpTalhaYazar
Copy link
Collaborator

Advanced Database Seeding System

This PR introduces a robust and comprehensive data seeding system for the API project, enabling developers to quickly set up a realistic testing environment with pre-populated data.

Changes

New Features

  • Added seed:advanced script for running the complete seeding process
  • Created modular seeding architecture with separate modules for different entity types
  • Implemented realistic data generation for testing scenarios

New Modules

  • feed-main.ts: Central orchestration module for running all seeders in sequence
  • user-auth-feed.ts: Creates users, roles, and permissions with proper relationships
  • wallet-feed.ts: Generates wallet types, wallets, and balances for test users
  • transaction-feed.ts: Creates realistic transaction data, including installments and subscriptions

Model Improvements

  • Updated model interfaces to use IBaseModel for consistent inheritance
  • Added necessary relationships between entities (e.g., wallet owner)
  • Refined model properties to better reflect real usage

Usage

To seed the database with comprehensive test data:

npm run seed:advanced

…zation

Implement a new advanced seeding script that provides a complete database initialization process:
- Create `feed-main.ts` to orchestrate multiple seeding processes
- Add seeding scripts for user authentication, transactions, wallets, and other core entities
- Enhance seed generation with realistic and randomized data
- Improve logging and error handling for seed processes
- Update package.json with a new `seed:advanced` script
@AlpTalhaYazar AlpTalhaYazar added the enhancement New feature or request label Feb 27, 2025
AlpTalhaYazar and others added 5 commits February 27, 2025 19:42
Minor formatting and code style improvements in:
- Constants validation rules
- Transaction and setting controllers
- Validation schemas for transactions, wallets, and wishlists

Standardize code indentation, remove unnecessary line breaks, and enhance overall code consistency
… helpers

Improvements:
- Extract common user data constants to a centralized location
- Rename variables for clarity and consistency
- Add role-user mapping to improve seed generation
- Remove duplicate user data definitions in different feed helper files
Implement a new seeding function to generate wallet accessors:
- Create `seedWalletAccessors` function in wallet feed helper
- Randomly assign accessors to wallets
- Prevent duplicate accessor assignments
- Log accessor creation and skipped cases
- Integrate with main feed seeding process
- Update wallet seeding to handle partial user data and existing users
- Add owner field to wallet schema
- Modify seedWalletAccessors to use more robust user matching
- Ensure type safety when creating wallet accessors and wallets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants