Schema class

Schema definition for a model.

Define schema in your model:

class User extends Model {
  @override
  Map<String, Column> get schema => {
    'id': Column.integer().primaryKey().autoIncrement(),
    'email': Column.string(255).unique().notNull(),
    'name': Column.string(100).notNull(),
    'is_active': Column.boolean().defaultValue(true),
    'created_at': Column.dateTime().nullable(),
    'updated_at': Column.dateTime().nullable(),
  };
}

Constructors

Schema({required String table, required Map<String, Column> columns, List<String> indexes = const [], List<String> uniqueIndexes = const [], List<String>? primaryKey})

Properties

columns Map<String, Column>
final
hashCode int
The hash code for this object.
no setterinherited
indexes List<String>
final
primaryKey List<String>?
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
table String
final
uniqueIndexes List<String>
final

Methods

createIndexSql(String driver) List<String>
Generate CREATE INDEX statements.
createTableSql(String driver) String
Generate CREATE TABLE SQL.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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