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 Request: Add support to Seed Data to the Database #4

Open
brunosmm opened this issue Feb 14, 2021 · 3 comments
Open

Feature Request: Add support to Seed Data to the Database #4

brunosmm opened this issue Feb 14, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@brunosmm
Copy link
Contributor

Problem

I know the focus of the lib is to support migration schemas, and does NOT intended to support any kind of data migration.
But today once my database is created for the first time I seed some data, which was part of my migration scripts once using faunadb-migrate lib.

Request:

Support Seed Data to be part of the migration scripts, in this case is not possible to auto-generated a down script automatically so my propose is to support seed data scripts where the up and down scripts should be typed by the developer.

Current Workaround:

Based on Fwitter I create a populate scripts this can support my data seed, this force me to keep out of my CI/CD pipeline for simplicity and the developers execute it manually if the database was created by the first time.

Here the scripts if someone would like to use:

  1. Create a js script to populate your database:
  1. Add a new folder seed to hold the scripts:
    image
  2. Create the scripts using the model from faunadb-migrate with up and down:
  1. Add to the npm package a new script:
    image
  2. Execute using npm or yarn:
    yarn populate FAUNA_ADMIN_KEY
@fauna-brecht fauna-brecht added the enhancement New feature or request label Feb 15, 2021
@brunosmm
Copy link
Contributor Author

@fauna-brecht, If I add an FQL script in a migrations folder to run together with some create/update scripts to populate data in some docs, would that run? Or the tool only execute FQL with UPDATE/CREATE and so on?

@fauna-brecht
Copy link
Contributor

It would not work, we would need a different approach for data. I still think seed data doesn't really fit the migrations problem.
Should the seed data run every time or only on a specific migration? Should it be 'unseeded' if you roll back?
So I'm guessing you are rather looking for data migrations and not necessarily seed data? Is that correct?

@brunosmm
Copy link
Contributor Author

Indeed this is more like a data migration than seed but should be linked with some DB migration and coupled with specifics UDF/Index.
What I am missing is more about the data structure, like we decide to add a new object structure in some collection from now on, but means the docs that were created before does not have it and if I execute my index search would not work since some objects have this and others not, here a good example https://fauna-community.slack.com/archives/CM29P7A81/p1622078419077100.
So what I would like is, once I create this new Index/UDF who use some new data from the docs be able to execute a script together to add a default value to the other docs but this would need to be executed together with the migration and only once.
The rollback is a good point since is not a SQL DB and the data does not need to follow a specific structure would not need to Update the object to remove it, but ideally would be the best scenario to not keep unnecessary data. In this case, rollback cannot be created automatically and would need to be defined by the user.

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

No branches or pull requests

2 participants