RawSqlMigration class
A migration that runs raw SQL statements
Example:
final migrations = [
RawSqlMigration(
version: 1,
description: 'Add status column to users',
upSql: 'ALTER TABLE users ADD COLUMN status VARCHAR(50) DEFAULT \'active\';',
downSql: 'ALTER TABLE users DROP COLUMN status;',
),
];
- Inheritance
-
- Object
- DatabaseMigration
- RawSqlMigration
Constructors
Properties
- connection ↔ DatabaseConnection
-
getter/setter pairinherited
- dbType → DatabaseType
-
no setterinherited
- description → String
-
no setteroverride
- downSql → String?
-
final
-
downSqlStatements
→ List<
String> ? -
final
- 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
- upSql → String
-
final
-
upSqlStatements
→ List<
String> ? -
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