NuxtHub provides a CLI for managing your database migrations and running SQL queries accessible from the npx nuxt db command.
nuxt db generateGenerate database migrations from the schema.
USAGE db generate [OPTIONS]
OPTIONS
--cwd The directory to run the command in.
-v, --verbose Show verbose output.
nuxt db migrateApply database migrations to the database.
USAGE db migrate [OPTIONS]
OPTIONS
--cwd The directory to run the command in.
--dotenv Point to another .env file to load.
-v, --verbose Show verbose output.
nuxt db mark-as-migratedMark local database migration(s) as applied to the database.
USAGE db mark-as-migrated [OPTIONS] [NAME]
ARGUMENTS
NAME The name of the migration to mark as applied.
OPTIONS
--cwd The directory to run the command in.
--dotenv Point to another .env file to load.
-v, --verbose Show verbose output.
nuxt db dropDrop a table from the database.
USAGE db drop [OPTIONS] <TABLE>
ARGUMENTS
TABLE The name of the table to drop.
OPTIONS
--cwd The directory to run the command in.
--dotenv Point to another .env file to load.
-v, --verbose Show verbose output.
nuxt db drop-allDrop all tables from the database.
USAGE db drop-all [OPTIONS]
OPTIONS
--cwd The directory to run the command in.
--dotenv Point to another .env file to load, relative to the root directory.
-v, --verbose Show verbose output.
nuxt db squashSquash several migrations into a single migration. This is useful for cleaning up your migration history during development.
USAGE db squash [OPTIONS]
OPTIONS
--last Number of migrations to squash starting from most recently applied. If not specified migrations can be interactively selected.
--cwd The directory to run the command in.
-v, --verbose Show verbose output.
Example usage:
# Squash the last 3 migrations into one
npx nuxt db squash --last 3
# Interactive mode - select which migrations to squash
npx nuxt db squash
After squashing, you'll be prompted to mark the new migration as already applied. This is useful when your database already has the schema from the squashed migrations applied.
nuxt db sqlExecute a SQL query against the database.
USAGE db sql [OPTIONS] [QUERY]
ARGUMENTS
QUERY The SQL query to execute. If not provided, reads from stdin.
OPTIONS
--cwd The directory to run the command in.
--dotenv Point to another .env file to load, relative to the root directory.
-v, --verbose Show verbose output.
Example usage:
npx nuxt db sql "SELECT * FROM users"
# or
npx nuxt db sql < dump.sql
Migrations
Manage database schema changes in Nuxt with Drizzle ORM migrations, including creating, applying, and tracking migration files safely.
Setup
Setup Blob Storage in your Nuxt application to store assets like images, videos, documents. Compatible with AWS S3, Cloudflare R2, Vercel Blob and more.