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 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