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

class ProductReviews extends Table {
  TextColumn get localId => text().clientDefault(() => const Uuid().v7().toString())();
  TextColumn get serverId => text().nullable()();
  TextColumn get customerId => text().references(Customers, #localId).nullable()();
  TextColumn get productVariantId => text().references(ProductVariants, #localId)();
  TextColumn get customerNameSnapshot => text().nullable()();
  IntColumn get rating => integer().withDefault(const Constant(0))();
  TextColumn get comment => text().nullable()();
  TextColumn get syncStatus => text().withDefault(const Constant('dirty'))();
  DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
  DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();

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