wheels db setup
Setup a complete database by creating it, running migrations, and seeding data.
Synopsis
wheels db setup [--datasource=<name>] [--environment=<env>] [--skip-seed] [--seed-count=<n>]
Description
The wheels db setup
command performs a complete database initialization in one command. It executes three operations in sequence:
Creates the database (
wheels db create
)Runs all migrations (
wheels dbmigrate latest
)Seeds the database with sample data (
wheels db seed
)
This is ideal for setting up a new development environment or initializing a test database.
Options
--datasource=
Specify which datasource to use. If not provided, uses the default datasource from your Wheels configuration.
wheels db setup --datasource=myapp_dev
--environment=
Specify the environment to use. Defaults to the current environment.
wheels db setup --environment=testing
--skip-seed
Skip the database seeding step.
wheels db setup --skip-seed
--seed-count=
Number of records to generate per model when seeding. Defaults to 5.
wheels db setup --seed-count=20
Examples
Basic Usage
Full setup with default options:
wheels db setup
Setup Without Sample Data
Create and migrate only:
wheels db setup --skip-seed
Setup Test Database
wheels db setup --datasource=myapp_test --environment=testing --seed-count=10
Production Setup
wheels db setup --environment=production --skip-seed
What It Does
The command executes these steps in order:
Create Database
Creates new database if it doesn't exist
Uses datasource configuration for connection details
Run Migrations
Executes all pending migrations
Creates schema from migration files
Seed Database (unless --skip-seed)
Generates sample data for testing
Creates specified number of records per model
Error Handling
If any step fails:
The command stops execution
Shows which step failed
Provides instructions for manual recovery
Common Use Cases
New Developer Setup
git clone https://github.com/myproject/repo.git
cd repo
box install
wheels db setup
server start
Reset Development Database
wheels db drop --force
wheels db setup --seed-count=50
Continuous Integration
# In CI script
wheels db setup --environment=testing --skip-seed
wheels test run
Best Practices
Use for development: Perfect for getting started quickly
Skip seeding in production: Use
--skip-seed
for productionCustomize seed count: More data for performance testing
Check migrations first: Ensure migrations are up to date
Related Commands
wheels db create
- Just create databasewheels db reset
- Drop and recreate everythingwheels dbmigrate latest
- Just run migrationswheels db seed
- Just seed data
Last updated
Was this helpful?