Skip to main content

Module schema_editor

Module schema_editor 

Source
Expand description

DDL generation for PostgreSQL, SQLite and MySQL.

PostgreSQL and SQLite identifiers are double-quoted (embedded " doubled). SQLite AlterField / RemoveField / constraint changes rebuild the table (create new, copy, drop, rename); the migrator disables foreign keys on the connection before BEGIN. MySQL has its own dialect (backticks, AUTO_INCREMENT, MODIFY COLUMN, no transactional DDL); see the mysql module. Other backends return MigrationError::UnsupportedBackend before any I/O.

Modules§

mysql
MySQL / MariaDB DDL (MySQL 8.0.31+).

Structs§

SqliteCastCheck
One SQLite CAST that needs a pre-copy loss check: sql returns a row when some non-NULL value in table.column would change under the cast.
SqliteRebuildTarget
SQLite rebuild target for op: the table being dropped plus the column sets before/after and the index names the rebuild itself recreates.

Functions§

quote_ident
Quote ident with double quotes; embed a quote by doubling it.
quote_identifier
Quote ident for the SQL dialect of kind: backticks for MySQL, double quotes for everything else.
quote_string
Quote a SQL string literal with single quotes.
render
Render a single operation against the current schema state (before the op).
sqlite_lossy_cast_checks
Columns of op whose SQLite rebuild CAST could lose data.
sqlite_rebuild_target
Which table op rebuilds on SQLite, if any.
sqlite_sql_mentions_ident
Whether sql references identifier ident (a column or table name).
statements
Render operations against state, applying each to a cloned state so later ops see earlier ones (needed for SQLite rebuilds).