feat: add remote products and qr code for payconic
This commit is contained in:
@@ -36,8 +36,13 @@ class Products extends Table {
|
||||
|
||||
IntColumn get priceInCents => integer()();
|
||||
|
||||
/// The picture shown on the tile: a local file, also offline.
|
||||
TextColumn get imagePath => text().nullable()();
|
||||
|
||||
/// The server's picture of this product (`/images/<imageId>`); [imagePath]
|
||||
/// is its downloaded copy once that finished. Null: none on the server.
|
||||
TextColumn get imageId => text().nullable()();
|
||||
|
||||
BoolColumn get active => boolean().withDefault(const Constant(true))();
|
||||
|
||||
@override
|
||||
@@ -227,6 +232,22 @@ class StockAdjustmentResults extends Table {
|
||||
Set<Column> get primaryKey => {id};
|
||||
}
|
||||
|
||||
/// Pictures taken on this tablet, waiting to be uploaded. Once uploaded, the
|
||||
/// product points at the server's copy and the row is removed; offline it
|
||||
/// waits here, while the tile already shows the local file.
|
||||
@DataClassName('PendingImageUploadRow')
|
||||
class PendingImageUploads extends Table {
|
||||
/// One picture per product: a newer one replaces a waiting one.
|
||||
TextColumn get productId => text()();
|
||||
|
||||
TextColumn get localPath => text()();
|
||||
|
||||
DateTimeColumn get createdAt => dateTime()();
|
||||
|
||||
@override
|
||||
Set<Column> get primaryKey => {productId};
|
||||
}
|
||||
|
||||
@DriftDatabase(
|
||||
tables: [
|
||||
Products,
|
||||
@@ -240,13 +261,14 @@ class StockAdjustmentResults extends Table {
|
||||
ProcessedRemoteCommands,
|
||||
TabEvents,
|
||||
StockAdjustmentResults,
|
||||
PendingImageUploads,
|
||||
],
|
||||
)
|
||||
class AppDatabase extends _$AppDatabase {
|
||||
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
||||
|
||||
@override
|
||||
int get schemaVersion => 17;
|
||||
int get schemaVersion => 18;
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration {
|
||||
@@ -362,6 +384,13 @@ class AppDatabase extends _$AppDatabase {
|
||||
remoteSyncState.settlementsCursor,
|
||||
);
|
||||
}
|
||||
|
||||
if (from < 18) {
|
||||
if (!await hasTableColumn('products', 'image_id')) {
|
||||
await migrator.addColumn(products, products.imageId);
|
||||
}
|
||||
await migrator.createTable(pendingImageUploads);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user