TideORM CLI
A comprehensive command-line interface for TideORM - A powerful Rust ORM.
Installation
Install globally:
Quick Start
# Initialize a new TideORM project
# Generate a model with fields, relations, and more
# Run migrations (`tideorm migrate` on its own does the same thing)
# Seed the database
Configuration
TideORM CLI uses a tideorm.toml configuration file:
[]
= "my-tideorm-project"
= "development"
[]
= "postgres"
= "localhost"
= 5432
= "myapp"
= "postgres"
= "password"
# Or use a connection URL:
# url = "postgres://postgres:password@localhost/myapp"
[]
= "src/models"
= "src/migrations"
= "src/seeders"
= "src/factories"
= "src/config.rs"
[]
= "_migrations"
= true
[]
= "DatabaseSeeder"
[]
= true
= false
= false
= "id"
= "i64"
Commands
Migration Commands
# Run all pending migrations
# Run migrations with options
# Generate a new migration
# Migration up/down
# Redo migrations
# Fresh migrations (drop all tables and re-run)
# Without --force this asks for confirmation and fails if it cannot prompt.
# Reset migrations (rollback all)
# Refresh migrations (reset + migrate)
# Reconcile the migration ledger without running any SQL
# MySQL and MariaDB commit DDL implicitly, so a migration whose schema change
# succeeded but whose ledger row was never written leaves later runs stuck on
# "table already exists". These repair the ledger by hand.
# View migration status
Rollback order follows the order migrations were applied, not their version strings, so a migration merged in from a long-lived branch is rolled back in the order it actually ran.
Model Generation
The make model command is the most powerful generator, supporting:
# Basic model
# Model with fields
# Field types:
# string, text, i32, i64, f32, f64, bool, datetime, date, time,
# uuid, json, jsonb, decimal, bytes,
# int_array, bigint_array, text_array, bool_array, float_array, json_array
# (SQL spellings are accepted as aliases: varchar, tinyint, smallint, int, integer,
# bigint, float, double, boolean, timestamp, blob, binary, integer_array,
# string_array, boolean_array)
# Field modifiers: nullable, unique, indexed, primary_key, auto_increment, default=value
# Model with relations
# Model with translatable fields
# Model with attachments
# Model with indexes
# Model with nullable fields
# Enable special features
# Generate with migration, seeder and factory
# Write the model somewhere other than the configured [paths] models directory.
# A companion --seeder/--factory generated in the same run imports the model from
# wherever --output put it.
# Full example
Other Generators
# Generate a migration
# Generate a seeder (--count sets how many records the generated seeder creates)
# Generate a factory
# Every `make` generator accepts --output to choose the target directory
--output defaults to the same value as the matching [paths] entry
(src/migrations, src/seeders, src/factories, src/models). Left alone, the
configured [paths] directory wins; passing anything else overrides it for that run
only. The generated file and the mod.rs next to it both go to the chosen directory,
so remember to declare that directory as a module in your crate.
Moving a seeder or a factory does not move the model it imports: the generated
use crate::.. path is still derived from [paths] models.
Database Commands
# Run all seeders
# Drop all tables, re-run migrations and re-seed
# Show database connection status
# Initialize TideORM metadata tables
# Create the database
# Drop the database
# Wipe all tables - this DROPS every table, schema included; it is not a TRUNCATE.
# `migrate fresh` relies on those drop semantics to rebuild from the migrations.
# Show table information
Destructive commands (db drop, db wipe, db fresh, migrate fresh) prompt for
confirmation unless --force is given. A run that cannot prompt - no terminal, or
CI / TIDEORM_NONINTERACTIVE set - fails with a non-zero exit rather than
reporting a cancellation as success, so pass --force in scripts and CI.
Utility Commands
# Initialize a new project
# Show configuration
# List all models
# Show schema information
Global Options
All commands support these global options:
)
The generator commands (tideorm make ..., tideorm migrate generate, tideorm models)
run without a tideorm.toml and fall back to the built-in defaults. A tideorm.toml that
exists but cannot be read or parsed is always reported as an error instead - otherwise a
typo in the config would silently generate Postgres code into src/ for a project
configured for another backend.
Generated File Examples
Generated Model
//! User Model
//!
//! Auto-generated by TideORM CLI
use *;
use Post;
use Company;
Generated Migration
//! Migration: create_users_table
use *;
;
Generated Seeder
//! UserSeeder
use *;
use crateUser;
;
Environment Variables
The CLI supports environment variable expansion in tideorm.toml:
[]
= "${DATABASE_PASSWORD}"
Create a .env file:
DATABASE_PASSWORD=secret
License
MIT License - See LICENSE file for details.