Skip to main content

apply_type

Function apply_type 

Source
pub fn apply_type(def: &mut ColumnDef, ty: ColumnType, keyed: bool)
Expand description

Apply the column’s SQL type to a sea-query ColumnDef. sea-query maps each of these to the per-dialect concrete type when rendered (e.g. BigUnsigned → BIGINT UNSIGNED on MySQL, INTEGER on SQLite).

keyed is whether the column participates in an index/constraint: a Text column that does is rendered as VARCHAR(255) instead of TEXT, because MySQL rejects indexing a BLOB/TEXT column without a prefix length. On SQLite/D1 a VARCHAR(255) is just TEXT affinity, so nothing is lost there.

pub(crate) so the incremental DDL builder (crate::ddl) renders an added column’s type identically to how CREATE TABLE rendered it.