Hasura Seed Data
Hasura "Seeds" file
Hasura comes with a seeding mechanism, it basically runs SQL files against your Hasura server. There is some seed data available in the repository; however, you might find yourself needing to create new seed data for an existing table or a new table.
Hasura lets you:
Create a new table seed with a SQL file.
Create a new seed by exporting data already present in the database (copy from another table)
Create a new seed from multiple existing tables.
Synopsis
Create a new seed file
hasura seeds create seed_name [flags]
Examples
# Create a new seed file and use editor to add SQL:
hasura seed create new_table_seed
# Create a new seed by exporting data from tables already present in the database:
hasura seed create table1_seed --from-table table1
# Export data from multiple tables:
hasura seed create tables_seed --from-table table1 --from-table table2
Apply the Seed data
Once you have your seed files created, it is time to apply them (run them against your database). To do this we use the apply command:
Synopsis
Apply seed data
hasura seeds apply [flags]
Examples
# Apply all seeds on the database:
hasura seed apply
# Apply only a particular file:
hasura seed apply --file seeds/1234_add_some_seed_data.sql
Last updated
Was this helpful?