Initial and done prolly
This commit is contained in:
commit
6f88b9966f
175 changed files with 15445 additions and 0 deletions
50
lib/db/database.dart
Normal file
50
lib/db/database.dart
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:drift/drift.dart';
|
||||
import 'package:drift_flutter/drift_flutter.dart';
|
||||
|
||||
import '../models/enums/temperature_mode.dart';
|
||||
import 'database.steps.dart';
|
||||
import 'tables/product.dart';
|
||||
import 'tables/product_category.dart';
|
||||
import 'tables/shopping_list_item.dart';
|
||||
import 'tables/storage_location.dart';
|
||||
import 'tables/users_table.dart';
|
||||
|
||||
part 'database.g.dart';
|
||||
|
||||
part 'crud/product_crud.dart';
|
||||
part 'crud/product_category_crud.dart';
|
||||
part 'crud/shopping_list_crud.dart';
|
||||
part 'crud/storage_locations_crud.dart';
|
||||
part 'crud/user_crud.dart';
|
||||
|
||||
@DriftDatabase(
|
||||
tables: [ProductCategory, Product, ShoppingListItem, StorageLocation, User])
|
||||
class AppDatabase extends _$AppDatabase {
|
||||
AppDatabase() : super(_openConnection());
|
||||
|
||||
@override
|
||||
int get schemaVersion => 2;
|
||||
|
||||
static QueryExecutor _openConnection() {
|
||||
return driftDatabase(name: "groceries_manager_db");
|
||||
}
|
||||
|
||||
@override
|
||||
MigrationStrategy get migration {
|
||||
return MigrationStrategy(
|
||||
onUpgrade: stepByStep(
|
||||
from1To2: (m, schema) async {
|
||||
m.createTable(schema.user);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
extension BetterConversionStorageLocation on StorageLocationData {
|
||||
TemperatureMode get temperatureModeE =>
|
||||
TemperatureMode.fromName(temperatureMode);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue