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
37 lines
1.3 KiB
Dart
37 lines
1.3 KiB
Dart
import 'package:drift/drift.dart';
|
|
import 'package:drift_postgres/drift_postgres.dart';
|
|
import 'users.dart';
|
|
|
|
/// Таблица UserAchievements - достижения пользователей
|
|
class UserAchievements 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)();
|
|
|
|
// Achievement ID (from AchievementDefinitions)
|
|
TextColumn get achievementId => text()();
|
|
|
|
// When achievement was unlocked
|
|
Column<PgDateTime> get unlockedAt =>
|
|
customType(PgTypes.timestampWithTimezone).withDefault(now())();
|
|
|
|
// Progress (0.0 to 1.0)
|
|
RealColumn get progress => real().withDefault(const Constant(1.0))();
|
|
|
|
// Audit
|
|
Column<PgDateTime> get createdAt =>
|
|
customType(PgTypes.timestampWithTimezone).withDefault(now())();
|
|
Column<PgDateTime> get updatedAt =>
|
|
customType(PgTypes.timestampWithTimezone).withDefault(now())();
|
|
|
|
@override
|
|
Set<Column> get primaryKey => {id};
|
|
|
|
@override
|
|
List<String> get customConstraints => ['UNIQUE(user_id, achievement_id)'];
|
|
}
|
|
|
|
// Конвертеры импортированы из converters.dart
|