Skip to main content

Crate yauth_migration

Crate yauth_migration 

Source
Expand description

Declarative schema system and migration file generator for yauth.

This crate has zero ORM dependencies — it is a pure code generator. It provides:

  • Schema types (TableDef, ColumnDef, ColumnType, etc.)
  • Core + plugin schema definitions
  • Schema collector with topological sort by FK dependencies
  • Dialect-specific DDL generators (Postgres, SQLite, MySQL)
  • Schema diff engine for incremental migrations
  • Migration file generators (diesel up.sql/down.sql, sqlx numbered .sql)
  • yauth.toml config file support
  • Schema hash for tracking

Modules§

config
yauth.toml configuration file support.
diff
Schema diff engine.
generate
Migration file generators for diesel and sqlx.
plugin_schemas
Schema definitions for each built-in plugin.
sqlx_queries
sqlx query file generator.

Structs§

ColumnDef
Definition of a single column.
ForeignKey
Foreign key reference from a column to another table’s column.
IndexDef
Index definition for a table.
TableDef
Definition of a single table.
YAuthSchema
Merged schema: all tables topologically sorted by FK dependencies.

Enums§

ColumnType
Abstract column type – each dialect maps this to a concrete SQL type.
Dialect
Supported SQL dialects for DDL generation.
OnDelete
ON DELETE action for foreign keys.
Orm
Supported ORM formats for migration file generation.
SchemaError
Error during schema collection.

Constants§

ALL_PLUGINS
All known plugin names.

Functions§

collect_schema
Collect and merge core + plugin schemas, then topologically sort by FK deps.
collect_schema_for_plugins
Collect a schema from a list of plugin names plus core tables.
core_schema
Returns the core yauth tables.
generate_ddl
Generate DDL for a schema in the given dialect.
generate_diesel_schema
Generate diesel table! macro definitions as Rust source text.
generate_mysql_ddl
Generate complete MySQL DDL for the entire schema.
generate_mysql_drop
Generate DROP TABLE IF EXISTS statement for a single table (MySQL).
generate_mysql_drops
Generate DROP TABLE statements for a list of tables in reverse order (MySQL).
generate_postgres_ddl
Generate complete Postgres DDL for the entire schema.
generate_postgres_drop
Generate a DROP TABLE IF EXISTS statement for a single table.
generate_postgres_drops
Generate DROP TABLE statements for a list of tables in reverse order.
generate_seaorm_entities
Generate SeaORM entity files for all tables in the schema.
generate_sqlite_ddl
Generate complete SQLite DDL for the entire schema.
generate_sqlite_drop
Generate DROP TABLE IF EXISTS statement for a single table (SQLite).
generate_sqlite_drops
Generate DROP TABLE statements for a list of tables in reverse order (SQLite).
generate_toasty_models
Generate Toasty model files for all tables in the schema.
is_known_plugin
Check if a plugin name is valid (even if it has no database tables). Plugins like admin, status, telemetry, and openapi are code-only.
plugin_schema_by_name
Get the schema tables for a plugin by name.
schema_hash
Compute a deterministic hash of the schema for tracking purposes.