Skip to content
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

Feature: Seeding #68

Open
itsezc opened this issue Feb 5, 2024 · 3 comments
Open

Feature: Seeding #68

itsezc opened this issue Feb 5, 2024 · 3 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@itsezc
Copy link

itsezc commented Feb 5, 2024

Is your feature request related to a problem? Please describe.

Seeding is a common feature provided by ORMs and migration tools like Eloquent and Prisma

Describe the solution you'd like

A seed file that is executed when the database is first setup.

Describe alternatives you've considered

Manually running SURQL on setup, but this can be tedious for large operations.

@itsezc itsezc changed the title Seed Feature: Seeding Feb 5, 2024
@Odonno Odonno added enhancement New feature or request question Further information is requested labels Feb 5, 2024
@Odonno
Copy link
Owner

Odonno commented Feb 5, 2024

Interesting.

This is not a feature I am particularly a fan of. But this is a feature most developers would expect. I suppose we can think how to integrate this feature into surrealdb-migrations.

I can think of two ways to run seeds:

  1. Manually, via cli command
  2. Automatically, when migration start from point 0

Additional features on this would be:

  • put seed files in a /seeds folder to keep everything in order
  • ability to enable/disable automatic seeding in config file?
  • ability to run bash scripts, or even better to run Rust scripts
  • inform when any seed file is not update (when mismatches are found with the latest version of the schema)

@itsezc
Copy link
Author

itsezc commented Feb 5, 2024

Interesting.

This is not a feature I am particularly a fan of. But this is a feature most developers would expect. I suppose we can think how to integrate this feature into surrealdb-migrations.

I can think of two ways to run seeds:

  1. Manually, via cli command
  2. Automatically, when migration start from point 0

Additional features on this would be:

  • put seed files in a /seeds folder to keep everything in order
  • ability to enable/disable automatic seeding in config file?
  • ability to run bash scripts, or even better to run Rust scripts
  • inform when any seed file is not update (when mismatches are found with the latest version of the schema)

I think both ways should be possible, with automatic seeding if the start point is 0, and these seeds should also be split based on the database branch, for instance you may have test accounts in "dev" or "staging" but not on production.

Having a /seeds folder makes sense, I think having it configurable makes sense with the default behaviour being true and having checks against the latest schema. Not too keen on the running bash scripts tho, perhaps I'm mistaken but I don't see how this might come in handy.

@Odonno
Copy link
Owner

Odonno commented Feb 6, 2024

Even if SurrealDB offers a large set of features, running a script (via bash for example) can be useful in some use cases. Like importing data from a text file or a CSV file. Or creating custom batch operations. This is especially true for seeding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants