mnemo_cards/mnemo_cards_backend/lib/database/tables/statistics.dart
Dmitry 0f49280805
Some checks are pending
Backend CI / test (push) Waiting to run
Backend CI / build (push) Blocked by required conditions
Mobile App CI / test (push) Waiting to run
Mobile App CI / build-android (push) Blocked by required conditions
Mobile App CI / build-ios (push) Blocked by required conditions
Web App CI / test (push) Waiting to run
Web App CI / build (push) Blocked by required conditions
Deploy Mnemo Cards / Deploy Backend (push) Waiting to run
Deploy Mnemo Cards / Deploy Web App (push) Blocked by required conditions
Deploy Mnemo Cards / Final Verification (push) Blocked by required conditions
Deploy Telegram Bot / Deploy Telegram Bot (push) Waiting to run
fixes and format
2025-12-20 21:26:15 +03:00

41 lines
1.6 KiB
Dart

import 'package:drift/drift.dart';
import 'package:drift_postgres/drift_postgres.dart';
import 'users.dart';
import '../converters.dart' show generateUuid;
/// Таблица StudySessions - сессии изучения
class StudySessions extends Table {
// ID как String, но фактически UUID (генерируется PostgreSQL на стороне БД)
TextColumn get id =>
text().withDefault(const CustomExpression('gen_random_uuid()::text'))();
TextColumn get userId =>
text().references(Users, #id, onDelete: KeyAction.cascade)();
TextColumn get sessionId => text().nullable().unique()();
Column<PgDateTime> get startTime =>
customType(PgTypes.timestampWithTimezone)();
Column<PgDateTime> get endTime =>
customType(PgTypes.timestampWithTimezone).nullable()();
IntColumn get wordsLearned => integer().withDefault(const Constant(0))();
IntColumn get testsCompleted => integer().withDefault(const Constant(0))();
RealColumn get accuracy => real().withDefault(const Constant(0.0))();
TextColumn get packId => text().nullable()();
TextColumn get testId => text().nullable()();
// Audit
Column<PgDateTime> get createdAt =>
customType(PgTypes.timestampWithTimezone).withDefault(now())();
Column<PgDateTime> get updatedAt =>
customType(PgTypes.timestampWithTimezone).withDefault(now())();
BoolColumn get isDeleted =>
boolean().customConstraint('NOT NULL DEFAULT FALSE')();
Column<PgDateTime> get deletedAt =>
customType(PgTypes.timestampWithTimezone).nullable()();
@override
Set<Column> get primaryKey => {id};
}