Database — Aquilia Documentation
Comprehensive guide and documentation for Database in the Aquilia framework. View API reference, examples, and implementation patterns.
CLI / Database Database Commands The aq db command group manages migrations, introspects tables, dumps schemas, and runs database shells. aq db makemigrations Analyzes your model classes in modules and diffs them against migration history to generate a new migration file. Diffs are compiled using the Aquilia DSL. # Generate migrations for all modules aq db makemigrations # Generate migrations only for the users module aq db makemigrations --app=users # Fall back to legacy SQL migrations instead of DSL aq db makemigrations --no-dsl Options Option Description ))} aq db migrate Executes pending migration files, applying changes to database schemas safely. # Apply all pending migrations aq db migrate # View execution plan without altering schemas aq db migrate --plan # Target a specific migration version (rolls back if version is in the past) aq db migrate --target=0004_add_profile_indexing Options Option Description ))} aq db showmigrations Displays all detected migration files, listing them sequentially with a checked or unchecked status indicator (e.g. [X] or [ ]) depending on whether they have been applied. aq db showmigrations aq db sqlmigrate Prints the raw SQL DDL queries compiled for a specific migration target name. Extremely helpful for review processes or manual SQL schemas approval. # Print SQL statements for migration 0002 aq db sqlmigrate 0002_create_user_table aq db dump Dumps model schemas into structured formats. # Dump DDL schema output as SQL aq db dump --emit=sql --output-dir=deploy/schema/ aq db inspectdb Introspects an existing database and prints auto-generated Python model code representing the tables. Helps with migrating legacy databases. # Introspect legacy database tables aq db inspectdb --database-url="postgresql://user:pass@localhost/legacy" aq db shell Launches an interactive, async Python REPL with the database connection and module model classes pre-loaded, facilitating quick queries. aq db shell aq db status Displays statistics on database connection states, including tables, columns, indexes, and row counts. aq db status )
Go to Homepage