Skip to content

Move Seed Logic to a Separate Script Using JSON Files #153

@avirajsingh7

Description

@avirajsingh7

Currently, seed data (e.g., organizations, users, API keys) is being inserted via an Alembic migration. This issue aims to cleanly separate the concerns by:

  • Removing the existing seed logic from the Alembic migration file. here
  • Creating a new standalone script (scripts/seed_data.py) that reads from JSON files and seeds data into the database.
  • Modify prestart.sh to use this script, such that running this will prepare DB for development.

Why:

  • Alembic migrations should focus on schema changes, not dynamic data.
  • Seeding via script allows flexibility.
  • JSON files make seed data readable, editable. IF we need some more data we can simply modify this json file.
  • In a future API key or any other model update, if we require a new value, for example a user's email address, alongside the api_key, we'll need to modify the API key generation logic. However, if the database migration order doesn't account for this new requirement, and the api_key table lacks a corresponding 'email' column, the API's functionality will break. Specifically, when the updated API logic attempts to read or write the email address, it will encounter a missing column error, leading to application failure. here

Seprate script will resolve this issues.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions