When a model field is removed, Brick still generates migrations that attempt to create indexes for the old column. This causes SQLite to crash during initialization with no such column errors.
Field removed was
//
@Supabase(foreignKey: "recipient_id", ignoreTo: true)
@Sqlite(index: true)
final Person? recipient;
@Sqlite(ignore: true)
String? get recipientId => recipient?.id;
@Supabase(foreignKey: "recipient_group_id", ignoreTo: true)
@Sqlite(index: true)
final Group? recipientGroup;
@Sqlite(ignore: true)
String? get recipientGroupId => recipientGroup?.id;
//
In the new migration Brick still add the indexes after already DropColumn
const List<MigrationCommand> _migration_20260119133856_up = [
DropColumn('recipient_Person_brick_id', onTable: 'Chat'),
DropColumn('recipient_group_Group_brick_id', onTable: 'Chat'),
CreateIndex(columns: ['recipient_Person_brick_id'], onTable: 'Chat', unique: false),
CreateIndex(columns: ['recipient_group_Group_brick_id'], onTable: 'Chat', unique: false)
]
Which cause my app crash...
flutter: \^[[38;5;1m┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────\^[[0m
flutter: \^[[38;5;1m│ [exception] | 18:47:29 44ms | [DATABASE] Error initialize app database\^[[0m
flutter: \^[[38;5;1m│ DatabaseException(Error Domain=FMDatabase Code=1 "no such column: recipient_Person_brick_id" UserInfo={NSLocalizedDescription=no such column: recipient_Person_brick_id}) sql 'CREATE INDEX IF NOT EXISTS index_Chat_on_recipient_Person_brick_id on `Chat`(`recipient_Person_brick_id`)' args []\^[[0m
flutter: \^[[38;5;1m│ StackTrace: #0 SqfliteSqlCipherDatabaseFactoryImpl.wrapDatabaseException (package:sqflite_sqlcipher/src/factory_sql_cipher_impl.dart:44:9)\^[[0m
flutter: \^[[38;5;1m│ <asynchronous suspension>\^[[0m
Is this a bug?
When a model field is removed, Brick still generates migrations that attempt to create indexes for the old column. This causes SQLite to crash during initialization with no such column errors.
Field removed was
In the new migration Brick still add the indexes after already
DropColumnWhich cause my app crash...
Is this a bug?