Moped Documentation
  • Welcome 👋
  • User Guides
    • Getting started
    • Map a project
  • Product Management
    • User communication
    • User management
    • User analytics
    • Local testing
    • Release process
    • Patch release process
    • MUI X Pro License
    • Integrations
      • Dataset documentation
      • ArcGIS Online
      • eCapris
      • Power BI
    • Features
  • Dev Guides
    • DB Docs & Data dictionary
    • Database backup policy
    • Moped Read Replica
    • How-to's
      • How do I start the Hasura cluster locally?
      • How do I launch the Hasura Console?
      • How do I get a JWT token?
      • How to ping the GraphQL API
      • How to ping the REST API
      • How do I connect a database with Postgres GUIs?
      • How do I connect to the RDS instance?
      • How to load production data into a local instance
      • How do I update seed data?
    • Hasura
      • Hasura Roles
      • Hasura Migrations
        • Getting Started
        • Installing the Hasura CLI
        • Configuration Files
        • Hasura Migration Principles
        • The Migration file format
        • Development
        • Hasura Seed Data
        • Running the Hasura Cluster Locally (video)
        • Create a migration: Exercise 1 (video)
        • Create a migration: Exercise 2 (video)
        • Latest hasura-cluster features
    • User Management
    • Authentication
      • Authentication Architecture
      • DynamoDB & Cognito
      • Secrets Manager & Cognito
      • Hasura & Cognito
      • React & Cognito
      • Flask API & Cognito
      • Single Sign-On with CTM
    • Code organization
    • API
      • Configuration Files
      • Testing
      • User Management API
    • Maps and geospatial data
      • Access tokens and API keys
      • Map libraries
      • Map data
      • Map styles
      • Map layers and basemaps
      • React patterns
      • V1 Archive
        • Map libraries
        • Map data
        • Map custom hooks
        • Map styles
        • Map layers and basemaps
    • UI access control
    • Design system
      • Branding
      • Component styles
      • Text content
    • Activity Log
      • Architecture
      • GitHub Actions and Deployment of Updates
      • Hasura Event Logs and Truncate Cron Job
      • Authentication
  • See also
  • Get Moped support, report a bug, or request an enhancement
  • Data & Technology Services
  • Github repository
Powered by GitBook
On this page
  • Hasura "Seeds" file
  • Synopsis
  • Examples
  • Apply the Seed data
  • Synopsis
  • Examples

Was this helpful?

  1. Dev Guides
  2. Hasura
  3. Hasura Migrations

Hasura Seed Data

PreviousDevelopmentNextRunning the Hasura Cluster Locally (video)

Last updated 4 years ago

Was this helpful?

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.

For more specific information about seed data files, please visit their documentation:

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
https://hasura.io/docs/1.0/graphql/core/hasura-cli/hasura_seeds_create.html#hasura-seeds-create