Expand LotType from {seed, plant} to six append-only forms (seed,
seedling, plant, tree, bulb, cutting) and add an optional Presentation
attribute (pot/tray/plug/bareRoot/rootBall) kept separate from quantity
so 'how many' and 'in what packaging' never conflate.
Add attachments.sortOrder so the cover photo is the lowest-ordered one,
enabling reordering from the full-screen viewer. Expand QuantityKind
with the new plant-aware forms.
Migrations are additive (v1→v5 all covered by migration_test); enum
values are stored by name and appended only, keeping CRDT sync safe.
50 lines
1.6 KiB
Dart
50 lines
1.6 KiB
Dart
import 'package:drift_dev/api/migrations_native.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:tane/db/database.dart';
|
|
|
|
import 'schema/schema.dart';
|
|
|
|
void main() {
|
|
late SchemaVerifier verifier;
|
|
|
|
setUpAll(() {
|
|
verifier = SchemaVerifier(GeneratedHelper());
|
|
});
|
|
|
|
test('freshly created database matches the exported schema v5', () async {
|
|
final schema = await verifier.schemaAt(5);
|
|
final db = AppDatabase(schema.newConnection());
|
|
await verifier.migrateAndValidate(db, 5);
|
|
await db.close();
|
|
});
|
|
|
|
test('upgrades v1 → v5 (Lot.type, harvestMonth, presentation, '
|
|
'Attachment.sortOrder) and matches the fresh schema', () async {
|
|
final connection = await verifier.startAt(1);
|
|
final db = AppDatabase(connection);
|
|
await verifier.migrateAndValidate(db, 5);
|
|
await db.close();
|
|
});
|
|
|
|
test('upgrades v2 → v5 and matches the fresh schema', () async {
|
|
final connection = await verifier.startAt(2);
|
|
final db = AppDatabase(connection);
|
|
await verifier.migrateAndValidate(db, 5);
|
|
await db.close();
|
|
});
|
|
|
|
test('upgrades v3 → v5 and matches the fresh schema', () async {
|
|
final connection = await verifier.startAt(3);
|
|
final db = AppDatabase(connection);
|
|
await verifier.migrateAndValidate(db, 5);
|
|
await db.close();
|
|
});
|
|
|
|
test('upgrades v4 → v5 (adds Attachment.sortOrder) and matches the fresh '
|
|
'schema', () async {
|
|
final connection = await verifier.startAt(4);
|
|
final db = AppDatabase(connection);
|
|
await verifier.migrateAndValidate(db, 5);
|
|
await db.close();
|
|
});
|
|
}
|