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
57 lines
2 KiB
Dart
57 lines
2 KiB
Dart
import 'package:drift/drift.dart';
|
|
|
|
import '../converters.dart' show JsonMapConverter, JsonListConverter;
|
|
import 'users.dart';
|
|
|
|
/// Таблица SubscriptionPlans - планы подписки
|
|
class SubscriptionPlans extends Table {
|
|
TextColumn get id => text().withDefault(const Constant('gen_random_uuid()'))();
|
|
|
|
// UI информация (JSON)
|
|
TextColumn get ui => text().nullable().map(const JsonMapConverter())();
|
|
|
|
// Цена и валюта
|
|
TextColumn get price => text()();
|
|
TextColumn get currency => text()();
|
|
IntColumn get durationDays => integer()();
|
|
|
|
// Функции подписки (JSON array)
|
|
TextColumn get features => text()
|
|
.withDefault(const Constant('[]'))
|
|
.map(const JsonListConverter())();
|
|
|
|
// Платежная система
|
|
TextColumn get paymentId => text().nullable()();
|
|
TextColumn get paymentSystem => text()(); // enum as string
|
|
|
|
// Audit
|
|
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
|
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
|
|
BoolColumn get isDeleted => boolean().withDefault(const Constant(false))();
|
|
|
|
@override
|
|
Set<Column> get primaryKey => {id};
|
|
}
|
|
|
|
/// Таблица UserSubscriptions - подписки пользователей
|
|
class UserSubscriptions extends Table {
|
|
TextColumn get id => text().withDefault(const Constant('gen_random_uuid()'))();
|
|
TextColumn get userId => text().unique().references(Users, #id, onDelete: KeyAction.cascade)();
|
|
|
|
DateTimeColumn get start => dateTime()();
|
|
DateTimeColumn get finish => dateTime()();
|
|
|
|
// Функции подписки (JSON array)
|
|
TextColumn get features => text()
|
|
.withDefault(const Constant('[]'))
|
|
.map(const JsonListConverter())();
|
|
|
|
// Audit
|
|
DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
|
|
DateTimeColumn get updatedAt => dateTime().withDefault(currentDateAndTime)();
|
|
|
|
@override
|
|
Set<Column> get primaryKey => {id};
|
|
}
|
|
|
|
// Конвертеры импортированы из converters.dart
|