SqliteMigration constructor
Creates a migration and validates its D1-compatible file name.
Implementation
factory SqliteMigration({required String name, required String sql}) {
final match = _migrationName.firstMatch(name);
if (match == null) {
throw FormatException(
'SQLite migration names must match NNNN_snake_case.sql: $name',
);
}
final version = int.parse(match.group(1)!);
if (version == 0) {
throw FormatException('SQLite migration versions must start at 0001.');
}
if (sql.contains('\u0000')) {
throw FormatException('SQLite migration SQL cannot contain NUL bytes.');
}
return SqliteMigration._(version: version, name: name, sql: sql);
}