Connection URL Format
MariaDB connections use the following URL format:Use the
mariadb:// scheme specifically for MariaDB. While MariaDB is MySQL-compatible, Geni requires the correct URL scheme.URL Components
- user - MariaDB username
- password - User password (optional)
- host - Database server hostname or IP address
- port - Database port (default: 3306)
- database - Database name
Setup
Configuration Examples
- Local Development
- Production
- Docker Compose
Features
Transaction Support
MariaDB migrations run in transactions by default. To disable transactions for a specific migration:Schema Dumping
Geni automatically dumps your MariaDB schema after each successful migration. The schema dump includes:- Tables - Table definitions with columns, data types, and defaults
- Views - View definitions
- Constraints - Primary keys, foreign keys, and unique constraints
- Indexes - Index definitions
- Comments - Table and column comments
INFORMATION_SCHEMA (source: maria.rs:208-434).
MariaDB uses the same schema dumping implementation as MySQL, querying the information schema directly without external tools.
Wait Timeout
Geni can wait for MariaDB to be ready before running migrations:maria.rs:34-54).
Parameterized Queries
MariaDB uses? placeholders for prepared statements (MySQL-compatible):
Database Operations
Create Database
CREATE DATABASE IF NOT EXISTS {database_name}
Drop Database
DROP DATABASE IF EXISTS {database_name}
Check Status
schema_migrations table.
Limitations
None. MariaDB is fully supported with all Geni features.Examples
Basic Migration
Create a table in20240115120000_create_users.up.sql:
20240115120000_create_users.down.sql:
MariaDB-Specific Features
Using MariaDB features:Troubleshooting
Connection Issues
If you see connection errors, verify:- MariaDB is running and accessible
- Hostname and port are correct (default: 3306)
- User credentials are valid
- Database exists (or use
geni create) - User has appropriate permissions
Localhost Resolution
Geni automatically convertslocalhost to 127.0.0.1 in MariaDB URLs (source: maria.rs:56-59). If you need to use a Unix socket instead, use the full path:
Migration Table
Geni creates aschema_migrations table to track applied migrations:
MariaDB vs MySQL
While MariaDB is MySQL-compatible, there are some differences:Similarities
- Both use
?for parameterized queries - Both support the same migration table structure
- Schema dumping works identically using
INFORMATION_SCHEMA - Both include
IF NOT EXISTS/IF EXISTSin database operations
URL Scheme Requirement
mariadb:// scheme for MariaDB databases, even though they are MySQL-compatible (source: mod.rs:148-159).
Best Practices
- Use
mariadb://URL scheme for clarity and correctness - Set appropriate
DATABASE_WAIT_TIMEOUTfor containerized environments - Use transactions by default (opt-out with
-- transaction:nowhen needed) - Test migrations with rollbacks in development
- Keep the schema file in version control for team collaboration