0
0
Supabasecloud~5 mins

Seed data management in Supabase

Choose your learning style9 modes available
Introduction

Seed data management helps you add initial data to your database automatically. This makes your app ready to use right after setup.

When you want to add default users or roles to your app database.
When you need sample data for testing your app features.
When setting up a new environment and want consistent starting data.
When sharing your project with others who need the same initial data.
When resetting your database to a known state during development.
Syntax
Supabase
supabase db seed run
This command runs seed scripts that add data to your database.
The seed script is an SQL file named `seed.sql` placed in the `supabase/seed/` folder.
Examples
Runs all seed scripts to populate the database with initial data.
Supabase
supabase db seed run
Runs seed scripts targeting the public schema in the database.
Supabase
supabase db seed run --schema=public
Sample Program

This SQL seed file adds two users to the users table. Running supabase db seed run will insert these rows into your database.

Supabase
-- File: supabase/seed/seed.sql
INSERT INTO users (id, name, email) VALUES
  (1, 'Alice', 'alice@example.com'),
  (2, 'Bob', 'bob@example.com');
OutputSuccess
Important Notes

Always back up your database before running seed scripts in production.

Seed scripts should be idempotent or carefully managed to avoid duplicate data.

Use seed data to speed up development and testing with consistent data sets.

Summary

Seed data management adds initial data to your database automatically.

Use supabase db seed run to execute seed scripts.

Seed data helps with testing, development, and consistent setups.