Overview
Thegeni create command creates a new database. This is useful for setting up fresh development, staging, or production environments.
Usage
Database Support
Database creation behavior varies by database type:
- PostgreSQL: Creates a new database
- MySQL: Creates a new database
- MariaDB: Creates a new database
- SQLite: Creates the database file (also happens automatically during migrations)
- LibSQL/Turso: Database should be created through the Turso CLI or web interface
Required Environment Variables
The database connection string. The format determines which database system to use.Connection String Formats:For PostgreSQL, MySQL, and MariaDB, connect to the server without specifying a database name, or use a default database:
- PostgreSQL:
postgres://user:password@localhost:5432/postgres - MySQL:
mysql://root:password@localhost:3306/ - MariaDB:
mariadb://root:password@localhost:3307/ - SQLite:
sqlite://./database.sqlite - LibSQL:
https://localhost:6000
Optional Environment Variables
Authentication token for LibSQL/Turso databases. Required for authenticated Turso instances.
Path to the migrations folder (used for configuration, but migrations are not run during create).
Name of the migrations tracking table (created when migrations are first run).
Schema file name (used during migrations, not during database creation).
Number of seconds to wait for the database server to be ready.
How It Works
- Parse the database URL to determine the database type
- Connect to the database server
- Execute the appropriate CREATE DATABASE command
- Verify the database was created successfully
Examples
PostgreSQL
MySQL
MariaDB
SQLite
For SQLite, the database file is created automatically:SQLite databases are automatically created when you run
geni up if the file doesn’t exist. The create command is optional for SQLite.LibSQL/Turso
For LibSQL and Turso, create the database using the Turso CLI:Complete Setup Workflow
Typical workflow for setting up a new environment:Docker Usage
Development Setup
Local PostgreSQL
Local MySQL
SQLite for Development
CI/CD Integration
GitHub Actions
GitLab CI
Docker Compose
Error Handling
Database Already Exists
geni up.
Connection Failed
DATABASE_URL environment variable.
Permission Denied
Server Not Running
- Ensure the database server is running
- Check the connection string
- Verify network connectivity
- Increase
DATABASE_WAIT_TIMEOUTif server is starting up
Database Naming Conventions
Follow these conventions for database names:- Development:
myapp_devormyapp_development - Test:
myapp_test - Staging:
myapp_staging - Production:
myappormyapp_production
Best Practices
- Separate environments: Use different databases for dev, test, staging, and production
- Name consistently: Follow a naming convention across projects
- Automate creation: Include database creation in setup scripts
- Check before creating: Verify the database doesn’t exist to avoid errors
- Use in CI: Create fresh test databases in CI/CD pipelines
- Document requirements: Note any special permissions needed
- Version control: Store database creation steps in documentation
Checking if Database Exists
Before creating, you can check if a database exists:PostgreSQL
MySQL/MariaDB
SQLite
Automation Scripts
Bash Setup Script
Make Command
Next Steps
Run Migrations
Apply migrations with
geni upCreate Migrations
Create migration files with
geni newCheck Status
View migration status with
geni statusDrop Database
Remove database with
geni drop