import 'package:drift/drift.dart';
import 'package:niogu_app/core/database/tables/product_variants.dart';
import 'package:niogu_app/core/database/tables/raw_materials.dart';
import 'package:uuid/uuid.dart';

class ReceiptItems extends Table {
  TextColumn get localId => text().clientDefault(() => const Uuid().v7().toString())();
  TextColumn get serverId => text().nullable()();
  TextColumn get productVariantId => text().references(ProductVariants, #localId).nullable()();
  TextColumn get rawMaterialId => text().references(RawMaterials, #localId).nullable()();
  RealColumn get quantity => real().withDefault(const Constant(0.0))();
  TextColumn get syncStatus => text().withDefault(const Constant('dirty'))();
  DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
  DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
  DateTimeColumn get deletedAt => dateTime().nullable()();

  @override
  // TODO: implement primaryKey
  Set<Column<Object>>? get primaryKey => {localId};
}