Seed
Seed your Better-Auth database with deterministic, yet realistic, fake data to populate your database.
Our seeding tool allows you to generate realistic sample data, such as users, for your Better Auth database. Inspired by Drizzle Seed.
Usage
Adding Users
Handles the creation of user
, session
, and account
tables.
You can modify or append new fields to the user
, session
, or account
tables, as well as add custom types.
Additional Options
Adding Organizations
Handles the creation of the organization
, member
, invitation
(if enabled), and team
(if enabled) tables.
You can modify or append new fields to the organizations
, members
, invitations
, and teams
tables, as well as add custom types.
Additional Options
Adding API keys
Handles the creation of API keys on the apikey
table.
You can modify or append new fields to the apikey
table, as well as add custom types.
Additional Options
Multiple Seed Files
You can execute multiple seed files by creating a seed
folder next to your auth.ts
file.
Within the seed
folder, you can create any number of files, with any name you want, and they will be executed in alphabetical order.
By default, the CLI will prompt you to select which seed files to execute. However, you can pass the --run-all
flag to execute all seed files.
$ Functions
We have a number of functions that you can use to generate random data.
Custom
This is a special function that allows you to hard code a value, and isn't used to generate random data.
Foreign Key
Generates a foreign key.
Emails
Generates a random email address.
First Names
Generates a random first name.
Last Names
Generates a random last name.
Full Name
Generates a random full name.
UUID
Generates a random UUID.
Random Boolean
Generates a random boolean.
Random Date
Generates a random date.
Random Characters
Generates a random string of characters.
Random Numbers
Generates a random number between 0 and 100. (configurable)
Random Choice
Generates a random choice from an array of values.
Password
Generates a random password.
Random Image URL
Generates a random image URL.
Company Name Suffixes
Generates a random company name suffix.
Countries
Generates a random country.
Job Titles
Generates a random job title.
Lorem Ipsum Sentence
Generates a random lorem ipsum sentence.
Phone Numbers
Generates a random phone number.
States
Generates a random state.
Street Suffixes
Generates a random street suffix.
Cities
Generates a random city.
IP Address
Generates a random IP address.
User Agent
Generates a random user agent.
Null Value
Generates a null value.
Configuration
You can export a config
object to configure the seeding process.
deleteRowsBeforeSeeding
Delete all rows in the tables before seeding.
Default is false
.
The table rows will be deleted in the order of the models
array.
rows
The default number of rows to seed.
Default is 100
.
If a given table has a count
option, that will take precedence over this.
Credit
This project was heavily inspired by Drizzle Seed, and the datasets used in this project are from Drizzle Seed as well. Big thanks to the Drizzle team for the awesome work! 💖