feat(db): lot presentation + attachment sort order (schema v4→v5)

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.
This commit is contained in:
vjrj 2026-07-09 11:51:21 +02:00
parent 06aed2a586
commit 3954c62aa6
16 changed files with 6174 additions and 32 deletions

View file

@ -57,12 +57,14 @@ class VarietyDetailCubit extends Cubit<VarietyDetailState> {
int? year,
int? month,
Quantity? quantity,
Presentation? presentation,
}) => _repo.addLot(
varietyId: varietyId,
type: type,
harvestYear: year,
harvestMonth: month,
quantity: quantity,
presentation: presentation,
);
Future<void> updateLot({
@ -71,12 +73,14 @@ class VarietyDetailCubit extends Cubit<VarietyDetailState> {
int? year,
int? month,
Quantity? quantity,
Presentation? presentation,
}) => _repo.updateLot(
lotId: lotId,
type: type,
harvestYear: year,
harvestMonth: month,
quantity: quantity,
presentation: presentation,
);
Future<void> deleteLot(String lotId) => _repo.softDeleteLot(lotId);
@ -92,6 +96,9 @@ class VarietyDetailCubit extends Cubit<VarietyDetailState> {
Future<void> removePhoto(String attachmentId) =>
_repo.removePhoto(attachmentId);
Future<void> setPreferredPhoto(String attachmentId) =>
_repo.setPreferredPhoto(varietyId, attachmentId);
Future<void> addExternalLink(String url, {String? title}) =>
_repo.addExternalLink(varietyId, url, title: title);