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:
parent
06aed2a586
commit
3954c62aa6
16 changed files with 6174 additions and 32 deletions
|
|
@ -27,13 +27,13 @@ class AppDatabase extends _$AppDatabase {
|
|||
AppDatabase(super.e);
|
||||
|
||||
@override
|
||||
int get schemaVersion => 3;
|
||||
int get schemaVersion => 5;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration => MigrationStrategy(
|
||||
onCreate: (m) async => m.createAll(),
|
||||
onUpgrade: (m, from, to) async {
|
||||
// v2: lots can hold seeds or plants/seedlings (plantel).
|
||||
// v2: lots can hold seeds or living plant material.
|
||||
if (from < 2) {
|
||||
await m.addColumn(lots, lots.type);
|
||||
}
|
||||
|
|
@ -41,6 +41,14 @@ class AppDatabase extends _$AppDatabase {
|
|||
if (from < 3) {
|
||||
await m.addColumn(lots, lots.harvestMonth);
|
||||
}
|
||||
// v4: optional packaging/supply form for living lots.
|
||||
if (from < 4) {
|
||||
await m.addColumn(lots, lots.presentation);
|
||||
}
|
||||
// v5: display order for attachments (cover photo = lowest sortOrder).
|
||||
if (from < 5) {
|
||||
await m.addColumn(attachments, attachments.sortOrder);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue