CompositeMigration class

A migration that combines multiple migrations into one

Example:

final migrations = [
  CompositeMigration(
    version: 3,
    description: 'Add multiple columns',
    steps: [
      RawSqlMigration(
        version: 0, // ignored in composite
        description: 'Add age column',
        upSql: 'ALTER TABLE users ADD COLUMN age INTEGER;',
        downSql: 'ALTER TABLE users DROP COLUMN age;',
      ),
      RawSqlMigration(
        version: 0, // ignored in composite
        description: 'Add phone column',
        upSql: 'ALTER TABLE users ADD COLUMN phone VARCHAR(20);',
        downSql: 'ALTER TABLE users DROP COLUMN phone;',
      ),
    ],
  ),
];
Inheritance

Constructors

CompositeMigration({required int version, required String description, required List<DatabaseMigration> steps})

Properties

connection DatabaseConnection
getter/setter pairinherited
dbType DatabaseType
no setterinherited
description String
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schemaManager SchemaManager
getter/setter pairinherited
steps List<DatabaseMigration>
final
version int
no setteroverride

Methods

addColumn({required String table, required String column, required String type, bool nullable = true, String? defaultValue}) Future<void>
Helper to add column (skips if exists)
inherited
createIndex({required String name, required String table, required List<String> columns, bool unique = false}) Future<void>
Helper to create index (skips if exists)
inherited
createTable(DatabaseSchema schema) Future<void>
Helper to create a table from schema (skips if exists)
inherited
down() Future<void>
Migration down - rollback schema
override
dropColumn({required String table, required String column}) Future<void>
Helper to drop column (skips if not exists)
inherited
dropIndex(String name) Future<void>
Helper to drop index (skips if not exists)
inherited
dropTable(String tableName) Future<void>
Helper to drop a table (skips if not exists)
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
setConnection(DatabaseConnection conn) → void
inherited
tableExists(String tableName) Future<bool>
Helper to check if table exists
inherited
toString() String
A string representation of this object.
inherited
up() Future<void>
Migration up - create/modify schema
override

Operators

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