import 'package:drift/drift.dart';
import 'package:niogu_app/core/database/tables/outlets.dart';
import 'package:niogu_app/core/database/tables/users.dart';
import 'package:uuid/uuid.dart';

class Transactions extends Table {
  TextColumn get localId => text().clientDefault(() => const Uuid().v7().toString())();
  TextColumn get serverId => text().nullable()();
  TextColumn get outletId => text().references(Outlets, #localId)();
  TextColumn get userId => text().references(Users, #localId)();
  TextColumn get referenceType => text()();
  TextColumn get referenceId => text()();
  TextColumn get referenceNumber => text()();
  TextColumn get stakeholder => text().nullable()();
  TextColumn get transactionType => text()();
  TextColumn get category => text()();
  RealColumn get amount => real().withDefault(const Constant(0.0))();
  TextColumn get note => 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};
}