feat(plantare): reproduction-commitment data layer (schema v9)
The Plantare — a promise to reproduce seed and return some (data-model §2.7, the seed-domain Pledge with return_kind=similar). NOT a sale. Local-first v1: your honest ledger of commitments (from/to a person by name); the bilateral signed cross-party form is a later social-layer phase. - New Plantares table (SyncColumns): varietyId, direction (iReturn/owedToMe), counterparty, owedDescription, madeOn, dueBy, status (open/returned/ forgiven), settledOn, note. schemaVersion 8 -> 9 with a guarded createTable migration; schema exported + migration-test helper regenerated. - VarietyRepository: createPlantare / watchPlantares / watchPlantaresForVariety / setPlantareStatus / deletePlantare (soft-delete, CRDT-stamped). - Included in backups + sync: InventorySnapshot + JSON codec (round-trips isDeleted) + exportInventory/exportForSync/importInventory, so commitments survive restore and replicate LWW like every other row. Tests: v1..v8 -> v9 migration + fresh v9; repo create/list/settle/reopen/ delete; and a backup round-trip preserving a commitment. 13 green. UI (detail section + Plantares screen) follows.
This commit is contained in:
parent
0e41293de5
commit
81094f25a8
12 changed files with 5418 additions and 60 deletions
|
|
@ -11,68 +11,20 @@ void main() {
|
|||
verifier = SchemaVerifier(GeneratedHelper());
|
||||
});
|
||||
|
||||
test('freshly created database matches the exported schema v8', () async {
|
||||
final schema = await verifier.schemaAt(8);
|
||||
test('freshly created database matches the exported schema v9', () async {
|
||||
final schema = await verifier.schemaAt(9);
|
||||
final db = AppDatabase(schema.newConnection());
|
||||
await verifier.migrateAndValidate(db, 8);
|
||||
await verifier.migrateAndValidate(db, 9);
|
||||
await db.close();
|
||||
});
|
||||
|
||||
test('upgrades v1 → v8 (Lot.type, harvestMonth, presentation, '
|
||||
'Attachment.sortOrder, Variety.isDraft/isOrganic, Species.viabilityYears, '
|
||||
'v8 provenance/calendar/abundance/condition-checks) and matches the fresh '
|
||||
'schema', () async {
|
||||
final connection = await verifier.startAt(1);
|
||||
final db = AppDatabase(connection);
|
||||
await verifier.migrateAndValidate(db, 8);
|
||||
await db.close();
|
||||
});
|
||||
|
||||
test('upgrades v2 → v8 and matches the fresh schema', () async {
|
||||
final connection = await verifier.startAt(2);
|
||||
final db = AppDatabase(connection);
|
||||
await verifier.migrateAndValidate(db, 8);
|
||||
await db.close();
|
||||
});
|
||||
|
||||
test('upgrades v3 → v8 and matches the fresh schema', () async {
|
||||
final connection = await verifier.startAt(3);
|
||||
final db = AppDatabase(connection);
|
||||
await verifier.migrateAndValidate(db, 8);
|
||||
await db.close();
|
||||
});
|
||||
|
||||
test('upgrades v4 → v8 and matches the fresh schema', () async {
|
||||
final connection = await verifier.startAt(4);
|
||||
final db = AppDatabase(connection);
|
||||
await verifier.migrateAndValidate(db, 8);
|
||||
await db.close();
|
||||
});
|
||||
|
||||
test(
|
||||
'upgrades v5 → v8 (adds Variety.isDraft) and matches the fresh schema',
|
||||
() async {
|
||||
final connection = await verifier.startAt(5);
|
||||
// Every historical version upgrades cleanly to the current schema (v9).
|
||||
for (var from = 1; from <= 8; from++) {
|
||||
test('upgrades v$from → v9 and matches the fresh schema', () async {
|
||||
final connection = await verifier.startAt(from);
|
||||
final db = AppDatabase(connection);
|
||||
await verifier.migrateAndValidate(db, 8);
|
||||
await verifier.migrateAndValidate(db, 9);
|
||||
await db.close();
|
||||
},
|
||||
);
|
||||
|
||||
test('upgrades v6 → v8 (adds Variety.isOrganic, Species.viabilityYears) and '
|
||||
'matches the fresh schema', () async {
|
||||
final connection = await verifier.startAt(6);
|
||||
final db = AppDatabase(connection);
|
||||
await verifier.migrateAndValidate(db, 8);
|
||||
await db.close();
|
||||
});
|
||||
|
||||
test('upgrades v7 → v8 (adds Variety.needsReproduction + crop calendar, '
|
||||
'Lot.origin/abundance/preservationFormat, ConditionChecks) and matches '
|
||||
'the fresh schema', () async {
|
||||
final connection = await verifier.startAt(7);
|
||||
final db = AppDatabase(connection);
|
||||
await verifier.migrateAndValidate(db, 8);
|
||||
await db.close();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import 'schema_v5.dart' as v5;
|
|||
import 'schema_v6.dart' as v6;
|
||||
import 'schema_v7.dart' as v7;
|
||||
import 'schema_v8.dart' as v8;
|
||||
import 'schema_v9.dart' as v9;
|
||||
|
||||
class GeneratedHelper implements SchemaInstantiationHelper {
|
||||
@override
|
||||
|
|
@ -33,10 +34,12 @@ class GeneratedHelper implements SchemaInstantiationHelper {
|
|||
return v7.DatabaseAtV7(db);
|
||||
case 8:
|
||||
return v8.DatabaseAtV8(db);
|
||||
case 9:
|
||||
return v9.DatabaseAtV9(db);
|
||||
default:
|
||||
throw MissingSchemaException(version, versions);
|
||||
}
|
||||
}
|
||||
|
||||
static const versions = const [1, 2, 3, 4, 5, 6, 7, 8];
|
||||
static const versions = const [1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
}
|
||||
|
|
|
|||
1845
apps/app_seeds/test/db/schema/schema_v9.dart
Normal file
1845
apps/app_seeds/test/db/schema/schema_v9.dart
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue