Additional commands for AdonisJS 6 Lucid ORM to help with database management and exploration.
This package provides additional Ace commands for AdonisJS applications to manage and explore databases:
db:create- Create a new databasedb:drop- Drop an existing database (with production safety)db:query- Execute a raw SQL query on the database
list:databases- List all configured database connectionslist:tables- List all tables in a specific database
npm install @jrmc/adonis-lucid-commandsAfter installation, configure the package in your AdonisJS application:
node ace configure @jrmc/adonis-lucid-commandsThis will automatically register the commands in your adonisrc.ts file.
# Create database using default connection
node ace db:create
# Create database using specific connection
node ace db:create --name=mysql# Drop database using default connection
node ace db:drop
# Drop database using specific connection
node ace db:drop --name=mysqldb:drop command is disabled in production environments to prevent accidental data loss.
# Execute a SQL query
node ace db:query 'SELECT * FROM users'
# Execute a query on a specific connection
node ace db:query 'SELECT * FROM users' --name=mysqlThe command supports multiple output formats:
Table format (default) - Results displayed in a formatted table with truncated long values:
node ace db:query 'SELECT * FROM users'JSON format - Results displayed as formatted JSON (ideal for complex data or piping):
node ace db:query 'SELECT * FROM users' --jsonVertical format - Each row displayed as a block with one column per line (like MySQL \G):
node ace db:query 'SELECT * FROM users' --verticalnode ace list:databasesThis command displays all configured database connections with their client type and database name.
# List tables in default connection
node ace list:tables
# List tables in specific connection
node ace list:tables --name=mysqlThis command shows all tables in the specified database connection. It supports multiple database clients:
- PostgreSQL - Uses
information_schema.tables - MySQL - Uses
information_schema.tables - SQLite - Uses
sqlite_master - MSSQL - Uses
sys.tables
The package supports the following database clients:
- PostgreSQL (
pg,postgres,postgresql) - MySQL (
mysql,mysql2) - SQLite (
sqlite,sqlite3,better-sqlite3) - Microsoft SQL Server (
mssql)
- AdonisJS Core:
^6.12.1 - AdonisJS Lucid:
^20.6.0 || ^21.0.0
MIT License - see LICENSE file for details.
Jeremy Chaufourier - jeremy@chaufourier.fr