docs/commands/database.md
databaseProvision a production ready Postgres database with a single command
Usage
netlify database
Flags
filter (string) - For monorepos, specify the name of the application to run the command indebug (boolean) - Print debugging informationauth (string) - Netlify auth token - can be used to run this command without logging in| Subcommand | description |
|---|---|
database status | Check the status of the database, including applied and pending migrations |
database init | Interactive setup: install the package, scaffold a starter migration, and verify the database |
database connect | Connect to the database |
database reset | Reset the local development database, removing all data and tables |
database migrations | Manage database migrations |
Examples
netlify database status
netlify database migrations apply
netlify database migrations pull
netlify database migrations new
netlify database reset
database statusCheck the status of the database, including applied and pending migrations
Usage
netlify database status
Flags
branch (string) - Netlify branch name to query; defaults to the local development databasejson (boolean) - Output result as JSONshow-credentials (boolean) - Include the full connection string (including username and password) in the outputdebug (boolean) - Print debugging informationauth (string) - Netlify auth token - can be used to run this command without logging inExamples
netlify database status
netlify database status --show-credentials
netlify database status --json
netlify database status --branch my-feature-branch
database initInteractive setup: install the package, scaffold a starter migration, and verify the database
Usage
netlify database init
Flags
filter (string) - For monorepos, specify the name of the application to run the command inyes (boolean) - Non-interactive mode. Accepts the defaults for every prompt.debug (boolean) - Print debugging informationauth (string) - Netlify auth token - can be used to run this command without logging inExamples
netlify database init
netlify database init --yes
database connectConnect to the database
Usage
netlify database connect
Flags
filter (string) - For monorepos, specify the name of the application to run the command injson (boolean) - Output query results as JSON. When used without --query, prints the connection details as JSON instead.query (string) - Execute a single query and exitdebug (boolean) - Print debugging informationauth (string) - Netlify auth token - can be used to run this command without logging inExamples
netlify database connect
netlify database connect --query "SELECT * FROM users"
netlify database connect --json --query "SELECT * FROM users"
netlify database connect --json
database resetReset the local development database, removing all data and tables
Usage
netlify database reset
Flags
filter (string) - For monorepos, specify the name of the application to run the command injson (boolean) - Output result as JSONdebug (boolean) - Print debugging informationauth (string) - Netlify auth token - can be used to run this command without logging indatabase migrationsManage database migrations
Usage
netlify database migrations
Flags
filter (string) - For monorepos, specify the name of the application to run the command indebug (boolean) - Print debugging informationauth (string) - Netlify auth token - can be used to run this command without logging in| Subcommand | description |
|---|---|
database migrations apply | Apply database migrations to the local development database |
database migrations new | Create a new migration |
database migrations pull | Pull migrations and overwrite local migration files |
database migrations reset | Delete local migration files that have not been applied yet |
database migrations applyApply database migrations to the local development database
Usage
netlify database migrations apply
Flags
filter (string) - For monorepos, specify the name of the application to run the command injson (boolean) - Output result as JSONto (string) - Target migration name or prefix to apply up to (applies all if omitted)debug (boolean) - Print debugging informationauth (string) - Netlify auth token - can be used to run this command without logging indatabase migrations newCreate a new migration
Usage
netlify database migrations new
Flags
description (string) - Purpose of the migration (used to generate the file name)filter (string) - For monorepos, specify the name of the application to run the command injson (boolean) - Output result as JSONscheme (timestamp | sequential) - Numbering scheme for migration prefixesdebug (boolean) - Print debugging informationauth (string) - Netlify auth token - can be used to run this command without logging inExamples
netlify database migrations new
netlify database migrations new --description "add users table" --scheme sequential
database migrations pullPull migrations and overwrite local migration files
Usage
netlify database migrations pull
Flags
branch (string) - Pull migrations for a specific branch (defaults to 'production'; pass --branch with no value to use local git branch)filter (string) - For monorepos, specify the name of the application to run the command inforce (boolean) - Skip confirmation promptdebug (boolean) - Print debugging informationauth (string) - Netlify auth token - can be used to run this command without logging injson (boolean) - Output result as JSONExamples
netlify database migrations pull
netlify database migrations pull --branch staging
netlify database migrations pull --branch
netlify database migrations pull --force
database migrations resetDelete local migration files that have not been applied yet
Usage
netlify database migrations reset
Flags
branch (string) - Target a remote preview branch instead of the local development databasefilter (string) - For monorepos, specify the name of the application to run the command injson (boolean) - Output result as JSONdebug (boolean) - Print debugging informationauth (string) - Netlify auth token - can be used to run this command without logging inExamples
netlify database migrations reset
netlify database migrations reset --branch my-feature-branch