Some checks are pending
Backend CI / test (push) Waiting to run
Backend 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
47 lines
1.7 KiB
Dart
47 lines
1.7 KiB
Dart
import 'package:drift/drift.dart';
|
|
import 'package:drift_postgres/drift_postgres.dart';
|
|
import '../converters.dart' show JsonListConverter, StringListConverter;
|
|
import 'users.dart';
|
|
|
|
/// Таблица Payments - платежи
|
|
class Payments 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 amount => text()();
|
|
TextColumn get currency => text()();
|
|
|
|
// Статус и платежная система (enum as string)
|
|
TextColumn get status => text()(); // PaymentStatus
|
|
TextColumn get paymentSystem => text()(); // PaymentSystem
|
|
|
|
TextColumn get externalToken => text().nullable()();
|
|
TextColumn get meta => text().nullable()();
|
|
|
|
Column<PgDateTime> get date => customType(PgTypes.timestampWithTimezone)
|
|
.withDefault(now())();
|
|
|
|
// Продукты (JSON array)
|
|
TextColumn get products => text()
|
|
.withDefault(const Constant('[]'))
|
|
.map(const JsonListConverter())();
|
|
|
|
// Audit
|
|
Column<PgDateTime> get createdAt => customType(PgTypes.timestampWithTimezone)
|
|
.withDefault(now())();
|
|
Column<PgDateTime> get updatedAt => customType(PgTypes.timestampWithTimezone)
|
|
.withDefault(now())();
|
|
BoolColumn get isDeleted => boolean()
|
|
.withDefault(const Constant(false))
|
|
.customConstraint('')();
|
|
Column<PgDateTime> get deletedAt => customType(PgTypes.timestampWithTimezone)
|
|
.nullable()();
|
|
|
|
@override
|
|
Set<Column> get primaryKey => {id};
|
|
}
|
|
|
|
// Конвертеры импортированы из converters.dart
|