TestSchemaManager class
Manages test schema setup with migrations and seeding support
This class provides a driver-agnostic way to:
- Run migrations from ModelDefinitions
- Execute custom migrations
- Seed test data
- Reset schema between tests
Example usage:
final manager = TestSchemaManager(
schemaDriver: connection.driver as SchemaDriver,
modelDefinitions: [UserOrmDefinition.definition],
migrations: [CreateUsersTable()],
);
await manager.setup();
await manager.seed([UserSeeder.new]);
await manager.teardown();
Constructors
-
TestSchemaManager({required SchemaDriver schemaDriver, List<
ModelDefinition< ? modelDefinitions, List<OrmEntity> >MigrationDescriptor> ? migrations, String ledgerTable = 'orm_migrations', String? tablePrefix})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
purge(
) → Future< void> - Purge all tables defined in model definitions
-
reset(
) → Future< MigrationReport> - Reset the schema by tearing down and setting up again
-
seed(
OrmConnection connection, List< DatabaseSeeder Function(OrmConnection)> seederFactories) → Future<void> - Run seeders using a connection
-
seedWithPretend(
OrmConnection connection, List< DatabaseSeeder Function(OrmConnection)> seederFactories, {bool pretend = false}) → Future<List< QueryLogEntry> > - Run seeders with pretend mode
-
setup(
) → Future< MigrationReport> - Set up the test schema by running all migrations
-
status(
) → Future< List< MigrationStatus> > - Get migration status
-
teardown(
) → Future< void> - Tear down the test schema by rolling back all migrations
-
toString(
) → String -
A string representation of this object.
inherited
-
truncateAll(
) → Future< void> - Truncate all tables defined in migrations or model definitions
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited