feat(plantare): schema v12 — bilateral signed columns + repo

Adds the deferred bilateral columns to Plantares (plantare-bilateral.md
§"Schema delta"), all nullable/defaulted so v1 local rows coexist
untouched:

- pledgeId (the shared id both parties key their row by), debtorKey /
  creditorKey, debtorSignature / creditorSignature, movementId (the
  shared hand-over Movement for the provenance DAG), remoteState
  (proposed/accepted/declined — the handshake, distinct from status),
  returnKind (similar/workHours/other, default similar) + workHours.

Repo: createPlantare grows optional bilateral params; plantareByPledgeId
looks a row up by the shared id; applyPlantareSignatures counter-stamps
an incoming accept; setPlantareRemoteState records a decline. The
JSON codec carries every new field so they ride backups.

Versioned migration is guarded/idempotent like the others; schema v12
dumped, test helper regenerated, migration test covers v1..v11 → v12.
db + data + services 295/295 green.
This commit is contained in:
vjrj 2026-07-14 10:59:35 +02:00
parent 3f622f7bf7
commit 01fba40ec2
11 changed files with 5322 additions and 17 deletions

View file

@ -31,7 +31,7 @@ class AppDatabase extends _$AppDatabase {
/// Current schema version; also stamped into interchange exports so an
/// importer knows which app generation wrote the file (data-model §7).
static const int currentSchemaVersion = 11;
static const int currentSchemaVersion = 12;
@override
int get schemaVersion => currentSchemaVersion;
@ -163,6 +163,30 @@ class AppDatabase extends _$AppDatabase {
await m.addColumn(lots, lots.priceCurrency);
}
}
// v12: the bilateral SIGNED Plantare (plantare-bilateral.md) keys, both
// signatures, the shared pledge id/Movement, the handshake state, and the
// structured return option. All nullable/defaulted so v1 local rows are
// untouched. Guarded (see the v7 note above).
if (from < 12) {
Future<void> addIfMissing(
String column,
GeneratedColumn<Object> definition,
) async {
if (!await _hasColumn('plantares', column)) {
await m.addColumn(plantares, definition);
}
}
await addIfMissing('pledge_id', plantares.pledgeId);
await addIfMissing('debtor_key', plantares.debtorKey);
await addIfMissing('creditor_key', plantares.creditorKey);
await addIfMissing('debtor_signature', plantares.debtorSignature);
await addIfMissing('creditor_signature', plantares.creditorSignature);
await addIfMissing('movement_id', plantares.movementId);
await addIfMissing('remote_state', plantares.remoteState);
await addIfMissing('return_kind', plantares.returnKind);
await addIfMissing('work_hours', plantares.workHours);
}
},
);