Seeds
Learn about using seeds to populate your local database
When developing locally, it is very useful to work with a known set of data as it can simplify testing and development, especially when working in larger teams with multiple developers.
With the CLI, it is easy to extract data from an existing environment and generate a “seed” that can be shared and used to pre-populate any development environment as it initializes.
As mentioned before, you can create a seed from any environment. In this guide, we will assume that we have already started a local development with a table called “animals”. At this point, we can add some data ourselves as usual. Once we are satisfied and have the data we want, we can run the following command to create a seed:
some-initial-data
while specifying the connection parameters for our local environment. You could also extract data from a cloud project by specifying the correct parameters. Finally, we are only extracting data from the animals
table, but you could also extract data from any other table or even from all tables.We can now inspect the file and see its contents:
Now, when you start a new development environment you can pass the --apply-seeds
argument to pre-populate your environment with the seeds:
Or you could also apply the seeds yourself after starting nhost: