SchemaUtils class

Schema utilities for adding constraints and modifiers to columns

This class provides a fluent interface for adding various constraints and modifiers to database columns during schema definition.

Example usage:

final schema = Schema()
  ..text('email').notNull().unique()
  ..integer('age').defaultValue(18).check('age >= 0')
  ..decimal('price').notNull().defaultValue(0.0);

Constructors

SchemaUtils.new(String _columnDefinition)
Creates a new schema utility instance

Properties

columnName String
Get the column name
no setter
columnType String
Get the column type
no setter
constraintCount int
Get constraint count
no setter
constraints List<String>
Get all constraints
no setter
hasConstraints bool
Check if the column has any constraints
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

autoIncrement() SchemaUtils
Add AUTOINCREMENT modifier
check(String condition) SchemaUtils
Add CHECK constraint
clearConstraints() → void
Clear all constraints
collate(String collation) SchemaUtils
Add COLLATE clause
comment(String comment) SchemaUtils
Add COMMENT modifier
compressed() SchemaUtils
Add COMPRESSED modifier
cost(double cost) SchemaUtils
Add COST modifier
custom(String constraint) SchemaUtils
Add custom constraint
defaultValue(dynamic value) SchemaUtils
Add DEFAULT value constraint
deterministic() SchemaUtils
Add DETERMINISTIC modifier
encrypted() SchemaUtils
Add ENCRYPTED modifier
foreignKey(String referencedTable, String referencedColumn, {String? onDelete, String? onUpdate}) SchemaUtils
Add FOREIGN KEY constraint
generatedAlwaysAs(String expression) SchemaUtils
Add GENERATED ALWAYS AS constraint
generatedStored() SchemaUtils
Add STORED modifier for generated columns
generatedVirtual() SchemaUtils
Add VIRTUAL modifier for generated columns
get() String
Get the complete column definition
hasConstraint(String constraint) bool
Check if the column has a specific constraint
hidden() SchemaUtils
Add HIDDEN modifier
immutable() SchemaUtils
Add IMMUTABLE modifier
indexed() SchemaUtils
Add INDEX hint
inline() SchemaUtils
Add INLINE modifier
invisible() SchemaUtils
Add INVISIBLE modifier
leakproof() SchemaUtils
Add LEAKPROOF modifier
mutable() SchemaUtils
Add MUTABLE modifier
nonDeterministic() SchemaUtils
Add NON-DETERMINISTIC modifier
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notNull() SchemaUtils
Add NOT NULL constraint
parallelRestricted() SchemaUtils
Add PARALLEL RESTRICTED modifier
parallelSafe() SchemaUtils
Add PARALLEL SAFE modifier
parallelUnsafe() SchemaUtils
Add PARALLEL UNSAFE modifier
primaryKey() SchemaUtils
Add PRIMARY KEY constraint
readOnly() SchemaUtils
Add READONLY modifier
removeConstraint(String constraint) bool
Remove a specific constraint
replaceConstraint(String oldConstraint, String newConstraint) bool
Replace a constraint
rows(int rows) SchemaUtils
Add ROWS modifier
stored() SchemaUtils
Add STORED modifier
support(String function) SchemaUtils
Add SUPPORT modifier
toString() String
A string representation of this object.
inherited
unique() SchemaUtils
Add UNIQUE constraint
virtual() SchemaUtils
Add VIRTUAL modifier
writable() SchemaUtils
Add WRITABLE modifier

Operators

operator ==(Object other) bool
The equality operator.
inherited