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
13643 lines
491 KiB
Dart
13643 lines
491 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
part of 'database.dart';
|
|
|
|
// ignore_for_file: type=lint
|
|
class $UsersTable extends Users with TableInfo<$UsersTable, User> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$UsersTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _externalUserIdMeta =
|
|
const VerificationMeta('externalUserId');
|
|
@override
|
|
late final GeneratedColumn<String> externalUserId = GeneratedColumn<String>(
|
|
'external_user_id', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways('UNIQUE'));
|
|
static const VerificationMeta _nameMeta = const VerificationMeta('name');
|
|
@override
|
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
|
'name', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _emailMeta = const VerificationMeta('email');
|
|
@override
|
|
late final GeneratedColumn<String> email = GeneratedColumn<String>(
|
|
'email', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _adminMeta = const VerificationMeta('admin');
|
|
@override
|
|
late final GeneratedColumn<bool> admin = GeneratedColumn<bool>(
|
|
'admin', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("admin" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
static const VerificationMeta _userSettingsMeta =
|
|
const VerificationMeta('userSettings');
|
|
@override
|
|
late final GeneratedColumn<String> userSettings = GeneratedColumn<String>(
|
|
'user_settings', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _purchasesMeta =
|
|
const VerificationMeta('purchases');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<String>, String> purchases =
|
|
GeneratedColumn<String>('purchases', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<String>>($UsersTable.$converterpurchases);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _isDeletedMeta =
|
|
const VerificationMeta('isDeleted');
|
|
@override
|
|
late final GeneratedColumn<bool> isDeleted = GeneratedColumn<bool>(
|
|
'is_deleted', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("is_deleted" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
externalUserId,
|
|
name,
|
|
email,
|
|
admin,
|
|
userSettings,
|
|
purchases,
|
|
createdAt,
|
|
updatedAt,
|
|
isDeleted
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'users';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<User> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('external_user_id')) {
|
|
context.handle(
|
|
_externalUserIdMeta,
|
|
externalUserId.isAcceptableOrUnknown(
|
|
data['external_user_id']!, _externalUserIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_externalUserIdMeta);
|
|
}
|
|
if (data.containsKey('name')) {
|
|
context.handle(
|
|
_nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta));
|
|
}
|
|
if (data.containsKey('email')) {
|
|
context.handle(
|
|
_emailMeta, email.isAcceptableOrUnknown(data['email']!, _emailMeta));
|
|
}
|
|
if (data.containsKey('admin')) {
|
|
context.handle(
|
|
_adminMeta, admin.isAcceptableOrUnknown(data['admin']!, _adminMeta));
|
|
}
|
|
if (data.containsKey('user_settings')) {
|
|
context.handle(
|
|
_userSettingsMeta,
|
|
userSettings.isAcceptableOrUnknown(
|
|
data['user_settings']!, _userSettingsMeta));
|
|
}
|
|
context.handle(_purchasesMeta, const VerificationResult.success());
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
if (data.containsKey('is_deleted')) {
|
|
context.handle(_isDeletedMeta,
|
|
isDeleted.isAcceptableOrUnknown(data['is_deleted']!, _isDeletedMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
User map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return User(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
externalUserId: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.string, data['${effectivePrefix}external_user_id'])!,
|
|
name: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}name']),
|
|
email: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}email']),
|
|
admin: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}admin'])!,
|
|
userSettings: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}user_settings']),
|
|
purchases: $UsersTable.$converterpurchases.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}purchases'])!),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
isDeleted: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_deleted'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$UsersTable createAlias(String alias) {
|
|
return $UsersTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<List<String>, String> $converterpurchases =
|
|
const StringListConverter();
|
|
}
|
|
|
|
class User extends DataClass implements Insertable<User> {
|
|
final int id;
|
|
final String externalUserId;
|
|
final String? name;
|
|
final String? email;
|
|
final bool admin;
|
|
final String? userSettings;
|
|
final List<String> purchases;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
final bool isDeleted;
|
|
const User(
|
|
{required this.id,
|
|
required this.externalUserId,
|
|
this.name,
|
|
this.email,
|
|
required this.admin,
|
|
this.userSettings,
|
|
required this.purchases,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.isDeleted});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['external_user_id'] = Variable<String>(externalUserId);
|
|
if (!nullToAbsent || name != null) {
|
|
map['name'] = Variable<String>(name);
|
|
}
|
|
if (!nullToAbsent || email != null) {
|
|
map['email'] = Variable<String>(email);
|
|
}
|
|
map['admin'] = Variable<bool>(admin);
|
|
if (!nullToAbsent || userSettings != null) {
|
|
map['user_settings'] = Variable<String>(userSettings);
|
|
}
|
|
{
|
|
map['purchases'] =
|
|
Variable<String>($UsersTable.$converterpurchases.toSql(purchases));
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
map['is_deleted'] = Variable<bool>(isDeleted);
|
|
return map;
|
|
}
|
|
|
|
UsersCompanion toCompanion(bool nullToAbsent) {
|
|
return UsersCompanion(
|
|
id: Value(id),
|
|
externalUserId: Value(externalUserId),
|
|
name: name == null && nullToAbsent ? const Value.absent() : Value(name),
|
|
email:
|
|
email == null && nullToAbsent ? const Value.absent() : Value(email),
|
|
admin: Value(admin),
|
|
userSettings: userSettings == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(userSettings),
|
|
purchases: Value(purchases),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
isDeleted: Value(isDeleted),
|
|
);
|
|
}
|
|
|
|
factory User.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return User(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
externalUserId: serializer.fromJson<String>(json['externalUserId']),
|
|
name: serializer.fromJson<String?>(json['name']),
|
|
email: serializer.fromJson<String?>(json['email']),
|
|
admin: serializer.fromJson<bool>(json['admin']),
|
|
userSettings: serializer.fromJson<String?>(json['userSettings']),
|
|
purchases: serializer.fromJson<List<String>>(json['purchases']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
isDeleted: serializer.fromJson<bool>(json['isDeleted']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'externalUserId': serializer.toJson<String>(externalUserId),
|
|
'name': serializer.toJson<String?>(name),
|
|
'email': serializer.toJson<String?>(email),
|
|
'admin': serializer.toJson<bool>(admin),
|
|
'userSettings': serializer.toJson<String?>(userSettings),
|
|
'purchases': serializer.toJson<List<String>>(purchases),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
'isDeleted': serializer.toJson<bool>(isDeleted),
|
|
};
|
|
}
|
|
|
|
User copyWith(
|
|
{int? id,
|
|
String? externalUserId,
|
|
Value<String?> name = const Value.absent(),
|
|
Value<String?> email = const Value.absent(),
|
|
bool? admin,
|
|
Value<String?> userSettings = const Value.absent(),
|
|
List<String>? purchases,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
bool? isDeleted}) =>
|
|
User(
|
|
id: id ?? this.id,
|
|
externalUserId: externalUserId ?? this.externalUserId,
|
|
name: name.present ? name.value : this.name,
|
|
email: email.present ? email.value : this.email,
|
|
admin: admin ?? this.admin,
|
|
userSettings:
|
|
userSettings.present ? userSettings.value : this.userSettings,
|
|
purchases: purchases ?? this.purchases,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('User(')
|
|
..write('id: $id, ')
|
|
..write('externalUserId: $externalUserId, ')
|
|
..write('name: $name, ')
|
|
..write('email: $email, ')
|
|
..write('admin: $admin, ')
|
|
..write('userSettings: $userSettings, ')
|
|
..write('purchases: $purchases, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, externalUserId, name, email, admin,
|
|
userSettings, purchases, createdAt, updatedAt, isDeleted);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is User &&
|
|
other.id == this.id &&
|
|
other.externalUserId == this.externalUserId &&
|
|
other.name == this.name &&
|
|
other.email == this.email &&
|
|
other.admin == this.admin &&
|
|
other.userSettings == this.userSettings &&
|
|
other.purchases == this.purchases &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt &&
|
|
other.isDeleted == this.isDeleted);
|
|
}
|
|
|
|
class UsersCompanion extends UpdateCompanion<User> {
|
|
final Value<int> id;
|
|
final Value<String> externalUserId;
|
|
final Value<String?> name;
|
|
final Value<String?> email;
|
|
final Value<bool> admin;
|
|
final Value<String?> userSettings;
|
|
final Value<List<String>> purchases;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
final Value<bool> isDeleted;
|
|
const UsersCompanion({
|
|
this.id = const Value.absent(),
|
|
this.externalUserId = const Value.absent(),
|
|
this.name = const Value.absent(),
|
|
this.email = const Value.absent(),
|
|
this.admin = const Value.absent(),
|
|
this.userSettings = const Value.absent(),
|
|
this.purchases = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
});
|
|
UsersCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String externalUserId,
|
|
this.name = const Value.absent(),
|
|
this.email = const Value.absent(),
|
|
this.admin = const Value.absent(),
|
|
this.userSettings = const Value.absent(),
|
|
this.purchases = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
}) : externalUserId = Value(externalUserId);
|
|
static Insertable<User> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? externalUserId,
|
|
Expression<String>? name,
|
|
Expression<String>? email,
|
|
Expression<bool>? admin,
|
|
Expression<String>? userSettings,
|
|
Expression<String>? purchases,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
Expression<bool>? isDeleted,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (externalUserId != null) 'external_user_id': externalUserId,
|
|
if (name != null) 'name': name,
|
|
if (email != null) 'email': email,
|
|
if (admin != null) 'admin': admin,
|
|
if (userSettings != null) 'user_settings': userSettings,
|
|
if (purchases != null) 'purchases': purchases,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
if (isDeleted != null) 'is_deleted': isDeleted,
|
|
});
|
|
}
|
|
|
|
UsersCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String>? externalUserId,
|
|
Value<String?>? name,
|
|
Value<String?>? email,
|
|
Value<bool>? admin,
|
|
Value<String?>? userSettings,
|
|
Value<List<String>>? purchases,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt,
|
|
Value<bool>? isDeleted}) {
|
|
return UsersCompanion(
|
|
id: id ?? this.id,
|
|
externalUserId: externalUserId ?? this.externalUserId,
|
|
name: name ?? this.name,
|
|
email: email ?? this.email,
|
|
admin: admin ?? this.admin,
|
|
userSettings: userSettings ?? this.userSettings,
|
|
purchases: purchases ?? this.purchases,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (externalUserId.present) {
|
|
map['external_user_id'] = Variable<String>(externalUserId.value);
|
|
}
|
|
if (name.present) {
|
|
map['name'] = Variable<String>(name.value);
|
|
}
|
|
if (email.present) {
|
|
map['email'] = Variable<String>(email.value);
|
|
}
|
|
if (admin.present) {
|
|
map['admin'] = Variable<bool>(admin.value);
|
|
}
|
|
if (userSettings.present) {
|
|
map['user_settings'] = Variable<String>(userSettings.value);
|
|
}
|
|
if (purchases.present) {
|
|
map['purchases'] = Variable<String>(
|
|
$UsersTable.$converterpurchases.toSql(purchases.value));
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
if (isDeleted.present) {
|
|
map['is_deleted'] = Variable<bool>(isDeleted.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UsersCompanion(')
|
|
..write('id: $id, ')
|
|
..write('externalUserId: $externalUserId, ')
|
|
..write('name: $name, ')
|
|
..write('email: $email, ')
|
|
..write('admin: $admin, ')
|
|
..write('userSettings: $userSettings, ')
|
|
..write('purchases: $purchases, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $UserDatasTable extends UserDatas
|
|
with TableInfo<$UserDatasTable, UserData> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$UserDatasTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'UNIQUE REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _totalStudyTimeMinutesMeta =
|
|
const VerificationMeta('totalStudyTimeMinutes');
|
|
@override
|
|
late final GeneratedColumn<int> totalStudyTimeMinutes = GeneratedColumn<int>(
|
|
'total_study_time_minutes', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
static const VerificationMeta _currentStreakMeta =
|
|
const VerificationMeta('currentStreak');
|
|
@override
|
|
late final GeneratedColumn<int> currentStreak = GeneratedColumn<int>(
|
|
'current_streak', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
static const VerificationMeta _longestStreakMeta =
|
|
const VerificationMeta('longestStreak');
|
|
@override
|
|
late final GeneratedColumn<int> longestStreak = GeneratedColumn<int>(
|
|
'longest_streak', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
static const VerificationMeta _totalCardsMeta =
|
|
const VerificationMeta('totalCards');
|
|
@override
|
|
late final GeneratedColumn<int> totalCards = GeneratedColumn<int>(
|
|
'total_cards', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
static const VerificationMeta _totalTestsMeta =
|
|
const VerificationMeta('totalTests');
|
|
@override
|
|
late final GeneratedColumn<int> totalTests = GeneratedColumn<int>(
|
|
'total_tests', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
static const VerificationMeta _lastTimeOnlineMeta =
|
|
const VerificationMeta('lastTimeOnline');
|
|
@override
|
|
late final GeneratedColumn<DateTime> lastTimeOnline =
|
|
GeneratedColumn<DateTime>('last_time_online', aliasedName, true,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: false);
|
|
static const VerificationMeta _registrationDateMeta =
|
|
const VerificationMeta('registrationDate');
|
|
@override
|
|
late final GeneratedColumn<DateTime> registrationDate =
|
|
GeneratedColumn<DateTime>('registration_date', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _lastTestSessionTokenMeta =
|
|
const VerificationMeta('lastTestSessionToken');
|
|
@override
|
|
late final GeneratedColumn<String> lastTestSessionToken =
|
|
GeneratedColumn<String>('last_test_session_token', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _wordsMeta = const VerificationMeta('words');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<dynamic>?, String> words =
|
|
GeneratedColumn<String>('words', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<dynamic>?>($UserDatasTable.$converterwords);
|
|
static const VerificationMeta _tagsMeta = const VerificationMeta('tags');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<String>, String> tags =
|
|
GeneratedColumn<String>('tags', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<String>>($UserDatasTable.$convertertags);
|
|
static const VerificationMeta _packProgressMeta =
|
|
const VerificationMeta('packProgress');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<dynamic>?, String>
|
|
packProgress = GeneratedColumn<String>(
|
|
'pack_progress', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<dynamic>?>(
|
|
$UserDatasTable.$converterpackProgress);
|
|
static const VerificationMeta _studyDatesMeta =
|
|
const VerificationMeta('studyDates');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<DateTime>?, String>
|
|
studyDates = GeneratedColumn<String>('study_dates', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<DateTime>?>($UserDatasTable.$converterstudyDates);
|
|
static const VerificationMeta _achievementsMeta =
|
|
const VerificationMeta('achievements');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<dynamic>?, String>
|
|
achievements = GeneratedColumn<String>('achievements', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<dynamic>?>(
|
|
$UserDatasTable.$converterachievements);
|
|
static const VerificationMeta _categoryMinutesMeta =
|
|
const VerificationMeta('categoryMinutes');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<Map<String, dynamic>?, String>
|
|
categoryMinutes = GeneratedColumn<String>(
|
|
'category_minutes', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('{}'))
|
|
.withConverter<Map<String, dynamic>?>(
|
|
$UserDatasTable.$convertercategoryMinutes);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
userId,
|
|
totalStudyTimeMinutes,
|
|
currentStreak,
|
|
longestStreak,
|
|
totalCards,
|
|
totalTests,
|
|
lastTimeOnline,
|
|
registrationDate,
|
|
lastTestSessionToken,
|
|
words,
|
|
tags,
|
|
packProgress,
|
|
studyDates,
|
|
achievements,
|
|
categoryMinutes,
|
|
createdAt,
|
|
updatedAt
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'user_datas';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<UserData> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('total_study_time_minutes')) {
|
|
context.handle(
|
|
_totalStudyTimeMinutesMeta,
|
|
totalStudyTimeMinutes.isAcceptableOrUnknown(
|
|
data['total_study_time_minutes']!, _totalStudyTimeMinutesMeta));
|
|
}
|
|
if (data.containsKey('current_streak')) {
|
|
context.handle(
|
|
_currentStreakMeta,
|
|
currentStreak.isAcceptableOrUnknown(
|
|
data['current_streak']!, _currentStreakMeta));
|
|
}
|
|
if (data.containsKey('longest_streak')) {
|
|
context.handle(
|
|
_longestStreakMeta,
|
|
longestStreak.isAcceptableOrUnknown(
|
|
data['longest_streak']!, _longestStreakMeta));
|
|
}
|
|
if (data.containsKey('total_cards')) {
|
|
context.handle(
|
|
_totalCardsMeta,
|
|
totalCards.isAcceptableOrUnknown(
|
|
data['total_cards']!, _totalCardsMeta));
|
|
}
|
|
if (data.containsKey('total_tests')) {
|
|
context.handle(
|
|
_totalTestsMeta,
|
|
totalTests.isAcceptableOrUnknown(
|
|
data['total_tests']!, _totalTestsMeta));
|
|
}
|
|
if (data.containsKey('last_time_online')) {
|
|
context.handle(
|
|
_lastTimeOnlineMeta,
|
|
lastTimeOnline.isAcceptableOrUnknown(
|
|
data['last_time_online']!, _lastTimeOnlineMeta));
|
|
}
|
|
if (data.containsKey('registration_date')) {
|
|
context.handle(
|
|
_registrationDateMeta,
|
|
registrationDate.isAcceptableOrUnknown(
|
|
data['registration_date']!, _registrationDateMeta));
|
|
}
|
|
if (data.containsKey('last_test_session_token')) {
|
|
context.handle(
|
|
_lastTestSessionTokenMeta,
|
|
lastTestSessionToken.isAcceptableOrUnknown(
|
|
data['last_test_session_token']!, _lastTestSessionTokenMeta));
|
|
}
|
|
context.handle(_wordsMeta, const VerificationResult.success());
|
|
context.handle(_tagsMeta, const VerificationResult.success());
|
|
context.handle(_packProgressMeta, const VerificationResult.success());
|
|
context.handle(_studyDatesMeta, const VerificationResult.success());
|
|
context.handle(_achievementsMeta, const VerificationResult.success());
|
|
context.handle(_categoryMinutesMeta, const VerificationResult.success());
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
UserData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return UserData(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
totalStudyTimeMinutes: attachedDatabase.typeMapping.read(DriftSqlType.int,
|
|
data['${effectivePrefix}total_study_time_minutes'])!,
|
|
currentStreak: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}current_streak'])!,
|
|
longestStreak: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}longest_streak'])!,
|
|
totalCards: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}total_cards'])!,
|
|
totalTests: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}total_tests'])!,
|
|
lastTimeOnline: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.dateTime, data['${effectivePrefix}last_time_online']),
|
|
registrationDate: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.dateTime, data['${effectivePrefix}registration_date'])!,
|
|
lastTestSessionToken: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.string,
|
|
data['${effectivePrefix}last_test_session_token']),
|
|
words: $UserDatasTable.$converterwords.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}words'])!),
|
|
tags: $UserDatasTable.$convertertags.fromSql(attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}tags'])!),
|
|
packProgress: $UserDatasTable.$converterpackProgress.fromSql(
|
|
attachedDatabase.typeMapping.read(
|
|
DriftSqlType.string, data['${effectivePrefix}pack_progress'])!),
|
|
studyDates: $UserDatasTable.$converterstudyDates.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}study_dates'])!),
|
|
achievements: $UserDatasTable.$converterachievements.fromSql(
|
|
attachedDatabase.typeMapping.read(
|
|
DriftSqlType.string, data['${effectivePrefix}achievements'])!),
|
|
categoryMinutes: $UserDatasTable.$convertercategoryMinutes.fromSql(
|
|
attachedDatabase.typeMapping.read(DriftSqlType.string,
|
|
data['${effectivePrefix}category_minutes'])!),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$UserDatasTable createAlias(String alias) {
|
|
return $UserDatasTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<List<dynamic>?, String> $converterwords =
|
|
const JsonListConverter();
|
|
static TypeConverter<List<String>, String> $convertertags =
|
|
const StringListConverter();
|
|
static TypeConverter<List<dynamic>?, String> $converterpackProgress =
|
|
const JsonListConverter();
|
|
static TypeConverter<List<DateTime>?, String> $converterstudyDates =
|
|
const DateTimeListConverter();
|
|
static TypeConverter<List<dynamic>?, String> $converterachievements =
|
|
const JsonListConverter();
|
|
static TypeConverter<Map<String, dynamic>?, String>
|
|
$convertercategoryMinutes = const JsonMapConverter();
|
|
}
|
|
|
|
class UserData extends DataClass implements Insertable<UserData> {
|
|
final int id;
|
|
final int userId;
|
|
final int totalStudyTimeMinutes;
|
|
final int currentStreak;
|
|
final int longestStreak;
|
|
final int totalCards;
|
|
final int totalTests;
|
|
final DateTime? lastTimeOnline;
|
|
final DateTime registrationDate;
|
|
final String? lastTestSessionToken;
|
|
final List<dynamic>? words;
|
|
final List<String> tags;
|
|
final List<dynamic>? packProgress;
|
|
final List<DateTime>? studyDates;
|
|
final List<dynamic>? achievements;
|
|
final Map<String, dynamic>? categoryMinutes;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
const UserData(
|
|
{required this.id,
|
|
required this.userId,
|
|
required this.totalStudyTimeMinutes,
|
|
required this.currentStreak,
|
|
required this.longestStreak,
|
|
required this.totalCards,
|
|
required this.totalTests,
|
|
this.lastTimeOnline,
|
|
required this.registrationDate,
|
|
this.lastTestSessionToken,
|
|
this.words,
|
|
required this.tags,
|
|
this.packProgress,
|
|
this.studyDates,
|
|
this.achievements,
|
|
this.categoryMinutes,
|
|
required this.createdAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['total_study_time_minutes'] = Variable<int>(totalStudyTimeMinutes);
|
|
map['current_streak'] = Variable<int>(currentStreak);
|
|
map['longest_streak'] = Variable<int>(longestStreak);
|
|
map['total_cards'] = Variable<int>(totalCards);
|
|
map['total_tests'] = Variable<int>(totalTests);
|
|
if (!nullToAbsent || lastTimeOnline != null) {
|
|
map['last_time_online'] = Variable<DateTime>(lastTimeOnline);
|
|
}
|
|
map['registration_date'] = Variable<DateTime>(registrationDate);
|
|
if (!nullToAbsent || lastTestSessionToken != null) {
|
|
map['last_test_session_token'] = Variable<String>(lastTestSessionToken);
|
|
}
|
|
if (!nullToAbsent || words != null) {
|
|
map['words'] =
|
|
Variable<String>($UserDatasTable.$converterwords.toSql(words));
|
|
}
|
|
{
|
|
map['tags'] =
|
|
Variable<String>($UserDatasTable.$convertertags.toSql(tags));
|
|
}
|
|
if (!nullToAbsent || packProgress != null) {
|
|
map['pack_progress'] = Variable<String>(
|
|
$UserDatasTable.$converterpackProgress.toSql(packProgress));
|
|
}
|
|
if (!nullToAbsent || studyDates != null) {
|
|
map['study_dates'] = Variable<String>(
|
|
$UserDatasTable.$converterstudyDates.toSql(studyDates));
|
|
}
|
|
if (!nullToAbsent || achievements != null) {
|
|
map['achievements'] = Variable<String>(
|
|
$UserDatasTable.$converterachievements.toSql(achievements));
|
|
}
|
|
if (!nullToAbsent || categoryMinutes != null) {
|
|
map['category_minutes'] = Variable<String>(
|
|
$UserDatasTable.$convertercategoryMinutes.toSql(categoryMinutes));
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
UserDatasCompanion toCompanion(bool nullToAbsent) {
|
|
return UserDatasCompanion(
|
|
id: Value(id),
|
|
userId: Value(userId),
|
|
totalStudyTimeMinutes: Value(totalStudyTimeMinutes),
|
|
currentStreak: Value(currentStreak),
|
|
longestStreak: Value(longestStreak),
|
|
totalCards: Value(totalCards),
|
|
totalTests: Value(totalTests),
|
|
lastTimeOnline: lastTimeOnline == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(lastTimeOnline),
|
|
registrationDate: Value(registrationDate),
|
|
lastTestSessionToken: lastTestSessionToken == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(lastTestSessionToken),
|
|
words:
|
|
words == null && nullToAbsent ? const Value.absent() : Value(words),
|
|
tags: Value(tags),
|
|
packProgress: packProgress == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(packProgress),
|
|
studyDates: studyDates == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(studyDates),
|
|
achievements: achievements == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(achievements),
|
|
categoryMinutes: categoryMinutes == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(categoryMinutes),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory UserData.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return UserData(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
totalStudyTimeMinutes:
|
|
serializer.fromJson<int>(json['totalStudyTimeMinutes']),
|
|
currentStreak: serializer.fromJson<int>(json['currentStreak']),
|
|
longestStreak: serializer.fromJson<int>(json['longestStreak']),
|
|
totalCards: serializer.fromJson<int>(json['totalCards']),
|
|
totalTests: serializer.fromJson<int>(json['totalTests']),
|
|
lastTimeOnline: serializer.fromJson<DateTime?>(json['lastTimeOnline']),
|
|
registrationDate: serializer.fromJson<DateTime>(json['registrationDate']),
|
|
lastTestSessionToken:
|
|
serializer.fromJson<String?>(json['lastTestSessionToken']),
|
|
words: serializer.fromJson<List<dynamic>?>(json['words']),
|
|
tags: serializer.fromJson<List<String>>(json['tags']),
|
|
packProgress: serializer.fromJson<List<dynamic>?>(json['packProgress']),
|
|
studyDates: serializer.fromJson<List<DateTime>?>(json['studyDates']),
|
|
achievements: serializer.fromJson<List<dynamic>?>(json['achievements']),
|
|
categoryMinutes:
|
|
serializer.fromJson<Map<String, dynamic>?>(json['categoryMinutes']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'totalStudyTimeMinutes': serializer.toJson<int>(totalStudyTimeMinutes),
|
|
'currentStreak': serializer.toJson<int>(currentStreak),
|
|
'longestStreak': serializer.toJson<int>(longestStreak),
|
|
'totalCards': serializer.toJson<int>(totalCards),
|
|
'totalTests': serializer.toJson<int>(totalTests),
|
|
'lastTimeOnline': serializer.toJson<DateTime?>(lastTimeOnline),
|
|
'registrationDate': serializer.toJson<DateTime>(registrationDate),
|
|
'lastTestSessionToken': serializer.toJson<String?>(lastTestSessionToken),
|
|
'words': serializer.toJson<List<dynamic>?>(words),
|
|
'tags': serializer.toJson<List<String>>(tags),
|
|
'packProgress': serializer.toJson<List<dynamic>?>(packProgress),
|
|
'studyDates': serializer.toJson<List<DateTime>?>(studyDates),
|
|
'achievements': serializer.toJson<List<dynamic>?>(achievements),
|
|
'categoryMinutes':
|
|
serializer.toJson<Map<String, dynamic>?>(categoryMinutes),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
UserData copyWith(
|
|
{int? id,
|
|
int? userId,
|
|
int? totalStudyTimeMinutes,
|
|
int? currentStreak,
|
|
int? longestStreak,
|
|
int? totalCards,
|
|
int? totalTests,
|
|
Value<DateTime?> lastTimeOnline = const Value.absent(),
|
|
DateTime? registrationDate,
|
|
Value<String?> lastTestSessionToken = const Value.absent(),
|
|
Value<List<dynamic>?> words = const Value.absent(),
|
|
List<String>? tags,
|
|
Value<List<dynamic>?> packProgress = const Value.absent(),
|
|
Value<List<DateTime>?> studyDates = const Value.absent(),
|
|
Value<List<dynamic>?> achievements = const Value.absent(),
|
|
Value<Map<String, dynamic>?> categoryMinutes = const Value.absent(),
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt}) =>
|
|
UserData(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
totalStudyTimeMinutes:
|
|
totalStudyTimeMinutes ?? this.totalStudyTimeMinutes,
|
|
currentStreak: currentStreak ?? this.currentStreak,
|
|
longestStreak: longestStreak ?? this.longestStreak,
|
|
totalCards: totalCards ?? this.totalCards,
|
|
totalTests: totalTests ?? this.totalTests,
|
|
lastTimeOnline:
|
|
lastTimeOnline.present ? lastTimeOnline.value : this.lastTimeOnline,
|
|
registrationDate: registrationDate ?? this.registrationDate,
|
|
lastTestSessionToken: lastTestSessionToken.present
|
|
? lastTestSessionToken.value
|
|
: this.lastTestSessionToken,
|
|
words: words.present ? words.value : this.words,
|
|
tags: tags ?? this.tags,
|
|
packProgress:
|
|
packProgress.present ? packProgress.value : this.packProgress,
|
|
studyDates: studyDates.present ? studyDates.value : this.studyDates,
|
|
achievements:
|
|
achievements.present ? achievements.value : this.achievements,
|
|
categoryMinutes: categoryMinutes.present
|
|
? categoryMinutes.value
|
|
: this.categoryMinutes,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserData(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('totalStudyTimeMinutes: $totalStudyTimeMinutes, ')
|
|
..write('currentStreak: $currentStreak, ')
|
|
..write('longestStreak: $longestStreak, ')
|
|
..write('totalCards: $totalCards, ')
|
|
..write('totalTests: $totalTests, ')
|
|
..write('lastTimeOnline: $lastTimeOnline, ')
|
|
..write('registrationDate: $registrationDate, ')
|
|
..write('lastTestSessionToken: $lastTestSessionToken, ')
|
|
..write('words: $words, ')
|
|
..write('tags: $tags, ')
|
|
..write('packProgress: $packProgress, ')
|
|
..write('studyDates: $studyDates, ')
|
|
..write('achievements: $achievements, ')
|
|
..write('categoryMinutes: $categoryMinutes, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id,
|
|
userId,
|
|
totalStudyTimeMinutes,
|
|
currentStreak,
|
|
longestStreak,
|
|
totalCards,
|
|
totalTests,
|
|
lastTimeOnline,
|
|
registrationDate,
|
|
lastTestSessionToken,
|
|
words,
|
|
tags,
|
|
packProgress,
|
|
studyDates,
|
|
achievements,
|
|
categoryMinutes,
|
|
createdAt,
|
|
updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is UserData &&
|
|
other.id == this.id &&
|
|
other.userId == this.userId &&
|
|
other.totalStudyTimeMinutes == this.totalStudyTimeMinutes &&
|
|
other.currentStreak == this.currentStreak &&
|
|
other.longestStreak == this.longestStreak &&
|
|
other.totalCards == this.totalCards &&
|
|
other.totalTests == this.totalTests &&
|
|
other.lastTimeOnline == this.lastTimeOnline &&
|
|
other.registrationDate == this.registrationDate &&
|
|
other.lastTestSessionToken == this.lastTestSessionToken &&
|
|
other.words == this.words &&
|
|
other.tags == this.tags &&
|
|
other.packProgress == this.packProgress &&
|
|
other.studyDates == this.studyDates &&
|
|
other.achievements == this.achievements &&
|
|
other.categoryMinutes == this.categoryMinutes &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class UserDatasCompanion extends UpdateCompanion<UserData> {
|
|
final Value<int> id;
|
|
final Value<int> userId;
|
|
final Value<int> totalStudyTimeMinutes;
|
|
final Value<int> currentStreak;
|
|
final Value<int> longestStreak;
|
|
final Value<int> totalCards;
|
|
final Value<int> totalTests;
|
|
final Value<DateTime?> lastTimeOnline;
|
|
final Value<DateTime> registrationDate;
|
|
final Value<String?> lastTestSessionToken;
|
|
final Value<List<dynamic>?> words;
|
|
final Value<List<String>> tags;
|
|
final Value<List<dynamic>?> packProgress;
|
|
final Value<List<DateTime>?> studyDates;
|
|
final Value<List<dynamic>?> achievements;
|
|
final Value<Map<String, dynamic>?> categoryMinutes;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
const UserDatasCompanion({
|
|
this.id = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.totalStudyTimeMinutes = const Value.absent(),
|
|
this.currentStreak = const Value.absent(),
|
|
this.longestStreak = const Value.absent(),
|
|
this.totalCards = const Value.absent(),
|
|
this.totalTests = const Value.absent(),
|
|
this.lastTimeOnline = const Value.absent(),
|
|
this.registrationDate = const Value.absent(),
|
|
this.lastTestSessionToken = const Value.absent(),
|
|
this.words = const Value.absent(),
|
|
this.tags = const Value.absent(),
|
|
this.packProgress = const Value.absent(),
|
|
this.studyDates = const Value.absent(),
|
|
this.achievements = const Value.absent(),
|
|
this.categoryMinutes = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
UserDatasCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int userId,
|
|
this.totalStudyTimeMinutes = const Value.absent(),
|
|
this.currentStreak = const Value.absent(),
|
|
this.longestStreak = const Value.absent(),
|
|
this.totalCards = const Value.absent(),
|
|
this.totalTests = const Value.absent(),
|
|
this.lastTimeOnline = const Value.absent(),
|
|
this.registrationDate = const Value.absent(),
|
|
this.lastTestSessionToken = const Value.absent(),
|
|
this.words = const Value.absent(),
|
|
this.tags = const Value.absent(),
|
|
this.packProgress = const Value.absent(),
|
|
this.studyDates = const Value.absent(),
|
|
this.achievements = const Value.absent(),
|
|
this.categoryMinutes = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : userId = Value(userId);
|
|
static Insertable<UserData> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? userId,
|
|
Expression<int>? totalStudyTimeMinutes,
|
|
Expression<int>? currentStreak,
|
|
Expression<int>? longestStreak,
|
|
Expression<int>? totalCards,
|
|
Expression<int>? totalTests,
|
|
Expression<DateTime>? lastTimeOnline,
|
|
Expression<DateTime>? registrationDate,
|
|
Expression<String>? lastTestSessionToken,
|
|
Expression<String>? words,
|
|
Expression<String>? tags,
|
|
Expression<String>? packProgress,
|
|
Expression<String>? studyDates,
|
|
Expression<String>? achievements,
|
|
Expression<String>? categoryMinutes,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'user_id': userId,
|
|
if (totalStudyTimeMinutes != null)
|
|
'total_study_time_minutes': totalStudyTimeMinutes,
|
|
if (currentStreak != null) 'current_streak': currentStreak,
|
|
if (longestStreak != null) 'longest_streak': longestStreak,
|
|
if (totalCards != null) 'total_cards': totalCards,
|
|
if (totalTests != null) 'total_tests': totalTests,
|
|
if (lastTimeOnline != null) 'last_time_online': lastTimeOnline,
|
|
if (registrationDate != null) 'registration_date': registrationDate,
|
|
if (lastTestSessionToken != null)
|
|
'last_test_session_token': lastTestSessionToken,
|
|
if (words != null) 'words': words,
|
|
if (tags != null) 'tags': tags,
|
|
if (packProgress != null) 'pack_progress': packProgress,
|
|
if (studyDates != null) 'study_dates': studyDates,
|
|
if (achievements != null) 'achievements': achievements,
|
|
if (categoryMinutes != null) 'category_minutes': categoryMinutes,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
UserDatasCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? userId,
|
|
Value<int>? totalStudyTimeMinutes,
|
|
Value<int>? currentStreak,
|
|
Value<int>? longestStreak,
|
|
Value<int>? totalCards,
|
|
Value<int>? totalTests,
|
|
Value<DateTime?>? lastTimeOnline,
|
|
Value<DateTime>? registrationDate,
|
|
Value<String?>? lastTestSessionToken,
|
|
Value<List<dynamic>?>? words,
|
|
Value<List<String>>? tags,
|
|
Value<List<dynamic>?>? packProgress,
|
|
Value<List<DateTime>?>? studyDates,
|
|
Value<List<dynamic>?>? achievements,
|
|
Value<Map<String, dynamic>?>? categoryMinutes,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return UserDatasCompanion(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
totalStudyTimeMinutes:
|
|
totalStudyTimeMinutes ?? this.totalStudyTimeMinutes,
|
|
currentStreak: currentStreak ?? this.currentStreak,
|
|
longestStreak: longestStreak ?? this.longestStreak,
|
|
totalCards: totalCards ?? this.totalCards,
|
|
totalTests: totalTests ?? this.totalTests,
|
|
lastTimeOnline: lastTimeOnline ?? this.lastTimeOnline,
|
|
registrationDate: registrationDate ?? this.registrationDate,
|
|
lastTestSessionToken: lastTestSessionToken ?? this.lastTestSessionToken,
|
|
words: words ?? this.words,
|
|
tags: tags ?? this.tags,
|
|
packProgress: packProgress ?? this.packProgress,
|
|
studyDates: studyDates ?? this.studyDates,
|
|
achievements: achievements ?? this.achievements,
|
|
categoryMinutes: categoryMinutes ?? this.categoryMinutes,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (totalStudyTimeMinutes.present) {
|
|
map['total_study_time_minutes'] =
|
|
Variable<int>(totalStudyTimeMinutes.value);
|
|
}
|
|
if (currentStreak.present) {
|
|
map['current_streak'] = Variable<int>(currentStreak.value);
|
|
}
|
|
if (longestStreak.present) {
|
|
map['longest_streak'] = Variable<int>(longestStreak.value);
|
|
}
|
|
if (totalCards.present) {
|
|
map['total_cards'] = Variable<int>(totalCards.value);
|
|
}
|
|
if (totalTests.present) {
|
|
map['total_tests'] = Variable<int>(totalTests.value);
|
|
}
|
|
if (lastTimeOnline.present) {
|
|
map['last_time_online'] = Variable<DateTime>(lastTimeOnline.value);
|
|
}
|
|
if (registrationDate.present) {
|
|
map['registration_date'] = Variable<DateTime>(registrationDate.value);
|
|
}
|
|
if (lastTestSessionToken.present) {
|
|
map['last_test_session_token'] =
|
|
Variable<String>(lastTestSessionToken.value);
|
|
}
|
|
if (words.present) {
|
|
map['words'] =
|
|
Variable<String>($UserDatasTable.$converterwords.toSql(words.value));
|
|
}
|
|
if (tags.present) {
|
|
map['tags'] =
|
|
Variable<String>($UserDatasTable.$convertertags.toSql(tags.value));
|
|
}
|
|
if (packProgress.present) {
|
|
map['pack_progress'] = Variable<String>(
|
|
$UserDatasTable.$converterpackProgress.toSql(packProgress.value));
|
|
}
|
|
if (studyDates.present) {
|
|
map['study_dates'] = Variable<String>(
|
|
$UserDatasTable.$converterstudyDates.toSql(studyDates.value));
|
|
}
|
|
if (achievements.present) {
|
|
map['achievements'] = Variable<String>(
|
|
$UserDatasTable.$converterachievements.toSql(achievements.value));
|
|
}
|
|
if (categoryMinutes.present) {
|
|
map['category_minutes'] = Variable<String>($UserDatasTable
|
|
.$convertercategoryMinutes
|
|
.toSql(categoryMinutes.value));
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserDatasCompanion(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('totalStudyTimeMinutes: $totalStudyTimeMinutes, ')
|
|
..write('currentStreak: $currentStreak, ')
|
|
..write('longestStreak: $longestStreak, ')
|
|
..write('totalCards: $totalCards, ')
|
|
..write('totalTests: $totalTests, ')
|
|
..write('lastTimeOnline: $lastTimeOnline, ')
|
|
..write('registrationDate: $registrationDate, ')
|
|
..write('lastTestSessionToken: $lastTestSessionToken, ')
|
|
..write('words: $words, ')
|
|
..write('tags: $tags, ')
|
|
..write('packProgress: $packProgress, ')
|
|
..write('studyDates: $studyDates, ')
|
|
..write('achievements: $achievements, ')
|
|
..write('categoryMinutes: $categoryMinutes, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $TokensTable extends Tokens with TableInfo<$TokensTable, Token> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$TokensTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _tokenMeta = const VerificationMeta('token');
|
|
@override
|
|
late final GeneratedColumn<String> token = GeneratedColumn<String>(
|
|
'token', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways('UNIQUE'));
|
|
static const VerificationMeta _externalUserIdMeta =
|
|
const VerificationMeta('externalUserId');
|
|
@override
|
|
late final GeneratedColumn<String> externalUserId = GeneratedColumn<String>(
|
|
'external_user_id', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _createdMeta =
|
|
const VerificationMeta('created');
|
|
@override
|
|
late final GeneratedColumn<DateTime> created = GeneratedColumn<DateTime>(
|
|
'created', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _expiresMeta =
|
|
const VerificationMeta('expires');
|
|
@override
|
|
late final GeneratedColumn<DateTime> expires = GeneratedColumn<DateTime>(
|
|
'expires', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, userId, token, externalUserId, created, expires];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'tokens';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<Token> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('token')) {
|
|
context.handle(
|
|
_tokenMeta, token.isAcceptableOrUnknown(data['token']!, _tokenMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_tokenMeta);
|
|
}
|
|
if (data.containsKey('external_user_id')) {
|
|
context.handle(
|
|
_externalUserIdMeta,
|
|
externalUserId.isAcceptableOrUnknown(
|
|
data['external_user_id']!, _externalUserIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_externalUserIdMeta);
|
|
}
|
|
if (data.containsKey('created')) {
|
|
context.handle(_createdMeta,
|
|
created.isAcceptableOrUnknown(data['created']!, _createdMeta));
|
|
}
|
|
if (data.containsKey('expires')) {
|
|
context.handle(_expiresMeta,
|
|
expires.isAcceptableOrUnknown(data['expires']!, _expiresMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_expiresMeta);
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
Token map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return Token(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
token: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}token'])!,
|
|
externalUserId: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.string, data['${effectivePrefix}external_user_id'])!,
|
|
created: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created'])!,
|
|
expires: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}expires'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$TokensTable createAlias(String alias) {
|
|
return $TokensTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class Token extends DataClass implements Insertable<Token> {
|
|
final int id;
|
|
final int userId;
|
|
final String token;
|
|
final String externalUserId;
|
|
final DateTime created;
|
|
final DateTime expires;
|
|
const Token(
|
|
{required this.id,
|
|
required this.userId,
|
|
required this.token,
|
|
required this.externalUserId,
|
|
required this.created,
|
|
required this.expires});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['token'] = Variable<String>(token);
|
|
map['external_user_id'] = Variable<String>(externalUserId);
|
|
map['created'] = Variable<DateTime>(created);
|
|
map['expires'] = Variable<DateTime>(expires);
|
|
return map;
|
|
}
|
|
|
|
TokensCompanion toCompanion(bool nullToAbsent) {
|
|
return TokensCompanion(
|
|
id: Value(id),
|
|
userId: Value(userId),
|
|
token: Value(token),
|
|
externalUserId: Value(externalUserId),
|
|
created: Value(created),
|
|
expires: Value(expires),
|
|
);
|
|
}
|
|
|
|
factory Token.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return Token(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
token: serializer.fromJson<String>(json['token']),
|
|
externalUserId: serializer.fromJson<String>(json['externalUserId']),
|
|
created: serializer.fromJson<DateTime>(json['created']),
|
|
expires: serializer.fromJson<DateTime>(json['expires']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'token': serializer.toJson<String>(token),
|
|
'externalUserId': serializer.toJson<String>(externalUserId),
|
|
'created': serializer.toJson<DateTime>(created),
|
|
'expires': serializer.toJson<DateTime>(expires),
|
|
};
|
|
}
|
|
|
|
Token copyWith(
|
|
{int? id,
|
|
int? userId,
|
|
String? token,
|
|
String? externalUserId,
|
|
DateTime? created,
|
|
DateTime? expires}) =>
|
|
Token(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
token: token ?? this.token,
|
|
externalUserId: externalUserId ?? this.externalUserId,
|
|
created: created ?? this.created,
|
|
expires: expires ?? this.expires,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('Token(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('token: $token, ')
|
|
..write('externalUserId: $externalUserId, ')
|
|
..write('created: $created, ')
|
|
..write('expires: $expires')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode =>
|
|
Object.hash(id, userId, token, externalUserId, created, expires);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is Token &&
|
|
other.id == this.id &&
|
|
other.userId == this.userId &&
|
|
other.token == this.token &&
|
|
other.externalUserId == this.externalUserId &&
|
|
other.created == this.created &&
|
|
other.expires == this.expires);
|
|
}
|
|
|
|
class TokensCompanion extends UpdateCompanion<Token> {
|
|
final Value<int> id;
|
|
final Value<int> userId;
|
|
final Value<String> token;
|
|
final Value<String> externalUserId;
|
|
final Value<DateTime> created;
|
|
final Value<DateTime> expires;
|
|
const TokensCompanion({
|
|
this.id = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.token = const Value.absent(),
|
|
this.externalUserId = const Value.absent(),
|
|
this.created = const Value.absent(),
|
|
this.expires = const Value.absent(),
|
|
});
|
|
TokensCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int userId,
|
|
required String token,
|
|
required String externalUserId,
|
|
this.created = const Value.absent(),
|
|
required DateTime expires,
|
|
}) : userId = Value(userId),
|
|
token = Value(token),
|
|
externalUserId = Value(externalUserId),
|
|
expires = Value(expires);
|
|
static Insertable<Token> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? userId,
|
|
Expression<String>? token,
|
|
Expression<String>? externalUserId,
|
|
Expression<DateTime>? created,
|
|
Expression<DateTime>? expires,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'user_id': userId,
|
|
if (token != null) 'token': token,
|
|
if (externalUserId != null) 'external_user_id': externalUserId,
|
|
if (created != null) 'created': created,
|
|
if (expires != null) 'expires': expires,
|
|
});
|
|
}
|
|
|
|
TokensCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? userId,
|
|
Value<String>? token,
|
|
Value<String>? externalUserId,
|
|
Value<DateTime>? created,
|
|
Value<DateTime>? expires}) {
|
|
return TokensCompanion(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
token: token ?? this.token,
|
|
externalUserId: externalUserId ?? this.externalUserId,
|
|
created: created ?? this.created,
|
|
expires: expires ?? this.expires,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (token.present) {
|
|
map['token'] = Variable<String>(token.value);
|
|
}
|
|
if (externalUserId.present) {
|
|
map['external_user_id'] = Variable<String>(externalUserId.value);
|
|
}
|
|
if (created.present) {
|
|
map['created'] = Variable<DateTime>(created.value);
|
|
}
|
|
if (expires.present) {
|
|
map['expires'] = Variable<DateTime>(expires.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TokensCompanion(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('token: $token, ')
|
|
..write('externalUserId: $externalUserId, ')
|
|
..write('created: $created, ')
|
|
..write('expires: $expires')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $RefreshTokensTable extends RefreshTokens
|
|
with TableInfo<$RefreshTokensTable, RefreshToken> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$RefreshTokensTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _jtiMeta = const VerificationMeta('jti');
|
|
@override
|
|
late final GeneratedColumn<String> jti = GeneratedColumn<String>(
|
|
'jti', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways('UNIQUE'));
|
|
static const VerificationMeta _isBlacklistedMeta =
|
|
const VerificationMeta('isBlacklisted');
|
|
@override
|
|
late final GeneratedColumn<bool> isBlacklisted = GeneratedColumn<bool>(
|
|
'is_blacklisted', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'CHECK ("is_blacklisted" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _expiresAtMeta =
|
|
const VerificationMeta('expiresAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> expiresAt = GeneratedColumn<DateTime>(
|
|
'expires_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, userId, jti, isBlacklisted, createdAt, expiresAt];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'refresh_tokens';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<RefreshToken> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('jti')) {
|
|
context.handle(
|
|
_jtiMeta, jti.isAcceptableOrUnknown(data['jti']!, _jtiMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_jtiMeta);
|
|
}
|
|
if (data.containsKey('is_blacklisted')) {
|
|
context.handle(
|
|
_isBlacklistedMeta,
|
|
isBlacklisted.isAcceptableOrUnknown(
|
|
data['is_blacklisted']!, _isBlacklistedMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('expires_at')) {
|
|
context.handle(_expiresAtMeta,
|
|
expiresAt.isAcceptableOrUnknown(data['expires_at']!, _expiresAtMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_expiresAtMeta);
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
RefreshToken map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return RefreshToken(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
jti: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}jti'])!,
|
|
isBlacklisted: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_blacklisted'])!,
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
expiresAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}expires_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$RefreshTokensTable createAlias(String alias) {
|
|
return $RefreshTokensTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class RefreshToken extends DataClass implements Insertable<RefreshToken> {
|
|
final int id;
|
|
final int userId;
|
|
final String jti;
|
|
final bool isBlacklisted;
|
|
final DateTime createdAt;
|
|
final DateTime expiresAt;
|
|
const RefreshToken(
|
|
{required this.id,
|
|
required this.userId,
|
|
required this.jti,
|
|
required this.isBlacklisted,
|
|
required this.createdAt,
|
|
required this.expiresAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['jti'] = Variable<String>(jti);
|
|
map['is_blacklisted'] = Variable<bool>(isBlacklisted);
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['expires_at'] = Variable<DateTime>(expiresAt);
|
|
return map;
|
|
}
|
|
|
|
RefreshTokensCompanion toCompanion(bool nullToAbsent) {
|
|
return RefreshTokensCompanion(
|
|
id: Value(id),
|
|
userId: Value(userId),
|
|
jti: Value(jti),
|
|
isBlacklisted: Value(isBlacklisted),
|
|
createdAt: Value(createdAt),
|
|
expiresAt: Value(expiresAt),
|
|
);
|
|
}
|
|
|
|
factory RefreshToken.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return RefreshToken(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
jti: serializer.fromJson<String>(json['jti']),
|
|
isBlacklisted: serializer.fromJson<bool>(json['isBlacklisted']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
expiresAt: serializer.fromJson<DateTime>(json['expiresAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'jti': serializer.toJson<String>(jti),
|
|
'isBlacklisted': serializer.toJson<bool>(isBlacklisted),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'expiresAt': serializer.toJson<DateTime>(expiresAt),
|
|
};
|
|
}
|
|
|
|
RefreshToken copyWith(
|
|
{int? id,
|
|
int? userId,
|
|
String? jti,
|
|
bool? isBlacklisted,
|
|
DateTime? createdAt,
|
|
DateTime? expiresAt}) =>
|
|
RefreshToken(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
jti: jti ?? this.jti,
|
|
isBlacklisted: isBlacklisted ?? this.isBlacklisted,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
expiresAt: expiresAt ?? this.expiresAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('RefreshToken(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('jti: $jti, ')
|
|
..write('isBlacklisted: $isBlacklisted, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('expiresAt: $expiresAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode =>
|
|
Object.hash(id, userId, jti, isBlacklisted, createdAt, expiresAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is RefreshToken &&
|
|
other.id == this.id &&
|
|
other.userId == this.userId &&
|
|
other.jti == this.jti &&
|
|
other.isBlacklisted == this.isBlacklisted &&
|
|
other.createdAt == this.createdAt &&
|
|
other.expiresAt == this.expiresAt);
|
|
}
|
|
|
|
class RefreshTokensCompanion extends UpdateCompanion<RefreshToken> {
|
|
final Value<int> id;
|
|
final Value<int> userId;
|
|
final Value<String> jti;
|
|
final Value<bool> isBlacklisted;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> expiresAt;
|
|
const RefreshTokensCompanion({
|
|
this.id = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.jti = const Value.absent(),
|
|
this.isBlacklisted = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.expiresAt = const Value.absent(),
|
|
});
|
|
RefreshTokensCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int userId,
|
|
required String jti,
|
|
this.isBlacklisted = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
required DateTime expiresAt,
|
|
}) : userId = Value(userId),
|
|
jti = Value(jti),
|
|
expiresAt = Value(expiresAt);
|
|
static Insertable<RefreshToken> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? userId,
|
|
Expression<String>? jti,
|
|
Expression<bool>? isBlacklisted,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? expiresAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'user_id': userId,
|
|
if (jti != null) 'jti': jti,
|
|
if (isBlacklisted != null) 'is_blacklisted': isBlacklisted,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (expiresAt != null) 'expires_at': expiresAt,
|
|
});
|
|
}
|
|
|
|
RefreshTokensCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? userId,
|
|
Value<String>? jti,
|
|
Value<bool>? isBlacklisted,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? expiresAt}) {
|
|
return RefreshTokensCompanion(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
jti: jti ?? this.jti,
|
|
isBlacklisted: isBlacklisted ?? this.isBlacklisted,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
expiresAt: expiresAt ?? this.expiresAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (jti.present) {
|
|
map['jti'] = Variable<String>(jti.value);
|
|
}
|
|
if (isBlacklisted.present) {
|
|
map['is_blacklisted'] = Variable<bool>(isBlacklisted.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (expiresAt.present) {
|
|
map['expires_at'] = Variable<DateTime>(expiresAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('RefreshTokensCompanion(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('jti: $jti, ')
|
|
..write('isBlacklisted: $isBlacklisted, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('expiresAt: $expiresAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $TelegramAuthCodesTable extends TelegramAuthCodes
|
|
with TableInfo<$TelegramAuthCodesTable, TelegramAuthCode> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$TelegramAuthCodesTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _codeMeta = const VerificationMeta('code');
|
|
@override
|
|
late final GeneratedColumn<String> code = GeneratedColumn<String>(
|
|
'code', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways('UNIQUE'));
|
|
static const VerificationMeta _telegramUserIdMeta =
|
|
const VerificationMeta('telegramUserId');
|
|
@override
|
|
late final GeneratedColumn<String> telegramUserId = GeneratedColumn<String>(
|
|
'telegram_user_id', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _telegramUsernameMeta =
|
|
const VerificationMeta('telegramUsername');
|
|
@override
|
|
late final GeneratedColumn<String> telegramUsername = GeneratedColumn<String>(
|
|
'telegram_username', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _firstNameMeta =
|
|
const VerificationMeta('firstName');
|
|
@override
|
|
late final GeneratedColumn<String> firstName = GeneratedColumn<String>(
|
|
'first_name', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _lastNameMeta =
|
|
const VerificationMeta('lastName');
|
|
@override
|
|
late final GeneratedColumn<String> lastName = GeneratedColumn<String>(
|
|
'last_name', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _isUsedMeta = const VerificationMeta('isUsed');
|
|
@override
|
|
late final GeneratedColumn<bool> isUsed = GeneratedColumn<bool>(
|
|
'is_used', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("is_used" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
static const VerificationMeta _usedAtMeta = const VerificationMeta('usedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> usedAt = GeneratedColumn<DateTime>(
|
|
'used_at', aliasedName, true,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: false);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _expiresAtMeta =
|
|
const VerificationMeta('expiresAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> expiresAt = GeneratedColumn<DateTime>(
|
|
'expires_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
code,
|
|
telegramUserId,
|
|
telegramUsername,
|
|
firstName,
|
|
lastName,
|
|
isUsed,
|
|
usedAt,
|
|
createdAt,
|
|
expiresAt
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'telegram_auth_codes';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<TelegramAuthCode> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('code')) {
|
|
context.handle(
|
|
_codeMeta, code.isAcceptableOrUnknown(data['code']!, _codeMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_codeMeta);
|
|
}
|
|
if (data.containsKey('telegram_user_id')) {
|
|
context.handle(
|
|
_telegramUserIdMeta,
|
|
telegramUserId.isAcceptableOrUnknown(
|
|
data['telegram_user_id']!, _telegramUserIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_telegramUserIdMeta);
|
|
}
|
|
if (data.containsKey('telegram_username')) {
|
|
context.handle(
|
|
_telegramUsernameMeta,
|
|
telegramUsername.isAcceptableOrUnknown(
|
|
data['telegram_username']!, _telegramUsernameMeta));
|
|
}
|
|
if (data.containsKey('first_name')) {
|
|
context.handle(_firstNameMeta,
|
|
firstName.isAcceptableOrUnknown(data['first_name']!, _firstNameMeta));
|
|
}
|
|
if (data.containsKey('last_name')) {
|
|
context.handle(_lastNameMeta,
|
|
lastName.isAcceptableOrUnknown(data['last_name']!, _lastNameMeta));
|
|
}
|
|
if (data.containsKey('is_used')) {
|
|
context.handle(_isUsedMeta,
|
|
isUsed.isAcceptableOrUnknown(data['is_used']!, _isUsedMeta));
|
|
}
|
|
if (data.containsKey('used_at')) {
|
|
context.handle(_usedAtMeta,
|
|
usedAt.isAcceptableOrUnknown(data['used_at']!, _usedAtMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('expires_at')) {
|
|
context.handle(_expiresAtMeta,
|
|
expiresAt.isAcceptableOrUnknown(data['expires_at']!, _expiresAtMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_expiresAtMeta);
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
TelegramAuthCode map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return TelegramAuthCode(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
code: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}code'])!,
|
|
telegramUserId: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.string, data['${effectivePrefix}telegram_user_id'])!,
|
|
telegramUsername: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.string, data['${effectivePrefix}telegram_username']),
|
|
firstName: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}first_name']),
|
|
lastName: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}last_name']),
|
|
isUsed: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_used'])!,
|
|
usedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}used_at']),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
expiresAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}expires_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$TelegramAuthCodesTable createAlias(String alias) {
|
|
return $TelegramAuthCodesTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class TelegramAuthCode extends DataClass
|
|
implements Insertable<TelegramAuthCode> {
|
|
final int id;
|
|
final String code;
|
|
final String telegramUserId;
|
|
final String? telegramUsername;
|
|
final String? firstName;
|
|
final String? lastName;
|
|
final bool isUsed;
|
|
final DateTime? usedAt;
|
|
final DateTime createdAt;
|
|
final DateTime expiresAt;
|
|
const TelegramAuthCode(
|
|
{required this.id,
|
|
required this.code,
|
|
required this.telegramUserId,
|
|
this.telegramUsername,
|
|
this.firstName,
|
|
this.lastName,
|
|
required this.isUsed,
|
|
this.usedAt,
|
|
required this.createdAt,
|
|
required this.expiresAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['code'] = Variable<String>(code);
|
|
map['telegram_user_id'] = Variable<String>(telegramUserId);
|
|
if (!nullToAbsent || telegramUsername != null) {
|
|
map['telegram_username'] = Variable<String>(telegramUsername);
|
|
}
|
|
if (!nullToAbsent || firstName != null) {
|
|
map['first_name'] = Variable<String>(firstName);
|
|
}
|
|
if (!nullToAbsent || lastName != null) {
|
|
map['last_name'] = Variable<String>(lastName);
|
|
}
|
|
map['is_used'] = Variable<bool>(isUsed);
|
|
if (!nullToAbsent || usedAt != null) {
|
|
map['used_at'] = Variable<DateTime>(usedAt);
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['expires_at'] = Variable<DateTime>(expiresAt);
|
|
return map;
|
|
}
|
|
|
|
TelegramAuthCodesCompanion toCompanion(bool nullToAbsent) {
|
|
return TelegramAuthCodesCompanion(
|
|
id: Value(id),
|
|
code: Value(code),
|
|
telegramUserId: Value(telegramUserId),
|
|
telegramUsername: telegramUsername == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(telegramUsername),
|
|
firstName: firstName == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(firstName),
|
|
lastName: lastName == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(lastName),
|
|
isUsed: Value(isUsed),
|
|
usedAt:
|
|
usedAt == null && nullToAbsent ? const Value.absent() : Value(usedAt),
|
|
createdAt: Value(createdAt),
|
|
expiresAt: Value(expiresAt),
|
|
);
|
|
}
|
|
|
|
factory TelegramAuthCode.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return TelegramAuthCode(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
code: serializer.fromJson<String>(json['code']),
|
|
telegramUserId: serializer.fromJson<String>(json['telegramUserId']),
|
|
telegramUsername: serializer.fromJson<String?>(json['telegramUsername']),
|
|
firstName: serializer.fromJson<String?>(json['firstName']),
|
|
lastName: serializer.fromJson<String?>(json['lastName']),
|
|
isUsed: serializer.fromJson<bool>(json['isUsed']),
|
|
usedAt: serializer.fromJson<DateTime?>(json['usedAt']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
expiresAt: serializer.fromJson<DateTime>(json['expiresAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'code': serializer.toJson<String>(code),
|
|
'telegramUserId': serializer.toJson<String>(telegramUserId),
|
|
'telegramUsername': serializer.toJson<String?>(telegramUsername),
|
|
'firstName': serializer.toJson<String?>(firstName),
|
|
'lastName': serializer.toJson<String?>(lastName),
|
|
'isUsed': serializer.toJson<bool>(isUsed),
|
|
'usedAt': serializer.toJson<DateTime?>(usedAt),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'expiresAt': serializer.toJson<DateTime>(expiresAt),
|
|
};
|
|
}
|
|
|
|
TelegramAuthCode copyWith(
|
|
{int? id,
|
|
String? code,
|
|
String? telegramUserId,
|
|
Value<String?> telegramUsername = const Value.absent(),
|
|
Value<String?> firstName = const Value.absent(),
|
|
Value<String?> lastName = const Value.absent(),
|
|
bool? isUsed,
|
|
Value<DateTime?> usedAt = const Value.absent(),
|
|
DateTime? createdAt,
|
|
DateTime? expiresAt}) =>
|
|
TelegramAuthCode(
|
|
id: id ?? this.id,
|
|
code: code ?? this.code,
|
|
telegramUserId: telegramUserId ?? this.telegramUserId,
|
|
telegramUsername: telegramUsername.present
|
|
? telegramUsername.value
|
|
: this.telegramUsername,
|
|
firstName: firstName.present ? firstName.value : this.firstName,
|
|
lastName: lastName.present ? lastName.value : this.lastName,
|
|
isUsed: isUsed ?? this.isUsed,
|
|
usedAt: usedAt.present ? usedAt.value : this.usedAt,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
expiresAt: expiresAt ?? this.expiresAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TelegramAuthCode(')
|
|
..write('id: $id, ')
|
|
..write('code: $code, ')
|
|
..write('telegramUserId: $telegramUserId, ')
|
|
..write('telegramUsername: $telegramUsername, ')
|
|
..write('firstName: $firstName, ')
|
|
..write('lastName: $lastName, ')
|
|
..write('isUsed: $isUsed, ')
|
|
..write('usedAt: $usedAt, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('expiresAt: $expiresAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, code, telegramUserId, telegramUsername,
|
|
firstName, lastName, isUsed, usedAt, createdAt, expiresAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is TelegramAuthCode &&
|
|
other.id == this.id &&
|
|
other.code == this.code &&
|
|
other.telegramUserId == this.telegramUserId &&
|
|
other.telegramUsername == this.telegramUsername &&
|
|
other.firstName == this.firstName &&
|
|
other.lastName == this.lastName &&
|
|
other.isUsed == this.isUsed &&
|
|
other.usedAt == this.usedAt &&
|
|
other.createdAt == this.createdAt &&
|
|
other.expiresAt == this.expiresAt);
|
|
}
|
|
|
|
class TelegramAuthCodesCompanion extends UpdateCompanion<TelegramAuthCode> {
|
|
final Value<int> id;
|
|
final Value<String> code;
|
|
final Value<String> telegramUserId;
|
|
final Value<String?> telegramUsername;
|
|
final Value<String?> firstName;
|
|
final Value<String?> lastName;
|
|
final Value<bool> isUsed;
|
|
final Value<DateTime?> usedAt;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> expiresAt;
|
|
const TelegramAuthCodesCompanion({
|
|
this.id = const Value.absent(),
|
|
this.code = const Value.absent(),
|
|
this.telegramUserId = const Value.absent(),
|
|
this.telegramUsername = const Value.absent(),
|
|
this.firstName = const Value.absent(),
|
|
this.lastName = const Value.absent(),
|
|
this.isUsed = const Value.absent(),
|
|
this.usedAt = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.expiresAt = const Value.absent(),
|
|
});
|
|
TelegramAuthCodesCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String code,
|
|
required String telegramUserId,
|
|
this.telegramUsername = const Value.absent(),
|
|
this.firstName = const Value.absent(),
|
|
this.lastName = const Value.absent(),
|
|
this.isUsed = const Value.absent(),
|
|
this.usedAt = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
required DateTime expiresAt,
|
|
}) : code = Value(code),
|
|
telegramUserId = Value(telegramUserId),
|
|
expiresAt = Value(expiresAt);
|
|
static Insertable<TelegramAuthCode> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? code,
|
|
Expression<String>? telegramUserId,
|
|
Expression<String>? telegramUsername,
|
|
Expression<String>? firstName,
|
|
Expression<String>? lastName,
|
|
Expression<bool>? isUsed,
|
|
Expression<DateTime>? usedAt,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? expiresAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (code != null) 'code': code,
|
|
if (telegramUserId != null) 'telegram_user_id': telegramUserId,
|
|
if (telegramUsername != null) 'telegram_username': telegramUsername,
|
|
if (firstName != null) 'first_name': firstName,
|
|
if (lastName != null) 'last_name': lastName,
|
|
if (isUsed != null) 'is_used': isUsed,
|
|
if (usedAt != null) 'used_at': usedAt,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (expiresAt != null) 'expires_at': expiresAt,
|
|
});
|
|
}
|
|
|
|
TelegramAuthCodesCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String>? code,
|
|
Value<String>? telegramUserId,
|
|
Value<String?>? telegramUsername,
|
|
Value<String?>? firstName,
|
|
Value<String?>? lastName,
|
|
Value<bool>? isUsed,
|
|
Value<DateTime?>? usedAt,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? expiresAt}) {
|
|
return TelegramAuthCodesCompanion(
|
|
id: id ?? this.id,
|
|
code: code ?? this.code,
|
|
telegramUserId: telegramUserId ?? this.telegramUserId,
|
|
telegramUsername: telegramUsername ?? this.telegramUsername,
|
|
firstName: firstName ?? this.firstName,
|
|
lastName: lastName ?? this.lastName,
|
|
isUsed: isUsed ?? this.isUsed,
|
|
usedAt: usedAt ?? this.usedAt,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
expiresAt: expiresAt ?? this.expiresAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (code.present) {
|
|
map['code'] = Variable<String>(code.value);
|
|
}
|
|
if (telegramUserId.present) {
|
|
map['telegram_user_id'] = Variable<String>(telegramUserId.value);
|
|
}
|
|
if (telegramUsername.present) {
|
|
map['telegram_username'] = Variable<String>(telegramUsername.value);
|
|
}
|
|
if (firstName.present) {
|
|
map['first_name'] = Variable<String>(firstName.value);
|
|
}
|
|
if (lastName.present) {
|
|
map['last_name'] = Variable<String>(lastName.value);
|
|
}
|
|
if (isUsed.present) {
|
|
map['is_used'] = Variable<bool>(isUsed.value);
|
|
}
|
|
if (usedAt.present) {
|
|
map['used_at'] = Variable<DateTime>(usedAt.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (expiresAt.present) {
|
|
map['expires_at'] = Variable<DateTime>(expiresAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TelegramAuthCodesCompanion(')
|
|
..write('id: $id, ')
|
|
..write('code: $code, ')
|
|
..write('telegramUserId: $telegramUserId, ')
|
|
..write('telegramUsername: $telegramUsername, ')
|
|
..write('firstName: $firstName, ')
|
|
..write('lastName: $lastName, ')
|
|
..write('isUsed: $isUsed, ')
|
|
..write('usedAt: $usedAt, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('expiresAt: $expiresAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $CardPacksTable extends CardPacks
|
|
with TableInfo<$CardPacksTable, CardPack> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$CardPacksTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _titleMeta = const VerificationMeta('title');
|
|
@override
|
|
late final GeneratedColumn<String> title = GeneratedColumn<String>(
|
|
'title', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _subtitleMeta =
|
|
const VerificationMeta('subtitle');
|
|
@override
|
|
late final GeneratedColumn<String> subtitle = GeneratedColumn<String>(
|
|
'subtitle', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _descriptionMeta =
|
|
const VerificationMeta('description');
|
|
@override
|
|
late final GeneratedColumn<String> description = GeneratedColumn<String>(
|
|
'description', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _colorMeta = const VerificationMeta('color');
|
|
@override
|
|
late final GeneratedColumn<String> color = GeneratedColumn<String>(
|
|
'color', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _coverMeta = const VerificationMeta('cover');
|
|
@override
|
|
late final GeneratedColumn<String> cover = GeneratedColumn<String>(
|
|
'cover', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _sizeMeta = const VerificationMeta('size');
|
|
@override
|
|
late final GeneratedColumn<int> size = GeneratedColumn<int>(
|
|
'size', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _versionMeta =
|
|
const VerificationMeta('version');
|
|
@override
|
|
late final GeneratedColumn<String> version = GeneratedColumn<String>(
|
|
'version', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _orderMeta = const VerificationMeta('order');
|
|
@override
|
|
late final GeneratedColumn<int> order = GeneratedColumn<int>(
|
|
'order', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
static const VerificationMeta _enabledMeta =
|
|
const VerificationMeta('enabled');
|
|
@override
|
|
late final GeneratedColumn<bool> enabled = GeneratedColumn<bool>(
|
|
'enabled', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("enabled" IN (0, 1))'),
|
|
defaultValue: const Constant(true));
|
|
static const VerificationMeta _cardsOrderMeta =
|
|
const VerificationMeta('cardsOrder');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<int>, String> cardsOrder =
|
|
GeneratedColumn<String>('cards_order', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<int>>($CardPacksTable.$convertercardsOrder);
|
|
static const VerificationMeta _googlePlayIdMeta =
|
|
const VerificationMeta('googlePlayId');
|
|
@override
|
|
late final GeneratedColumn<String> googlePlayId = GeneratedColumn<String>(
|
|
'google_play_id', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _rustoreIdMeta =
|
|
const VerificationMeta('rustoreId');
|
|
@override
|
|
late final GeneratedColumn<String> rustoreId = GeneratedColumn<String>(
|
|
'rustore_id', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _appStoreIdMeta =
|
|
const VerificationMeta('appStoreId');
|
|
@override
|
|
late final GeneratedColumn<String> appStoreId = GeneratedColumn<String>(
|
|
'app_store_id', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _priceMeta = const VerificationMeta('price');
|
|
@override
|
|
late final GeneratedColumn<String> price = GeneratedColumn<String>(
|
|
'price', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _currencyMeta =
|
|
const VerificationMeta('currency');
|
|
@override
|
|
late final GeneratedColumn<String> currency = GeneratedColumn<String>(
|
|
'currency', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('RUB'));
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _isDeletedMeta =
|
|
const VerificationMeta('isDeleted');
|
|
@override
|
|
late final GeneratedColumn<bool> isDeleted = GeneratedColumn<bool>(
|
|
'is_deleted', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("is_deleted" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
title,
|
|
subtitle,
|
|
description,
|
|
color,
|
|
cover,
|
|
size,
|
|
version,
|
|
order,
|
|
enabled,
|
|
cardsOrder,
|
|
googlePlayId,
|
|
rustoreId,
|
|
appStoreId,
|
|
price,
|
|
currency,
|
|
createdAt,
|
|
updatedAt,
|
|
isDeleted
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'card_packs';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<CardPack> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('title')) {
|
|
context.handle(
|
|
_titleMeta, title.isAcceptableOrUnknown(data['title']!, _titleMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_titleMeta);
|
|
}
|
|
if (data.containsKey('subtitle')) {
|
|
context.handle(_subtitleMeta,
|
|
subtitle.isAcceptableOrUnknown(data['subtitle']!, _subtitleMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_subtitleMeta);
|
|
}
|
|
if (data.containsKey('description')) {
|
|
context.handle(
|
|
_descriptionMeta,
|
|
description.isAcceptableOrUnknown(
|
|
data['description']!, _descriptionMeta));
|
|
}
|
|
if (data.containsKey('color')) {
|
|
context.handle(
|
|
_colorMeta, color.isAcceptableOrUnknown(data['color']!, _colorMeta));
|
|
}
|
|
if (data.containsKey('cover')) {
|
|
context.handle(
|
|
_coverMeta, cover.isAcceptableOrUnknown(data['cover']!, _coverMeta));
|
|
}
|
|
if (data.containsKey('size')) {
|
|
context.handle(
|
|
_sizeMeta, size.isAcceptableOrUnknown(data['size']!, _sizeMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_sizeMeta);
|
|
}
|
|
if (data.containsKey('version')) {
|
|
context.handle(_versionMeta,
|
|
version.isAcceptableOrUnknown(data['version']!, _versionMeta));
|
|
}
|
|
if (data.containsKey('order')) {
|
|
context.handle(
|
|
_orderMeta, order.isAcceptableOrUnknown(data['order']!, _orderMeta));
|
|
}
|
|
if (data.containsKey('enabled')) {
|
|
context.handle(_enabledMeta,
|
|
enabled.isAcceptableOrUnknown(data['enabled']!, _enabledMeta));
|
|
}
|
|
context.handle(_cardsOrderMeta, const VerificationResult.success());
|
|
if (data.containsKey('google_play_id')) {
|
|
context.handle(
|
|
_googlePlayIdMeta,
|
|
googlePlayId.isAcceptableOrUnknown(
|
|
data['google_play_id']!, _googlePlayIdMeta));
|
|
}
|
|
if (data.containsKey('rustore_id')) {
|
|
context.handle(_rustoreIdMeta,
|
|
rustoreId.isAcceptableOrUnknown(data['rustore_id']!, _rustoreIdMeta));
|
|
}
|
|
if (data.containsKey('app_store_id')) {
|
|
context.handle(
|
|
_appStoreIdMeta,
|
|
appStoreId.isAcceptableOrUnknown(
|
|
data['app_store_id']!, _appStoreIdMeta));
|
|
}
|
|
if (data.containsKey('price')) {
|
|
context.handle(
|
|
_priceMeta, price.isAcceptableOrUnknown(data['price']!, _priceMeta));
|
|
}
|
|
if (data.containsKey('currency')) {
|
|
context.handle(_currencyMeta,
|
|
currency.isAcceptableOrUnknown(data['currency']!, _currencyMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
if (data.containsKey('is_deleted')) {
|
|
context.handle(_isDeletedMeta,
|
|
isDeleted.isAcceptableOrUnknown(data['is_deleted']!, _isDeletedMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
CardPack map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return CardPack(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
title: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
|
subtitle: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}subtitle'])!,
|
|
description: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}description']),
|
|
color: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}color']),
|
|
cover: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}cover']),
|
|
size: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}size'])!,
|
|
version: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}version']),
|
|
order: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}order'])!,
|
|
enabled: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}enabled'])!,
|
|
cardsOrder: $CardPacksTable.$convertercardsOrder.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}cards_order'])!),
|
|
googlePlayId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}google_play_id']),
|
|
rustoreId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}rustore_id']),
|
|
appStoreId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}app_store_id']),
|
|
price: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}price']),
|
|
currency: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}currency'])!,
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
isDeleted: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_deleted'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$CardPacksTable createAlias(String alias) {
|
|
return $CardPacksTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<List<int>, String> $convertercardsOrder =
|
|
const IntListConverter();
|
|
}
|
|
|
|
class CardPack extends DataClass implements Insertable<CardPack> {
|
|
final int id;
|
|
final String title;
|
|
final String subtitle;
|
|
final String? description;
|
|
final String? color;
|
|
final String? cover;
|
|
final int size;
|
|
final String? version;
|
|
final int order;
|
|
final bool enabled;
|
|
final List<int> cardsOrder;
|
|
final String? googlePlayId;
|
|
final String? rustoreId;
|
|
final String? appStoreId;
|
|
final String? price;
|
|
final String currency;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
final bool isDeleted;
|
|
const CardPack(
|
|
{required this.id,
|
|
required this.title,
|
|
required this.subtitle,
|
|
this.description,
|
|
this.color,
|
|
this.cover,
|
|
required this.size,
|
|
this.version,
|
|
required this.order,
|
|
required this.enabled,
|
|
required this.cardsOrder,
|
|
this.googlePlayId,
|
|
this.rustoreId,
|
|
this.appStoreId,
|
|
this.price,
|
|
required this.currency,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.isDeleted});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['title'] = Variable<String>(title);
|
|
map['subtitle'] = Variable<String>(subtitle);
|
|
if (!nullToAbsent || description != null) {
|
|
map['description'] = Variable<String>(description);
|
|
}
|
|
if (!nullToAbsent || color != null) {
|
|
map['color'] = Variable<String>(color);
|
|
}
|
|
if (!nullToAbsent || cover != null) {
|
|
map['cover'] = Variable<String>(cover);
|
|
}
|
|
map['size'] = Variable<int>(size);
|
|
if (!nullToAbsent || version != null) {
|
|
map['version'] = Variable<String>(version);
|
|
}
|
|
map['order'] = Variable<int>(order);
|
|
map['enabled'] = Variable<bool>(enabled);
|
|
{
|
|
map['cards_order'] = Variable<String>(
|
|
$CardPacksTable.$convertercardsOrder.toSql(cardsOrder));
|
|
}
|
|
if (!nullToAbsent || googlePlayId != null) {
|
|
map['google_play_id'] = Variable<String>(googlePlayId);
|
|
}
|
|
if (!nullToAbsent || rustoreId != null) {
|
|
map['rustore_id'] = Variable<String>(rustoreId);
|
|
}
|
|
if (!nullToAbsent || appStoreId != null) {
|
|
map['app_store_id'] = Variable<String>(appStoreId);
|
|
}
|
|
if (!nullToAbsent || price != null) {
|
|
map['price'] = Variable<String>(price);
|
|
}
|
|
map['currency'] = Variable<String>(currency);
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
map['is_deleted'] = Variable<bool>(isDeleted);
|
|
return map;
|
|
}
|
|
|
|
CardPacksCompanion toCompanion(bool nullToAbsent) {
|
|
return CardPacksCompanion(
|
|
id: Value(id),
|
|
title: Value(title),
|
|
subtitle: Value(subtitle),
|
|
description: description == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(description),
|
|
color:
|
|
color == null && nullToAbsent ? const Value.absent() : Value(color),
|
|
cover:
|
|
cover == null && nullToAbsent ? const Value.absent() : Value(cover),
|
|
size: Value(size),
|
|
version: version == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(version),
|
|
order: Value(order),
|
|
enabled: Value(enabled),
|
|
cardsOrder: Value(cardsOrder),
|
|
googlePlayId: googlePlayId == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(googlePlayId),
|
|
rustoreId: rustoreId == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(rustoreId),
|
|
appStoreId: appStoreId == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(appStoreId),
|
|
price:
|
|
price == null && nullToAbsent ? const Value.absent() : Value(price),
|
|
currency: Value(currency),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
isDeleted: Value(isDeleted),
|
|
);
|
|
}
|
|
|
|
factory CardPack.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return CardPack(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
title: serializer.fromJson<String>(json['title']),
|
|
subtitle: serializer.fromJson<String>(json['subtitle']),
|
|
description: serializer.fromJson<String?>(json['description']),
|
|
color: serializer.fromJson<String?>(json['color']),
|
|
cover: serializer.fromJson<String?>(json['cover']),
|
|
size: serializer.fromJson<int>(json['size']),
|
|
version: serializer.fromJson<String?>(json['version']),
|
|
order: serializer.fromJson<int>(json['order']),
|
|
enabled: serializer.fromJson<bool>(json['enabled']),
|
|
cardsOrder: serializer.fromJson<List<int>>(json['cardsOrder']),
|
|
googlePlayId: serializer.fromJson<String?>(json['googlePlayId']),
|
|
rustoreId: serializer.fromJson<String?>(json['rustoreId']),
|
|
appStoreId: serializer.fromJson<String?>(json['appStoreId']),
|
|
price: serializer.fromJson<String?>(json['price']),
|
|
currency: serializer.fromJson<String>(json['currency']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
isDeleted: serializer.fromJson<bool>(json['isDeleted']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'title': serializer.toJson<String>(title),
|
|
'subtitle': serializer.toJson<String>(subtitle),
|
|
'description': serializer.toJson<String?>(description),
|
|
'color': serializer.toJson<String?>(color),
|
|
'cover': serializer.toJson<String?>(cover),
|
|
'size': serializer.toJson<int>(size),
|
|
'version': serializer.toJson<String?>(version),
|
|
'order': serializer.toJson<int>(order),
|
|
'enabled': serializer.toJson<bool>(enabled),
|
|
'cardsOrder': serializer.toJson<List<int>>(cardsOrder),
|
|
'googlePlayId': serializer.toJson<String?>(googlePlayId),
|
|
'rustoreId': serializer.toJson<String?>(rustoreId),
|
|
'appStoreId': serializer.toJson<String?>(appStoreId),
|
|
'price': serializer.toJson<String?>(price),
|
|
'currency': serializer.toJson<String>(currency),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
'isDeleted': serializer.toJson<bool>(isDeleted),
|
|
};
|
|
}
|
|
|
|
CardPack copyWith(
|
|
{int? id,
|
|
String? title,
|
|
String? subtitle,
|
|
Value<String?> description = const Value.absent(),
|
|
Value<String?> color = const Value.absent(),
|
|
Value<String?> cover = const Value.absent(),
|
|
int? size,
|
|
Value<String?> version = const Value.absent(),
|
|
int? order,
|
|
bool? enabled,
|
|
List<int>? cardsOrder,
|
|
Value<String?> googlePlayId = const Value.absent(),
|
|
Value<String?> rustoreId = const Value.absent(),
|
|
Value<String?> appStoreId = const Value.absent(),
|
|
Value<String?> price = const Value.absent(),
|
|
String? currency,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
bool? isDeleted}) =>
|
|
CardPack(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
subtitle: subtitle ?? this.subtitle,
|
|
description: description.present ? description.value : this.description,
|
|
color: color.present ? color.value : this.color,
|
|
cover: cover.present ? cover.value : this.cover,
|
|
size: size ?? this.size,
|
|
version: version.present ? version.value : this.version,
|
|
order: order ?? this.order,
|
|
enabled: enabled ?? this.enabled,
|
|
cardsOrder: cardsOrder ?? this.cardsOrder,
|
|
googlePlayId:
|
|
googlePlayId.present ? googlePlayId.value : this.googlePlayId,
|
|
rustoreId: rustoreId.present ? rustoreId.value : this.rustoreId,
|
|
appStoreId: appStoreId.present ? appStoreId.value : this.appStoreId,
|
|
price: price.present ? price.value : this.price,
|
|
currency: currency ?? this.currency,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('CardPack(')
|
|
..write('id: $id, ')
|
|
..write('title: $title, ')
|
|
..write('subtitle: $subtitle, ')
|
|
..write('description: $description, ')
|
|
..write('color: $color, ')
|
|
..write('cover: $cover, ')
|
|
..write('size: $size, ')
|
|
..write('version: $version, ')
|
|
..write('order: $order, ')
|
|
..write('enabled: $enabled, ')
|
|
..write('cardsOrder: $cardsOrder, ')
|
|
..write('googlePlayId: $googlePlayId, ')
|
|
..write('rustoreId: $rustoreId, ')
|
|
..write('appStoreId: $appStoreId, ')
|
|
..write('price: $price, ')
|
|
..write('currency: $currency, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id,
|
|
title,
|
|
subtitle,
|
|
description,
|
|
color,
|
|
cover,
|
|
size,
|
|
version,
|
|
order,
|
|
enabled,
|
|
cardsOrder,
|
|
googlePlayId,
|
|
rustoreId,
|
|
appStoreId,
|
|
price,
|
|
currency,
|
|
createdAt,
|
|
updatedAt,
|
|
isDeleted);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is CardPack &&
|
|
other.id == this.id &&
|
|
other.title == this.title &&
|
|
other.subtitle == this.subtitle &&
|
|
other.description == this.description &&
|
|
other.color == this.color &&
|
|
other.cover == this.cover &&
|
|
other.size == this.size &&
|
|
other.version == this.version &&
|
|
other.order == this.order &&
|
|
other.enabled == this.enabled &&
|
|
other.cardsOrder == this.cardsOrder &&
|
|
other.googlePlayId == this.googlePlayId &&
|
|
other.rustoreId == this.rustoreId &&
|
|
other.appStoreId == this.appStoreId &&
|
|
other.price == this.price &&
|
|
other.currency == this.currency &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt &&
|
|
other.isDeleted == this.isDeleted);
|
|
}
|
|
|
|
class CardPacksCompanion extends UpdateCompanion<CardPack> {
|
|
final Value<int> id;
|
|
final Value<String> title;
|
|
final Value<String> subtitle;
|
|
final Value<String?> description;
|
|
final Value<String?> color;
|
|
final Value<String?> cover;
|
|
final Value<int> size;
|
|
final Value<String?> version;
|
|
final Value<int> order;
|
|
final Value<bool> enabled;
|
|
final Value<List<int>> cardsOrder;
|
|
final Value<String?> googlePlayId;
|
|
final Value<String?> rustoreId;
|
|
final Value<String?> appStoreId;
|
|
final Value<String?> price;
|
|
final Value<String> currency;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
final Value<bool> isDeleted;
|
|
const CardPacksCompanion({
|
|
this.id = const Value.absent(),
|
|
this.title = const Value.absent(),
|
|
this.subtitle = const Value.absent(),
|
|
this.description = const Value.absent(),
|
|
this.color = const Value.absent(),
|
|
this.cover = const Value.absent(),
|
|
this.size = const Value.absent(),
|
|
this.version = const Value.absent(),
|
|
this.order = const Value.absent(),
|
|
this.enabled = const Value.absent(),
|
|
this.cardsOrder = const Value.absent(),
|
|
this.googlePlayId = const Value.absent(),
|
|
this.rustoreId = const Value.absent(),
|
|
this.appStoreId = const Value.absent(),
|
|
this.price = const Value.absent(),
|
|
this.currency = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
});
|
|
CardPacksCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String title,
|
|
required String subtitle,
|
|
this.description = const Value.absent(),
|
|
this.color = const Value.absent(),
|
|
this.cover = const Value.absent(),
|
|
required int size,
|
|
this.version = const Value.absent(),
|
|
this.order = const Value.absent(),
|
|
this.enabled = const Value.absent(),
|
|
this.cardsOrder = const Value.absent(),
|
|
this.googlePlayId = const Value.absent(),
|
|
this.rustoreId = const Value.absent(),
|
|
this.appStoreId = const Value.absent(),
|
|
this.price = const Value.absent(),
|
|
this.currency = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
}) : title = Value(title),
|
|
subtitle = Value(subtitle),
|
|
size = Value(size);
|
|
static Insertable<CardPack> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? title,
|
|
Expression<String>? subtitle,
|
|
Expression<String>? description,
|
|
Expression<String>? color,
|
|
Expression<String>? cover,
|
|
Expression<int>? size,
|
|
Expression<String>? version,
|
|
Expression<int>? order,
|
|
Expression<bool>? enabled,
|
|
Expression<String>? cardsOrder,
|
|
Expression<String>? googlePlayId,
|
|
Expression<String>? rustoreId,
|
|
Expression<String>? appStoreId,
|
|
Expression<String>? price,
|
|
Expression<String>? currency,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
Expression<bool>? isDeleted,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (title != null) 'title': title,
|
|
if (subtitle != null) 'subtitle': subtitle,
|
|
if (description != null) 'description': description,
|
|
if (color != null) 'color': color,
|
|
if (cover != null) 'cover': cover,
|
|
if (size != null) 'size': size,
|
|
if (version != null) 'version': version,
|
|
if (order != null) 'order': order,
|
|
if (enabled != null) 'enabled': enabled,
|
|
if (cardsOrder != null) 'cards_order': cardsOrder,
|
|
if (googlePlayId != null) 'google_play_id': googlePlayId,
|
|
if (rustoreId != null) 'rustore_id': rustoreId,
|
|
if (appStoreId != null) 'app_store_id': appStoreId,
|
|
if (price != null) 'price': price,
|
|
if (currency != null) 'currency': currency,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
if (isDeleted != null) 'is_deleted': isDeleted,
|
|
});
|
|
}
|
|
|
|
CardPacksCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String>? title,
|
|
Value<String>? subtitle,
|
|
Value<String?>? description,
|
|
Value<String?>? color,
|
|
Value<String?>? cover,
|
|
Value<int>? size,
|
|
Value<String?>? version,
|
|
Value<int>? order,
|
|
Value<bool>? enabled,
|
|
Value<List<int>>? cardsOrder,
|
|
Value<String?>? googlePlayId,
|
|
Value<String?>? rustoreId,
|
|
Value<String?>? appStoreId,
|
|
Value<String?>? price,
|
|
Value<String>? currency,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt,
|
|
Value<bool>? isDeleted}) {
|
|
return CardPacksCompanion(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
subtitle: subtitle ?? this.subtitle,
|
|
description: description ?? this.description,
|
|
color: color ?? this.color,
|
|
cover: cover ?? this.cover,
|
|
size: size ?? this.size,
|
|
version: version ?? this.version,
|
|
order: order ?? this.order,
|
|
enabled: enabled ?? this.enabled,
|
|
cardsOrder: cardsOrder ?? this.cardsOrder,
|
|
googlePlayId: googlePlayId ?? this.googlePlayId,
|
|
rustoreId: rustoreId ?? this.rustoreId,
|
|
appStoreId: appStoreId ?? this.appStoreId,
|
|
price: price ?? this.price,
|
|
currency: currency ?? this.currency,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (title.present) {
|
|
map['title'] = Variable<String>(title.value);
|
|
}
|
|
if (subtitle.present) {
|
|
map['subtitle'] = Variable<String>(subtitle.value);
|
|
}
|
|
if (description.present) {
|
|
map['description'] = Variable<String>(description.value);
|
|
}
|
|
if (color.present) {
|
|
map['color'] = Variable<String>(color.value);
|
|
}
|
|
if (cover.present) {
|
|
map['cover'] = Variable<String>(cover.value);
|
|
}
|
|
if (size.present) {
|
|
map['size'] = Variable<int>(size.value);
|
|
}
|
|
if (version.present) {
|
|
map['version'] = Variable<String>(version.value);
|
|
}
|
|
if (order.present) {
|
|
map['order'] = Variable<int>(order.value);
|
|
}
|
|
if (enabled.present) {
|
|
map['enabled'] = Variable<bool>(enabled.value);
|
|
}
|
|
if (cardsOrder.present) {
|
|
map['cards_order'] = Variable<String>(
|
|
$CardPacksTable.$convertercardsOrder.toSql(cardsOrder.value));
|
|
}
|
|
if (googlePlayId.present) {
|
|
map['google_play_id'] = Variable<String>(googlePlayId.value);
|
|
}
|
|
if (rustoreId.present) {
|
|
map['rustore_id'] = Variable<String>(rustoreId.value);
|
|
}
|
|
if (appStoreId.present) {
|
|
map['app_store_id'] = Variable<String>(appStoreId.value);
|
|
}
|
|
if (price.present) {
|
|
map['price'] = Variable<String>(price.value);
|
|
}
|
|
if (currency.present) {
|
|
map['currency'] = Variable<String>(currency.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
if (isDeleted.present) {
|
|
map['is_deleted'] = Variable<bool>(isDeleted.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('CardPacksCompanion(')
|
|
..write('id: $id, ')
|
|
..write('title: $title, ')
|
|
..write('subtitle: $subtitle, ')
|
|
..write('description: $description, ')
|
|
..write('color: $color, ')
|
|
..write('cover: $cover, ')
|
|
..write('size: $size, ')
|
|
..write('version: $version, ')
|
|
..write('order: $order, ')
|
|
..write('enabled: $enabled, ')
|
|
..write('cardsOrder: $cardsOrder, ')
|
|
..write('googlePlayId: $googlePlayId, ')
|
|
..write('rustoreId: $rustoreId, ')
|
|
..write('appStoreId: $appStoreId, ')
|
|
..write('price: $price, ')
|
|
..write('currency: $currency, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $GameCardsTable extends GameCards
|
|
with TableInfo<$GameCardsTable, GameCard> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$GameCardsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _packIdMeta = const VerificationMeta('packId');
|
|
@override
|
|
late final GeneratedColumn<int> packId = GeneratedColumn<int>(
|
|
'pack_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES card_packs (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _originalMeta =
|
|
const VerificationMeta('original');
|
|
@override
|
|
late final GeneratedColumn<String> original = GeneratedColumn<String>(
|
|
'original', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _translationMeta =
|
|
const VerificationMeta('translation');
|
|
@override
|
|
late final GeneratedColumn<String> translation = GeneratedColumn<String>(
|
|
'translation', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _mnemoMeta = const VerificationMeta('mnemo');
|
|
@override
|
|
late final GeneratedColumn<String> mnemo = GeneratedColumn<String>(
|
|
'mnemo', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _imageMeta = const VerificationMeta('image');
|
|
@override
|
|
late final GeneratedColumn<String> image = GeneratedColumn<String>(
|
|
'image', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _imageBackMeta =
|
|
const VerificationMeta('imageBack');
|
|
@override
|
|
late final GeneratedColumn<String> imageBack = GeneratedColumn<String>(
|
|
'image_back', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _transcriptionMeta =
|
|
const VerificationMeta('transcription');
|
|
@override
|
|
late final GeneratedColumn<String> transcription = GeneratedColumn<String>(
|
|
'transcription', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _transcriptionMnemoMeta =
|
|
const VerificationMeta('transcriptionMnemo');
|
|
@override
|
|
late final GeneratedColumn<String> transcriptionMnemo =
|
|
GeneratedColumn<String>('transcription_mnemo', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _backMeta = const VerificationMeta('back');
|
|
@override
|
|
late final GeneratedColumn<String> back = GeneratedColumn<String>(
|
|
'back', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _isDeletedMeta =
|
|
const VerificationMeta('isDeleted');
|
|
@override
|
|
late final GeneratedColumn<bool> isDeleted = GeneratedColumn<bool>(
|
|
'is_deleted', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("is_deleted" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
packId,
|
|
original,
|
|
translation,
|
|
mnemo,
|
|
image,
|
|
imageBack,
|
|
transcription,
|
|
transcriptionMnemo,
|
|
back,
|
|
createdAt,
|
|
updatedAt,
|
|
isDeleted
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'game_cards';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<GameCard> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('pack_id')) {
|
|
context.handle(_packIdMeta,
|
|
packId.isAcceptableOrUnknown(data['pack_id']!, _packIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_packIdMeta);
|
|
}
|
|
if (data.containsKey('original')) {
|
|
context.handle(_originalMeta,
|
|
original.isAcceptableOrUnknown(data['original']!, _originalMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_originalMeta);
|
|
}
|
|
if (data.containsKey('translation')) {
|
|
context.handle(
|
|
_translationMeta,
|
|
translation.isAcceptableOrUnknown(
|
|
data['translation']!, _translationMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_translationMeta);
|
|
}
|
|
if (data.containsKey('mnemo')) {
|
|
context.handle(
|
|
_mnemoMeta, mnemo.isAcceptableOrUnknown(data['mnemo']!, _mnemoMeta));
|
|
}
|
|
if (data.containsKey('image')) {
|
|
context.handle(
|
|
_imageMeta, image.isAcceptableOrUnknown(data['image']!, _imageMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_imageMeta);
|
|
}
|
|
if (data.containsKey('image_back')) {
|
|
context.handle(_imageBackMeta,
|
|
imageBack.isAcceptableOrUnknown(data['image_back']!, _imageBackMeta));
|
|
}
|
|
if (data.containsKey('transcription')) {
|
|
context.handle(
|
|
_transcriptionMeta,
|
|
transcription.isAcceptableOrUnknown(
|
|
data['transcription']!, _transcriptionMeta));
|
|
}
|
|
if (data.containsKey('transcription_mnemo')) {
|
|
context.handle(
|
|
_transcriptionMnemoMeta,
|
|
transcriptionMnemo.isAcceptableOrUnknown(
|
|
data['transcription_mnemo']!, _transcriptionMnemoMeta));
|
|
}
|
|
if (data.containsKey('back')) {
|
|
context.handle(
|
|
_backMeta, back.isAcceptableOrUnknown(data['back']!, _backMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
if (data.containsKey('is_deleted')) {
|
|
context.handle(_isDeletedMeta,
|
|
isDeleted.isAcceptableOrUnknown(data['is_deleted']!, _isDeletedMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
GameCard map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return GameCard(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
packId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}pack_id'])!,
|
|
original: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}original'])!,
|
|
translation: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}translation'])!,
|
|
mnemo: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}mnemo']),
|
|
image: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}image'])!,
|
|
imageBack: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}image_back']),
|
|
transcription: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}transcription']),
|
|
transcriptionMnemo: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.string, data['${effectivePrefix}transcription_mnemo']),
|
|
back: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}back']),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
isDeleted: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_deleted'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$GameCardsTable createAlias(String alias) {
|
|
return $GameCardsTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class GameCard extends DataClass implements Insertable<GameCard> {
|
|
final int id;
|
|
final int packId;
|
|
final String original;
|
|
final String translation;
|
|
final String? mnemo;
|
|
final String image;
|
|
final String? imageBack;
|
|
final String? transcription;
|
|
final String? transcriptionMnemo;
|
|
final String? back;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
final bool isDeleted;
|
|
const GameCard(
|
|
{required this.id,
|
|
required this.packId,
|
|
required this.original,
|
|
required this.translation,
|
|
this.mnemo,
|
|
required this.image,
|
|
this.imageBack,
|
|
this.transcription,
|
|
this.transcriptionMnemo,
|
|
this.back,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.isDeleted});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['pack_id'] = Variable<int>(packId);
|
|
map['original'] = Variable<String>(original);
|
|
map['translation'] = Variable<String>(translation);
|
|
if (!nullToAbsent || mnemo != null) {
|
|
map['mnemo'] = Variable<String>(mnemo);
|
|
}
|
|
map['image'] = Variable<String>(image);
|
|
if (!nullToAbsent || imageBack != null) {
|
|
map['image_back'] = Variable<String>(imageBack);
|
|
}
|
|
if (!nullToAbsent || transcription != null) {
|
|
map['transcription'] = Variable<String>(transcription);
|
|
}
|
|
if (!nullToAbsent || transcriptionMnemo != null) {
|
|
map['transcription_mnemo'] = Variable<String>(transcriptionMnemo);
|
|
}
|
|
if (!nullToAbsent || back != null) {
|
|
map['back'] = Variable<String>(back);
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
map['is_deleted'] = Variable<bool>(isDeleted);
|
|
return map;
|
|
}
|
|
|
|
GameCardsCompanion toCompanion(bool nullToAbsent) {
|
|
return GameCardsCompanion(
|
|
id: Value(id),
|
|
packId: Value(packId),
|
|
original: Value(original),
|
|
translation: Value(translation),
|
|
mnemo:
|
|
mnemo == null && nullToAbsent ? const Value.absent() : Value(mnemo),
|
|
image: Value(image),
|
|
imageBack: imageBack == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(imageBack),
|
|
transcription: transcription == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(transcription),
|
|
transcriptionMnemo: transcriptionMnemo == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(transcriptionMnemo),
|
|
back: back == null && nullToAbsent ? const Value.absent() : Value(back),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
isDeleted: Value(isDeleted),
|
|
);
|
|
}
|
|
|
|
factory GameCard.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return GameCard(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
packId: serializer.fromJson<int>(json['packId']),
|
|
original: serializer.fromJson<String>(json['original']),
|
|
translation: serializer.fromJson<String>(json['translation']),
|
|
mnemo: serializer.fromJson<String?>(json['mnemo']),
|
|
image: serializer.fromJson<String>(json['image']),
|
|
imageBack: serializer.fromJson<String?>(json['imageBack']),
|
|
transcription: serializer.fromJson<String?>(json['transcription']),
|
|
transcriptionMnemo:
|
|
serializer.fromJson<String?>(json['transcriptionMnemo']),
|
|
back: serializer.fromJson<String?>(json['back']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
isDeleted: serializer.fromJson<bool>(json['isDeleted']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'packId': serializer.toJson<int>(packId),
|
|
'original': serializer.toJson<String>(original),
|
|
'translation': serializer.toJson<String>(translation),
|
|
'mnemo': serializer.toJson<String?>(mnemo),
|
|
'image': serializer.toJson<String>(image),
|
|
'imageBack': serializer.toJson<String?>(imageBack),
|
|
'transcription': serializer.toJson<String?>(transcription),
|
|
'transcriptionMnemo': serializer.toJson<String?>(transcriptionMnemo),
|
|
'back': serializer.toJson<String?>(back),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
'isDeleted': serializer.toJson<bool>(isDeleted),
|
|
};
|
|
}
|
|
|
|
GameCard copyWith(
|
|
{int? id,
|
|
int? packId,
|
|
String? original,
|
|
String? translation,
|
|
Value<String?> mnemo = const Value.absent(),
|
|
String? image,
|
|
Value<String?> imageBack = const Value.absent(),
|
|
Value<String?> transcription = const Value.absent(),
|
|
Value<String?> transcriptionMnemo = const Value.absent(),
|
|
Value<String?> back = const Value.absent(),
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
bool? isDeleted}) =>
|
|
GameCard(
|
|
id: id ?? this.id,
|
|
packId: packId ?? this.packId,
|
|
original: original ?? this.original,
|
|
translation: translation ?? this.translation,
|
|
mnemo: mnemo.present ? mnemo.value : this.mnemo,
|
|
image: image ?? this.image,
|
|
imageBack: imageBack.present ? imageBack.value : this.imageBack,
|
|
transcription:
|
|
transcription.present ? transcription.value : this.transcription,
|
|
transcriptionMnemo: transcriptionMnemo.present
|
|
? transcriptionMnemo.value
|
|
: this.transcriptionMnemo,
|
|
back: back.present ? back.value : this.back,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('GameCard(')
|
|
..write('id: $id, ')
|
|
..write('packId: $packId, ')
|
|
..write('original: $original, ')
|
|
..write('translation: $translation, ')
|
|
..write('mnemo: $mnemo, ')
|
|
..write('image: $image, ')
|
|
..write('imageBack: $imageBack, ')
|
|
..write('transcription: $transcription, ')
|
|
..write('transcriptionMnemo: $transcriptionMnemo, ')
|
|
..write('back: $back, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id,
|
|
packId,
|
|
original,
|
|
translation,
|
|
mnemo,
|
|
image,
|
|
imageBack,
|
|
transcription,
|
|
transcriptionMnemo,
|
|
back,
|
|
createdAt,
|
|
updatedAt,
|
|
isDeleted);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is GameCard &&
|
|
other.id == this.id &&
|
|
other.packId == this.packId &&
|
|
other.original == this.original &&
|
|
other.translation == this.translation &&
|
|
other.mnemo == this.mnemo &&
|
|
other.image == this.image &&
|
|
other.imageBack == this.imageBack &&
|
|
other.transcription == this.transcription &&
|
|
other.transcriptionMnemo == this.transcriptionMnemo &&
|
|
other.back == this.back &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt &&
|
|
other.isDeleted == this.isDeleted);
|
|
}
|
|
|
|
class GameCardsCompanion extends UpdateCompanion<GameCard> {
|
|
final Value<int> id;
|
|
final Value<int> packId;
|
|
final Value<String> original;
|
|
final Value<String> translation;
|
|
final Value<String?> mnemo;
|
|
final Value<String> image;
|
|
final Value<String?> imageBack;
|
|
final Value<String?> transcription;
|
|
final Value<String?> transcriptionMnemo;
|
|
final Value<String?> back;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
final Value<bool> isDeleted;
|
|
const GameCardsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.packId = const Value.absent(),
|
|
this.original = const Value.absent(),
|
|
this.translation = const Value.absent(),
|
|
this.mnemo = const Value.absent(),
|
|
this.image = const Value.absent(),
|
|
this.imageBack = const Value.absent(),
|
|
this.transcription = const Value.absent(),
|
|
this.transcriptionMnemo = const Value.absent(),
|
|
this.back = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
});
|
|
GameCardsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int packId,
|
|
required String original,
|
|
required String translation,
|
|
this.mnemo = const Value.absent(),
|
|
required String image,
|
|
this.imageBack = const Value.absent(),
|
|
this.transcription = const Value.absent(),
|
|
this.transcriptionMnemo = const Value.absent(),
|
|
this.back = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
}) : packId = Value(packId),
|
|
original = Value(original),
|
|
translation = Value(translation),
|
|
image = Value(image);
|
|
static Insertable<GameCard> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? packId,
|
|
Expression<String>? original,
|
|
Expression<String>? translation,
|
|
Expression<String>? mnemo,
|
|
Expression<String>? image,
|
|
Expression<String>? imageBack,
|
|
Expression<String>? transcription,
|
|
Expression<String>? transcriptionMnemo,
|
|
Expression<String>? back,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
Expression<bool>? isDeleted,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (packId != null) 'pack_id': packId,
|
|
if (original != null) 'original': original,
|
|
if (translation != null) 'translation': translation,
|
|
if (mnemo != null) 'mnemo': mnemo,
|
|
if (image != null) 'image': image,
|
|
if (imageBack != null) 'image_back': imageBack,
|
|
if (transcription != null) 'transcription': transcription,
|
|
if (transcriptionMnemo != null) 'transcription_mnemo': transcriptionMnemo,
|
|
if (back != null) 'back': back,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
if (isDeleted != null) 'is_deleted': isDeleted,
|
|
});
|
|
}
|
|
|
|
GameCardsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? packId,
|
|
Value<String>? original,
|
|
Value<String>? translation,
|
|
Value<String?>? mnemo,
|
|
Value<String>? image,
|
|
Value<String?>? imageBack,
|
|
Value<String?>? transcription,
|
|
Value<String?>? transcriptionMnemo,
|
|
Value<String?>? back,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt,
|
|
Value<bool>? isDeleted}) {
|
|
return GameCardsCompanion(
|
|
id: id ?? this.id,
|
|
packId: packId ?? this.packId,
|
|
original: original ?? this.original,
|
|
translation: translation ?? this.translation,
|
|
mnemo: mnemo ?? this.mnemo,
|
|
image: image ?? this.image,
|
|
imageBack: imageBack ?? this.imageBack,
|
|
transcription: transcription ?? this.transcription,
|
|
transcriptionMnemo: transcriptionMnemo ?? this.transcriptionMnemo,
|
|
back: back ?? this.back,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (packId.present) {
|
|
map['pack_id'] = Variable<int>(packId.value);
|
|
}
|
|
if (original.present) {
|
|
map['original'] = Variable<String>(original.value);
|
|
}
|
|
if (translation.present) {
|
|
map['translation'] = Variable<String>(translation.value);
|
|
}
|
|
if (mnemo.present) {
|
|
map['mnemo'] = Variable<String>(mnemo.value);
|
|
}
|
|
if (image.present) {
|
|
map['image'] = Variable<String>(image.value);
|
|
}
|
|
if (imageBack.present) {
|
|
map['image_back'] = Variable<String>(imageBack.value);
|
|
}
|
|
if (transcription.present) {
|
|
map['transcription'] = Variable<String>(transcription.value);
|
|
}
|
|
if (transcriptionMnemo.present) {
|
|
map['transcription_mnemo'] = Variable<String>(transcriptionMnemo.value);
|
|
}
|
|
if (back.present) {
|
|
map['back'] = Variable<String>(back.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
if (isDeleted.present) {
|
|
map['is_deleted'] = Variable<bool>(isDeleted.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('GameCardsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('packId: $packId, ')
|
|
..write('original: $original, ')
|
|
..write('translation: $translation, ')
|
|
..write('mnemo: $mnemo, ')
|
|
..write('image: $image, ')
|
|
..write('imageBack: $imageBack, ')
|
|
..write('transcription: $transcription, ')
|
|
..write('transcriptionMnemo: $transcriptionMnemo, ')
|
|
..write('back: $back, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $VoiceModelsTable extends VoiceModels
|
|
with TableInfo<$VoiceModelsTable, VoiceModel> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$VoiceModelsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _cardIdMeta = const VerificationMeta('cardId');
|
|
@override
|
|
late final GeneratedColumn<int> cardId = GeneratedColumn<int>(
|
|
'card_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES game_cards (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _voiceUrlMeta =
|
|
const VerificationMeta('voiceUrl');
|
|
@override
|
|
late final GeneratedColumn<String> voiceUrl = GeneratedColumn<String>(
|
|
'voice_url', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _languageMeta =
|
|
const VerificationMeta('language');
|
|
@override
|
|
late final GeneratedColumn<String> language = GeneratedColumn<String>(
|
|
'language', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, cardId, voiceUrl, language, createdAt];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'voice_models';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<VoiceModel> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('card_id')) {
|
|
context.handle(_cardIdMeta,
|
|
cardId.isAcceptableOrUnknown(data['card_id']!, _cardIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_cardIdMeta);
|
|
}
|
|
if (data.containsKey('voice_url')) {
|
|
context.handle(_voiceUrlMeta,
|
|
voiceUrl.isAcceptableOrUnknown(data['voice_url']!, _voiceUrlMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_voiceUrlMeta);
|
|
}
|
|
if (data.containsKey('language')) {
|
|
context.handle(_languageMeta,
|
|
language.isAcceptableOrUnknown(data['language']!, _languageMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_languageMeta);
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
VoiceModel map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return VoiceModel(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
cardId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}card_id'])!,
|
|
voiceUrl: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}voice_url'])!,
|
|
language: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}language'])!,
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$VoiceModelsTable createAlias(String alias) {
|
|
return $VoiceModelsTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class VoiceModel extends DataClass implements Insertable<VoiceModel> {
|
|
final int id;
|
|
final int cardId;
|
|
final String voiceUrl;
|
|
final String language;
|
|
final DateTime createdAt;
|
|
const VoiceModel(
|
|
{required this.id,
|
|
required this.cardId,
|
|
required this.voiceUrl,
|
|
required this.language,
|
|
required this.createdAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['card_id'] = Variable<int>(cardId);
|
|
map['voice_url'] = Variable<String>(voiceUrl);
|
|
map['language'] = Variable<String>(language);
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
return map;
|
|
}
|
|
|
|
VoiceModelsCompanion toCompanion(bool nullToAbsent) {
|
|
return VoiceModelsCompanion(
|
|
id: Value(id),
|
|
cardId: Value(cardId),
|
|
voiceUrl: Value(voiceUrl),
|
|
language: Value(language),
|
|
createdAt: Value(createdAt),
|
|
);
|
|
}
|
|
|
|
factory VoiceModel.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return VoiceModel(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
cardId: serializer.fromJson<int>(json['cardId']),
|
|
voiceUrl: serializer.fromJson<String>(json['voiceUrl']),
|
|
language: serializer.fromJson<String>(json['language']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'cardId': serializer.toJson<int>(cardId),
|
|
'voiceUrl': serializer.toJson<String>(voiceUrl),
|
|
'language': serializer.toJson<String>(language),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
};
|
|
}
|
|
|
|
VoiceModel copyWith(
|
|
{int? id,
|
|
int? cardId,
|
|
String? voiceUrl,
|
|
String? language,
|
|
DateTime? createdAt}) =>
|
|
VoiceModel(
|
|
id: id ?? this.id,
|
|
cardId: cardId ?? this.cardId,
|
|
voiceUrl: voiceUrl ?? this.voiceUrl,
|
|
language: language ?? this.language,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('VoiceModel(')
|
|
..write('id: $id, ')
|
|
..write('cardId: $cardId, ')
|
|
..write('voiceUrl: $voiceUrl, ')
|
|
..write('language: $language, ')
|
|
..write('createdAt: $createdAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, cardId, voiceUrl, language, createdAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is VoiceModel &&
|
|
other.id == this.id &&
|
|
other.cardId == this.cardId &&
|
|
other.voiceUrl == this.voiceUrl &&
|
|
other.language == this.language &&
|
|
other.createdAt == this.createdAt);
|
|
}
|
|
|
|
class VoiceModelsCompanion extends UpdateCompanion<VoiceModel> {
|
|
final Value<int> id;
|
|
final Value<int> cardId;
|
|
final Value<String> voiceUrl;
|
|
final Value<String> language;
|
|
final Value<DateTime> createdAt;
|
|
const VoiceModelsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.cardId = const Value.absent(),
|
|
this.voiceUrl = const Value.absent(),
|
|
this.language = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
});
|
|
VoiceModelsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int cardId,
|
|
required String voiceUrl,
|
|
required String language,
|
|
this.createdAt = const Value.absent(),
|
|
}) : cardId = Value(cardId),
|
|
voiceUrl = Value(voiceUrl),
|
|
language = Value(language);
|
|
static Insertable<VoiceModel> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? cardId,
|
|
Expression<String>? voiceUrl,
|
|
Expression<String>? language,
|
|
Expression<DateTime>? createdAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (cardId != null) 'card_id': cardId,
|
|
if (voiceUrl != null) 'voice_url': voiceUrl,
|
|
if (language != null) 'language': language,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
});
|
|
}
|
|
|
|
VoiceModelsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? cardId,
|
|
Value<String>? voiceUrl,
|
|
Value<String>? language,
|
|
Value<DateTime>? createdAt}) {
|
|
return VoiceModelsCompanion(
|
|
id: id ?? this.id,
|
|
cardId: cardId ?? this.cardId,
|
|
voiceUrl: voiceUrl ?? this.voiceUrl,
|
|
language: language ?? this.language,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (cardId.present) {
|
|
map['card_id'] = Variable<int>(cardId.value);
|
|
}
|
|
if (voiceUrl.present) {
|
|
map['voice_url'] = Variable<String>(voiceUrl.value);
|
|
}
|
|
if (language.present) {
|
|
map['language'] = Variable<String>(language.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('VoiceModelsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('cardId: $cardId, ')
|
|
..write('voiceUrl: $voiceUrl, ')
|
|
..write('language: $language, ')
|
|
..write('createdAt: $createdAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $UserPacksTable extends UserPacks
|
|
with TableInfo<$UserPacksTable, UserPack> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$UserPacksTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _packIdMeta = const VerificationMeta('packId');
|
|
@override
|
|
late final GeneratedColumn<int> packId = GeneratedColumn<int>(
|
|
'pack_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES card_packs (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _grantedAtMeta =
|
|
const VerificationMeta('grantedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> grantedAt = GeneratedColumn<DateTime>(
|
|
'granted_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _grantTypeMeta =
|
|
const VerificationMeta('grantType');
|
|
@override
|
|
late final GeneratedColumn<String> grantType = GeneratedColumn<String>(
|
|
'grant_type', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('purchase'));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [userId, packId, grantedAt, grantType];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'user_packs';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<UserPack> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('pack_id')) {
|
|
context.handle(_packIdMeta,
|
|
packId.isAcceptableOrUnknown(data['pack_id']!, _packIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_packIdMeta);
|
|
}
|
|
if (data.containsKey('granted_at')) {
|
|
context.handle(_grantedAtMeta,
|
|
grantedAt.isAcceptableOrUnknown(data['granted_at']!, _grantedAtMeta));
|
|
}
|
|
if (data.containsKey('grant_type')) {
|
|
context.handle(_grantTypeMeta,
|
|
grantType.isAcceptableOrUnknown(data['grant_type']!, _grantTypeMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {userId, packId};
|
|
@override
|
|
UserPack map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return UserPack(
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
packId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}pack_id'])!,
|
|
grantedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}granted_at'])!,
|
|
grantType: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}grant_type'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$UserPacksTable createAlias(String alias) {
|
|
return $UserPacksTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class UserPack extends DataClass implements Insertable<UserPack> {
|
|
final int userId;
|
|
final int packId;
|
|
final DateTime grantedAt;
|
|
final String grantType;
|
|
const UserPack(
|
|
{required this.userId,
|
|
required this.packId,
|
|
required this.grantedAt,
|
|
required this.grantType});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['pack_id'] = Variable<int>(packId);
|
|
map['granted_at'] = Variable<DateTime>(grantedAt);
|
|
map['grant_type'] = Variable<String>(grantType);
|
|
return map;
|
|
}
|
|
|
|
UserPacksCompanion toCompanion(bool nullToAbsent) {
|
|
return UserPacksCompanion(
|
|
userId: Value(userId),
|
|
packId: Value(packId),
|
|
grantedAt: Value(grantedAt),
|
|
grantType: Value(grantType),
|
|
);
|
|
}
|
|
|
|
factory UserPack.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return UserPack(
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
packId: serializer.fromJson<int>(json['packId']),
|
|
grantedAt: serializer.fromJson<DateTime>(json['grantedAt']),
|
|
grantType: serializer.fromJson<String>(json['grantType']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'userId': serializer.toJson<int>(userId),
|
|
'packId': serializer.toJson<int>(packId),
|
|
'grantedAt': serializer.toJson<DateTime>(grantedAt),
|
|
'grantType': serializer.toJson<String>(grantType),
|
|
};
|
|
}
|
|
|
|
UserPack copyWith(
|
|
{int? userId, int? packId, DateTime? grantedAt, String? grantType}) =>
|
|
UserPack(
|
|
userId: userId ?? this.userId,
|
|
packId: packId ?? this.packId,
|
|
grantedAt: grantedAt ?? this.grantedAt,
|
|
grantType: grantType ?? this.grantType,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserPack(')
|
|
..write('userId: $userId, ')
|
|
..write('packId: $packId, ')
|
|
..write('grantedAt: $grantedAt, ')
|
|
..write('grantType: $grantType')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(userId, packId, grantedAt, grantType);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is UserPack &&
|
|
other.userId == this.userId &&
|
|
other.packId == this.packId &&
|
|
other.grantedAt == this.grantedAt &&
|
|
other.grantType == this.grantType);
|
|
}
|
|
|
|
class UserPacksCompanion extends UpdateCompanion<UserPack> {
|
|
final Value<int> userId;
|
|
final Value<int> packId;
|
|
final Value<DateTime> grantedAt;
|
|
final Value<String> grantType;
|
|
final Value<int> rowid;
|
|
const UserPacksCompanion({
|
|
this.userId = const Value.absent(),
|
|
this.packId = const Value.absent(),
|
|
this.grantedAt = const Value.absent(),
|
|
this.grantType = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
});
|
|
UserPacksCompanion.insert({
|
|
required int userId,
|
|
required int packId,
|
|
this.grantedAt = const Value.absent(),
|
|
this.grantType = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
}) : userId = Value(userId),
|
|
packId = Value(packId);
|
|
static Insertable<UserPack> custom({
|
|
Expression<int>? userId,
|
|
Expression<int>? packId,
|
|
Expression<DateTime>? grantedAt,
|
|
Expression<String>? grantType,
|
|
Expression<int>? rowid,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (userId != null) 'user_id': userId,
|
|
if (packId != null) 'pack_id': packId,
|
|
if (grantedAt != null) 'granted_at': grantedAt,
|
|
if (grantType != null) 'grant_type': grantType,
|
|
if (rowid != null) 'rowid': rowid,
|
|
});
|
|
}
|
|
|
|
UserPacksCompanion copyWith(
|
|
{Value<int>? userId,
|
|
Value<int>? packId,
|
|
Value<DateTime>? grantedAt,
|
|
Value<String>? grantType,
|
|
Value<int>? rowid}) {
|
|
return UserPacksCompanion(
|
|
userId: userId ?? this.userId,
|
|
packId: packId ?? this.packId,
|
|
grantedAt: grantedAt ?? this.grantedAt,
|
|
grantType: grantType ?? this.grantType,
|
|
rowid: rowid ?? this.rowid,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (packId.present) {
|
|
map['pack_id'] = Variable<int>(packId.value);
|
|
}
|
|
if (grantedAt.present) {
|
|
map['granted_at'] = Variable<DateTime>(grantedAt.value);
|
|
}
|
|
if (grantType.present) {
|
|
map['grant_type'] = Variable<String>(grantType.value);
|
|
}
|
|
if (rowid.present) {
|
|
map['rowid'] = Variable<int>(rowid.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserPacksCompanion(')
|
|
..write('userId: $userId, ')
|
|
..write('packId: $packId, ')
|
|
..write('grantedAt: $grantedAt, ')
|
|
..write('grantType: $grantType, ')
|
|
..write('rowid: $rowid')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $PreviewCardsTable extends PreviewCards
|
|
with TableInfo<$PreviewCardsTable, PreviewCard> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$PreviewCardsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _packIdMeta = const VerificationMeta('packId');
|
|
@override
|
|
late final GeneratedColumn<int> packId = GeneratedColumn<int>(
|
|
'pack_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES card_packs (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _cardIdMeta = const VerificationMeta('cardId');
|
|
@override
|
|
late final GeneratedColumn<int> cardId = GeneratedColumn<int>(
|
|
'card_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES game_cards (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _orderMeta = const VerificationMeta('order');
|
|
@override
|
|
late final GeneratedColumn<int> order = GeneratedColumn<int>(
|
|
'order', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [packId, cardId, order];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'preview_cards';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<PreviewCard> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('pack_id')) {
|
|
context.handle(_packIdMeta,
|
|
packId.isAcceptableOrUnknown(data['pack_id']!, _packIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_packIdMeta);
|
|
}
|
|
if (data.containsKey('card_id')) {
|
|
context.handle(_cardIdMeta,
|
|
cardId.isAcceptableOrUnknown(data['card_id']!, _cardIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_cardIdMeta);
|
|
}
|
|
if (data.containsKey('order')) {
|
|
context.handle(
|
|
_orderMeta, order.isAcceptableOrUnknown(data['order']!, _orderMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {packId, cardId};
|
|
@override
|
|
PreviewCard map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return PreviewCard(
|
|
packId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}pack_id'])!,
|
|
cardId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}card_id'])!,
|
|
order: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}order'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$PreviewCardsTable createAlias(String alias) {
|
|
return $PreviewCardsTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class PreviewCard extends DataClass implements Insertable<PreviewCard> {
|
|
final int packId;
|
|
final int cardId;
|
|
final int order;
|
|
const PreviewCard(
|
|
{required this.packId, required this.cardId, required this.order});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['pack_id'] = Variable<int>(packId);
|
|
map['card_id'] = Variable<int>(cardId);
|
|
map['order'] = Variable<int>(order);
|
|
return map;
|
|
}
|
|
|
|
PreviewCardsCompanion toCompanion(bool nullToAbsent) {
|
|
return PreviewCardsCompanion(
|
|
packId: Value(packId),
|
|
cardId: Value(cardId),
|
|
order: Value(order),
|
|
);
|
|
}
|
|
|
|
factory PreviewCard.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return PreviewCard(
|
|
packId: serializer.fromJson<int>(json['packId']),
|
|
cardId: serializer.fromJson<int>(json['cardId']),
|
|
order: serializer.fromJson<int>(json['order']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'packId': serializer.toJson<int>(packId),
|
|
'cardId': serializer.toJson<int>(cardId),
|
|
'order': serializer.toJson<int>(order),
|
|
};
|
|
}
|
|
|
|
PreviewCard copyWith({int? packId, int? cardId, int? order}) => PreviewCard(
|
|
packId: packId ?? this.packId,
|
|
cardId: cardId ?? this.cardId,
|
|
order: order ?? this.order,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PreviewCard(')
|
|
..write('packId: $packId, ')
|
|
..write('cardId: $cardId, ')
|
|
..write('order: $order')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(packId, cardId, order);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is PreviewCard &&
|
|
other.packId == this.packId &&
|
|
other.cardId == this.cardId &&
|
|
other.order == this.order);
|
|
}
|
|
|
|
class PreviewCardsCompanion extends UpdateCompanion<PreviewCard> {
|
|
final Value<int> packId;
|
|
final Value<int> cardId;
|
|
final Value<int> order;
|
|
final Value<int> rowid;
|
|
const PreviewCardsCompanion({
|
|
this.packId = const Value.absent(),
|
|
this.cardId = const Value.absent(),
|
|
this.order = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
});
|
|
PreviewCardsCompanion.insert({
|
|
required int packId,
|
|
required int cardId,
|
|
this.order = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
}) : packId = Value(packId),
|
|
cardId = Value(cardId);
|
|
static Insertable<PreviewCard> custom({
|
|
Expression<int>? packId,
|
|
Expression<int>? cardId,
|
|
Expression<int>? order,
|
|
Expression<int>? rowid,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (packId != null) 'pack_id': packId,
|
|
if (cardId != null) 'card_id': cardId,
|
|
if (order != null) 'order': order,
|
|
if (rowid != null) 'rowid': rowid,
|
|
});
|
|
}
|
|
|
|
PreviewCardsCompanion copyWith(
|
|
{Value<int>? packId,
|
|
Value<int>? cardId,
|
|
Value<int>? order,
|
|
Value<int>? rowid}) {
|
|
return PreviewCardsCompanion(
|
|
packId: packId ?? this.packId,
|
|
cardId: cardId ?? this.cardId,
|
|
order: order ?? this.order,
|
|
rowid: rowid ?? this.rowid,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (packId.present) {
|
|
map['pack_id'] = Variable<int>(packId.value);
|
|
}
|
|
if (cardId.present) {
|
|
map['card_id'] = Variable<int>(cardId.value);
|
|
}
|
|
if (order.present) {
|
|
map['order'] = Variable<int>(order.value);
|
|
}
|
|
if (rowid.present) {
|
|
map['rowid'] = Variable<int>(rowid.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PreviewCardsCompanion(')
|
|
..write('packId: $packId, ')
|
|
..write('cardId: $cardId, ')
|
|
..write('order: $order, ')
|
|
..write('rowid: $rowid')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $CardPackCardsTable extends CardPackCards
|
|
with TableInfo<$CardPackCardsTable, CardPackCard> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$CardPackCardsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _packIdMeta = const VerificationMeta('packId');
|
|
@override
|
|
late final GeneratedColumn<int> packId = GeneratedColumn<int>(
|
|
'pack_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES card_packs (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _cardIdMeta = const VerificationMeta('cardId');
|
|
@override
|
|
late final GeneratedColumn<int> cardId = GeneratedColumn<int>(
|
|
'card_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES game_cards (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _orderMeta = const VerificationMeta('order');
|
|
@override
|
|
late final GeneratedColumn<int> order = GeneratedColumn<int>(
|
|
'order', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [packId, cardId, order];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'card_pack_cards';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<CardPackCard> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('pack_id')) {
|
|
context.handle(_packIdMeta,
|
|
packId.isAcceptableOrUnknown(data['pack_id']!, _packIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_packIdMeta);
|
|
}
|
|
if (data.containsKey('card_id')) {
|
|
context.handle(_cardIdMeta,
|
|
cardId.isAcceptableOrUnknown(data['card_id']!, _cardIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_cardIdMeta);
|
|
}
|
|
if (data.containsKey('order')) {
|
|
context.handle(
|
|
_orderMeta, order.isAcceptableOrUnknown(data['order']!, _orderMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {packId, cardId};
|
|
@override
|
|
CardPackCard map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return CardPackCard(
|
|
packId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}pack_id'])!,
|
|
cardId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}card_id'])!,
|
|
order: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}order'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$CardPackCardsTable createAlias(String alias) {
|
|
return $CardPackCardsTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class CardPackCard extends DataClass implements Insertable<CardPackCard> {
|
|
final int packId;
|
|
final int cardId;
|
|
final int order;
|
|
const CardPackCard(
|
|
{required this.packId, required this.cardId, required this.order});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['pack_id'] = Variable<int>(packId);
|
|
map['card_id'] = Variable<int>(cardId);
|
|
map['order'] = Variable<int>(order);
|
|
return map;
|
|
}
|
|
|
|
CardPackCardsCompanion toCompanion(bool nullToAbsent) {
|
|
return CardPackCardsCompanion(
|
|
packId: Value(packId),
|
|
cardId: Value(cardId),
|
|
order: Value(order),
|
|
);
|
|
}
|
|
|
|
factory CardPackCard.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return CardPackCard(
|
|
packId: serializer.fromJson<int>(json['packId']),
|
|
cardId: serializer.fromJson<int>(json['cardId']),
|
|
order: serializer.fromJson<int>(json['order']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'packId': serializer.toJson<int>(packId),
|
|
'cardId': serializer.toJson<int>(cardId),
|
|
'order': serializer.toJson<int>(order),
|
|
};
|
|
}
|
|
|
|
CardPackCard copyWith({int? packId, int? cardId, int? order}) => CardPackCard(
|
|
packId: packId ?? this.packId,
|
|
cardId: cardId ?? this.cardId,
|
|
order: order ?? this.order,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('CardPackCard(')
|
|
..write('packId: $packId, ')
|
|
..write('cardId: $cardId, ')
|
|
..write('order: $order')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(packId, cardId, order);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is CardPackCard &&
|
|
other.packId == this.packId &&
|
|
other.cardId == this.cardId &&
|
|
other.order == this.order);
|
|
}
|
|
|
|
class CardPackCardsCompanion extends UpdateCompanion<CardPackCard> {
|
|
final Value<int> packId;
|
|
final Value<int> cardId;
|
|
final Value<int> order;
|
|
final Value<int> rowid;
|
|
const CardPackCardsCompanion({
|
|
this.packId = const Value.absent(),
|
|
this.cardId = const Value.absent(),
|
|
this.order = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
});
|
|
CardPackCardsCompanion.insert({
|
|
required int packId,
|
|
required int cardId,
|
|
this.order = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
}) : packId = Value(packId),
|
|
cardId = Value(cardId);
|
|
static Insertable<CardPackCard> custom({
|
|
Expression<int>? packId,
|
|
Expression<int>? cardId,
|
|
Expression<int>? order,
|
|
Expression<int>? rowid,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (packId != null) 'pack_id': packId,
|
|
if (cardId != null) 'card_id': cardId,
|
|
if (order != null) 'order': order,
|
|
if (rowid != null) 'rowid': rowid,
|
|
});
|
|
}
|
|
|
|
CardPackCardsCompanion copyWith(
|
|
{Value<int>? packId,
|
|
Value<int>? cardId,
|
|
Value<int>? order,
|
|
Value<int>? rowid}) {
|
|
return CardPackCardsCompanion(
|
|
packId: packId ?? this.packId,
|
|
cardId: cardId ?? this.cardId,
|
|
order: order ?? this.order,
|
|
rowid: rowid ?? this.rowid,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (packId.present) {
|
|
map['pack_id'] = Variable<int>(packId.value);
|
|
}
|
|
if (cardId.present) {
|
|
map['card_id'] = Variable<int>(cardId.value);
|
|
}
|
|
if (order.present) {
|
|
map['order'] = Variable<int>(order.value);
|
|
}
|
|
if (rowid.present) {
|
|
map['rowid'] = Variable<int>(rowid.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('CardPackCardsCompanion(')
|
|
..write('packId: $packId, ')
|
|
..write('cardId: $cardId, ')
|
|
..write('order: $order, ')
|
|
..write('rowid: $rowid')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $CardVoicesTable extends CardVoices
|
|
with TableInfo<$CardVoicesTable, CardVoice> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$CardVoicesTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _cardIdMeta = const VerificationMeta('cardId');
|
|
@override
|
|
late final GeneratedColumn<int> cardId = GeneratedColumn<int>(
|
|
'card_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES game_cards (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _voiceIdMeta =
|
|
const VerificationMeta('voiceId');
|
|
@override
|
|
late final GeneratedColumn<int> voiceId = GeneratedColumn<int>(
|
|
'voice_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES voice_models (id) ON DELETE CASCADE'));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [cardId, voiceId];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'card_voices';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<CardVoice> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('card_id')) {
|
|
context.handle(_cardIdMeta,
|
|
cardId.isAcceptableOrUnknown(data['card_id']!, _cardIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_cardIdMeta);
|
|
}
|
|
if (data.containsKey('voice_id')) {
|
|
context.handle(_voiceIdMeta,
|
|
voiceId.isAcceptableOrUnknown(data['voice_id']!, _voiceIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_voiceIdMeta);
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {cardId, voiceId};
|
|
@override
|
|
CardVoice map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return CardVoice(
|
|
cardId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}card_id'])!,
|
|
voiceId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}voice_id'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$CardVoicesTable createAlias(String alias) {
|
|
return $CardVoicesTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class CardVoice extends DataClass implements Insertable<CardVoice> {
|
|
final int cardId;
|
|
final int voiceId;
|
|
const CardVoice({required this.cardId, required this.voiceId});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['card_id'] = Variable<int>(cardId);
|
|
map['voice_id'] = Variable<int>(voiceId);
|
|
return map;
|
|
}
|
|
|
|
CardVoicesCompanion toCompanion(bool nullToAbsent) {
|
|
return CardVoicesCompanion(
|
|
cardId: Value(cardId),
|
|
voiceId: Value(voiceId),
|
|
);
|
|
}
|
|
|
|
factory CardVoice.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return CardVoice(
|
|
cardId: serializer.fromJson<int>(json['cardId']),
|
|
voiceId: serializer.fromJson<int>(json['voiceId']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'cardId': serializer.toJson<int>(cardId),
|
|
'voiceId': serializer.toJson<int>(voiceId),
|
|
};
|
|
}
|
|
|
|
CardVoice copyWith({int? cardId, int? voiceId}) => CardVoice(
|
|
cardId: cardId ?? this.cardId,
|
|
voiceId: voiceId ?? this.voiceId,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('CardVoice(')
|
|
..write('cardId: $cardId, ')
|
|
..write('voiceId: $voiceId')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(cardId, voiceId);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is CardVoice &&
|
|
other.cardId == this.cardId &&
|
|
other.voiceId == this.voiceId);
|
|
}
|
|
|
|
class CardVoicesCompanion extends UpdateCompanion<CardVoice> {
|
|
final Value<int> cardId;
|
|
final Value<int> voiceId;
|
|
final Value<int> rowid;
|
|
const CardVoicesCompanion({
|
|
this.cardId = const Value.absent(),
|
|
this.voiceId = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
});
|
|
CardVoicesCompanion.insert({
|
|
required int cardId,
|
|
required int voiceId,
|
|
this.rowid = const Value.absent(),
|
|
}) : cardId = Value(cardId),
|
|
voiceId = Value(voiceId);
|
|
static Insertable<CardVoice> custom({
|
|
Expression<int>? cardId,
|
|
Expression<int>? voiceId,
|
|
Expression<int>? rowid,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (cardId != null) 'card_id': cardId,
|
|
if (voiceId != null) 'voice_id': voiceId,
|
|
if (rowid != null) 'rowid': rowid,
|
|
});
|
|
}
|
|
|
|
CardVoicesCompanion copyWith(
|
|
{Value<int>? cardId, Value<int>? voiceId, Value<int>? rowid}) {
|
|
return CardVoicesCompanion(
|
|
cardId: cardId ?? this.cardId,
|
|
voiceId: voiceId ?? this.voiceId,
|
|
rowid: rowid ?? this.rowid,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (cardId.present) {
|
|
map['card_id'] = Variable<int>(cardId.value);
|
|
}
|
|
if (voiceId.present) {
|
|
map['voice_id'] = Variable<int>(voiceId.value);
|
|
}
|
|
if (rowid.present) {
|
|
map['rowid'] = Variable<int>(rowid.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('CardVoicesCompanion(')
|
|
..write('cardId: $cardId, ')
|
|
..write('voiceId: $voiceId, ')
|
|
..write('rowid: $rowid')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $SubscriptionPlansTable extends SubscriptionPlans
|
|
with TableInfo<$SubscriptionPlansTable, SubscriptionPlan> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$SubscriptionPlansTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _uiMeta = const VerificationMeta('ui');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<Map<String, dynamic>?, String>
|
|
ui = GeneratedColumn<String>('ui', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false)
|
|
.withConverter<Map<String, dynamic>?>(
|
|
$SubscriptionPlansTable.$converterui);
|
|
static const VerificationMeta _priceMeta = const VerificationMeta('price');
|
|
@override
|
|
late final GeneratedColumn<String> price = GeneratedColumn<String>(
|
|
'price', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _currencyMeta =
|
|
const VerificationMeta('currency');
|
|
@override
|
|
late final GeneratedColumn<String> currency = GeneratedColumn<String>(
|
|
'currency', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _durationDaysMeta =
|
|
const VerificationMeta('durationDays');
|
|
@override
|
|
late final GeneratedColumn<int> durationDays = GeneratedColumn<int>(
|
|
'duration_days', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _featuresMeta =
|
|
const VerificationMeta('features');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<dynamic>?, String> features =
|
|
GeneratedColumn<String>('features', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<dynamic>?>(
|
|
$SubscriptionPlansTable.$converterfeatures);
|
|
static const VerificationMeta _paymentIdMeta =
|
|
const VerificationMeta('paymentId');
|
|
@override
|
|
late final GeneratedColumn<String> paymentId = GeneratedColumn<String>(
|
|
'payment_id', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _paymentSystemMeta =
|
|
const VerificationMeta('paymentSystem');
|
|
@override
|
|
late final GeneratedColumn<String> paymentSystem = GeneratedColumn<String>(
|
|
'payment_system', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _isDeletedMeta =
|
|
const VerificationMeta('isDeleted');
|
|
@override
|
|
late final GeneratedColumn<bool> isDeleted = GeneratedColumn<bool>(
|
|
'is_deleted', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("is_deleted" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
ui,
|
|
price,
|
|
currency,
|
|
durationDays,
|
|
features,
|
|
paymentId,
|
|
paymentSystem,
|
|
createdAt,
|
|
updatedAt,
|
|
isDeleted
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'subscription_plans';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<SubscriptionPlan> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
context.handle(_uiMeta, const VerificationResult.success());
|
|
if (data.containsKey('price')) {
|
|
context.handle(
|
|
_priceMeta, price.isAcceptableOrUnknown(data['price']!, _priceMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_priceMeta);
|
|
}
|
|
if (data.containsKey('currency')) {
|
|
context.handle(_currencyMeta,
|
|
currency.isAcceptableOrUnknown(data['currency']!, _currencyMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_currencyMeta);
|
|
}
|
|
if (data.containsKey('duration_days')) {
|
|
context.handle(
|
|
_durationDaysMeta,
|
|
durationDays.isAcceptableOrUnknown(
|
|
data['duration_days']!, _durationDaysMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_durationDaysMeta);
|
|
}
|
|
context.handle(_featuresMeta, const VerificationResult.success());
|
|
if (data.containsKey('payment_id')) {
|
|
context.handle(_paymentIdMeta,
|
|
paymentId.isAcceptableOrUnknown(data['payment_id']!, _paymentIdMeta));
|
|
}
|
|
if (data.containsKey('payment_system')) {
|
|
context.handle(
|
|
_paymentSystemMeta,
|
|
paymentSystem.isAcceptableOrUnknown(
|
|
data['payment_system']!, _paymentSystemMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_paymentSystemMeta);
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
if (data.containsKey('is_deleted')) {
|
|
context.handle(_isDeletedMeta,
|
|
isDeleted.isAcceptableOrUnknown(data['is_deleted']!, _isDeletedMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
SubscriptionPlan map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return SubscriptionPlan(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
ui: $SubscriptionPlansTable.$converterui.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}ui'])),
|
|
price: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}price'])!,
|
|
currency: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}currency'])!,
|
|
durationDays: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}duration_days'])!,
|
|
features: $SubscriptionPlansTable.$converterfeatures.fromSql(
|
|
attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}features'])!),
|
|
paymentId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}payment_id']),
|
|
paymentSystem: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}payment_system'])!,
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
isDeleted: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_deleted'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$SubscriptionPlansTable createAlias(String alias) {
|
|
return $SubscriptionPlansTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<Map<String, dynamic>?, String?> $converterui =
|
|
NullAwareTypeConverter.wrap(const JsonMapConverter());
|
|
static TypeConverter<List<dynamic>?, String> $converterfeatures =
|
|
const JsonListConverter();
|
|
}
|
|
|
|
class SubscriptionPlan extends DataClass
|
|
implements Insertable<SubscriptionPlan> {
|
|
final int id;
|
|
final Map<String, dynamic>? ui;
|
|
final String price;
|
|
final String currency;
|
|
final int durationDays;
|
|
final List<dynamic>? features;
|
|
final String? paymentId;
|
|
final String paymentSystem;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
final bool isDeleted;
|
|
const SubscriptionPlan(
|
|
{required this.id,
|
|
this.ui,
|
|
required this.price,
|
|
required this.currency,
|
|
required this.durationDays,
|
|
this.features,
|
|
this.paymentId,
|
|
required this.paymentSystem,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.isDeleted});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
if (!nullToAbsent || ui != null) {
|
|
map['ui'] =
|
|
Variable<String>($SubscriptionPlansTable.$converterui.toSql(ui));
|
|
}
|
|
map['price'] = Variable<String>(price);
|
|
map['currency'] = Variable<String>(currency);
|
|
map['duration_days'] = Variable<int>(durationDays);
|
|
if (!nullToAbsent || features != null) {
|
|
map['features'] = Variable<String>(
|
|
$SubscriptionPlansTable.$converterfeatures.toSql(features));
|
|
}
|
|
if (!nullToAbsent || paymentId != null) {
|
|
map['payment_id'] = Variable<String>(paymentId);
|
|
}
|
|
map['payment_system'] = Variable<String>(paymentSystem);
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
map['is_deleted'] = Variable<bool>(isDeleted);
|
|
return map;
|
|
}
|
|
|
|
SubscriptionPlansCompanion toCompanion(bool nullToAbsent) {
|
|
return SubscriptionPlansCompanion(
|
|
id: Value(id),
|
|
ui: ui == null && nullToAbsent ? const Value.absent() : Value(ui),
|
|
price: Value(price),
|
|
currency: Value(currency),
|
|
durationDays: Value(durationDays),
|
|
features: features == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(features),
|
|
paymentId: paymentId == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(paymentId),
|
|
paymentSystem: Value(paymentSystem),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
isDeleted: Value(isDeleted),
|
|
);
|
|
}
|
|
|
|
factory SubscriptionPlan.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return SubscriptionPlan(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
ui: serializer.fromJson<Map<String, dynamic>?>(json['ui']),
|
|
price: serializer.fromJson<String>(json['price']),
|
|
currency: serializer.fromJson<String>(json['currency']),
|
|
durationDays: serializer.fromJson<int>(json['durationDays']),
|
|
features: serializer.fromJson<List<dynamic>?>(json['features']),
|
|
paymentId: serializer.fromJson<String?>(json['paymentId']),
|
|
paymentSystem: serializer.fromJson<String>(json['paymentSystem']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
isDeleted: serializer.fromJson<bool>(json['isDeleted']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'ui': serializer.toJson<Map<String, dynamic>?>(ui),
|
|
'price': serializer.toJson<String>(price),
|
|
'currency': serializer.toJson<String>(currency),
|
|
'durationDays': serializer.toJson<int>(durationDays),
|
|
'features': serializer.toJson<List<dynamic>?>(features),
|
|
'paymentId': serializer.toJson<String?>(paymentId),
|
|
'paymentSystem': serializer.toJson<String>(paymentSystem),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
'isDeleted': serializer.toJson<bool>(isDeleted),
|
|
};
|
|
}
|
|
|
|
SubscriptionPlan copyWith(
|
|
{int? id,
|
|
Value<Map<String, dynamic>?> ui = const Value.absent(),
|
|
String? price,
|
|
String? currency,
|
|
int? durationDays,
|
|
Value<List<dynamic>?> features = const Value.absent(),
|
|
Value<String?> paymentId = const Value.absent(),
|
|
String? paymentSystem,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
bool? isDeleted}) =>
|
|
SubscriptionPlan(
|
|
id: id ?? this.id,
|
|
ui: ui.present ? ui.value : this.ui,
|
|
price: price ?? this.price,
|
|
currency: currency ?? this.currency,
|
|
durationDays: durationDays ?? this.durationDays,
|
|
features: features.present ? features.value : this.features,
|
|
paymentId: paymentId.present ? paymentId.value : this.paymentId,
|
|
paymentSystem: paymentSystem ?? this.paymentSystem,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('SubscriptionPlan(')
|
|
..write('id: $id, ')
|
|
..write('ui: $ui, ')
|
|
..write('price: $price, ')
|
|
..write('currency: $currency, ')
|
|
..write('durationDays: $durationDays, ')
|
|
..write('features: $features, ')
|
|
..write('paymentId: $paymentId, ')
|
|
..write('paymentSystem: $paymentSystem, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, ui, price, currency, durationDays,
|
|
features, paymentId, paymentSystem, createdAt, updatedAt, isDeleted);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is SubscriptionPlan &&
|
|
other.id == this.id &&
|
|
other.ui == this.ui &&
|
|
other.price == this.price &&
|
|
other.currency == this.currency &&
|
|
other.durationDays == this.durationDays &&
|
|
other.features == this.features &&
|
|
other.paymentId == this.paymentId &&
|
|
other.paymentSystem == this.paymentSystem &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt &&
|
|
other.isDeleted == this.isDeleted);
|
|
}
|
|
|
|
class SubscriptionPlansCompanion extends UpdateCompanion<SubscriptionPlan> {
|
|
final Value<int> id;
|
|
final Value<Map<String, dynamic>?> ui;
|
|
final Value<String> price;
|
|
final Value<String> currency;
|
|
final Value<int> durationDays;
|
|
final Value<List<dynamic>?> features;
|
|
final Value<String?> paymentId;
|
|
final Value<String> paymentSystem;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
final Value<bool> isDeleted;
|
|
const SubscriptionPlansCompanion({
|
|
this.id = const Value.absent(),
|
|
this.ui = const Value.absent(),
|
|
this.price = const Value.absent(),
|
|
this.currency = const Value.absent(),
|
|
this.durationDays = const Value.absent(),
|
|
this.features = const Value.absent(),
|
|
this.paymentId = const Value.absent(),
|
|
this.paymentSystem = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
});
|
|
SubscriptionPlansCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
this.ui = const Value.absent(),
|
|
required String price,
|
|
required String currency,
|
|
required int durationDays,
|
|
this.features = const Value.absent(),
|
|
this.paymentId = const Value.absent(),
|
|
required String paymentSystem,
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
}) : price = Value(price),
|
|
currency = Value(currency),
|
|
durationDays = Value(durationDays),
|
|
paymentSystem = Value(paymentSystem);
|
|
static Insertable<SubscriptionPlan> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? ui,
|
|
Expression<String>? price,
|
|
Expression<String>? currency,
|
|
Expression<int>? durationDays,
|
|
Expression<String>? features,
|
|
Expression<String>? paymentId,
|
|
Expression<String>? paymentSystem,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
Expression<bool>? isDeleted,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (ui != null) 'ui': ui,
|
|
if (price != null) 'price': price,
|
|
if (currency != null) 'currency': currency,
|
|
if (durationDays != null) 'duration_days': durationDays,
|
|
if (features != null) 'features': features,
|
|
if (paymentId != null) 'payment_id': paymentId,
|
|
if (paymentSystem != null) 'payment_system': paymentSystem,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
if (isDeleted != null) 'is_deleted': isDeleted,
|
|
});
|
|
}
|
|
|
|
SubscriptionPlansCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<Map<String, dynamic>?>? ui,
|
|
Value<String>? price,
|
|
Value<String>? currency,
|
|
Value<int>? durationDays,
|
|
Value<List<dynamic>?>? features,
|
|
Value<String?>? paymentId,
|
|
Value<String>? paymentSystem,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt,
|
|
Value<bool>? isDeleted}) {
|
|
return SubscriptionPlansCompanion(
|
|
id: id ?? this.id,
|
|
ui: ui ?? this.ui,
|
|
price: price ?? this.price,
|
|
currency: currency ?? this.currency,
|
|
durationDays: durationDays ?? this.durationDays,
|
|
features: features ?? this.features,
|
|
paymentId: paymentId ?? this.paymentId,
|
|
paymentSystem: paymentSystem ?? this.paymentSystem,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (ui.present) {
|
|
map['ui'] = Variable<String>(
|
|
$SubscriptionPlansTable.$converterui.toSql(ui.value));
|
|
}
|
|
if (price.present) {
|
|
map['price'] = Variable<String>(price.value);
|
|
}
|
|
if (currency.present) {
|
|
map['currency'] = Variable<String>(currency.value);
|
|
}
|
|
if (durationDays.present) {
|
|
map['duration_days'] = Variable<int>(durationDays.value);
|
|
}
|
|
if (features.present) {
|
|
map['features'] = Variable<String>(
|
|
$SubscriptionPlansTable.$converterfeatures.toSql(features.value));
|
|
}
|
|
if (paymentId.present) {
|
|
map['payment_id'] = Variable<String>(paymentId.value);
|
|
}
|
|
if (paymentSystem.present) {
|
|
map['payment_system'] = Variable<String>(paymentSystem.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
if (isDeleted.present) {
|
|
map['is_deleted'] = Variable<bool>(isDeleted.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('SubscriptionPlansCompanion(')
|
|
..write('id: $id, ')
|
|
..write('ui: $ui, ')
|
|
..write('price: $price, ')
|
|
..write('currency: $currency, ')
|
|
..write('durationDays: $durationDays, ')
|
|
..write('features: $features, ')
|
|
..write('paymentId: $paymentId, ')
|
|
..write('paymentSystem: $paymentSystem, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $UserSubscriptionsTable extends UserSubscriptions
|
|
with TableInfo<$UserSubscriptionsTable, UserSubscription> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$UserSubscriptionsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'UNIQUE REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _startMeta = const VerificationMeta('start');
|
|
@override
|
|
late final GeneratedColumn<DateTime> start = GeneratedColumn<DateTime>(
|
|
'start', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
static const VerificationMeta _finishMeta = const VerificationMeta('finish');
|
|
@override
|
|
late final GeneratedColumn<DateTime> finish = GeneratedColumn<DateTime>(
|
|
'finish', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
static const VerificationMeta _featuresMeta =
|
|
const VerificationMeta('features');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<dynamic>?, String> features =
|
|
GeneratedColumn<String>('features', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<dynamic>?>(
|
|
$UserSubscriptionsTable.$converterfeatures);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, userId, start, finish, features, createdAt, updatedAt];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'user_subscriptions';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<UserSubscription> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('start')) {
|
|
context.handle(
|
|
_startMeta, start.isAcceptableOrUnknown(data['start']!, _startMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_startMeta);
|
|
}
|
|
if (data.containsKey('finish')) {
|
|
context.handle(_finishMeta,
|
|
finish.isAcceptableOrUnknown(data['finish']!, _finishMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_finishMeta);
|
|
}
|
|
context.handle(_featuresMeta, const VerificationResult.success());
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
UserSubscription map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return UserSubscription(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
start: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}start'])!,
|
|
finish: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}finish'])!,
|
|
features: $UserSubscriptionsTable.$converterfeatures.fromSql(
|
|
attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}features'])!),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$UserSubscriptionsTable createAlias(String alias) {
|
|
return $UserSubscriptionsTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<List<dynamic>?, String> $converterfeatures =
|
|
const JsonListConverter();
|
|
}
|
|
|
|
class UserSubscription extends DataClass
|
|
implements Insertable<UserSubscription> {
|
|
final int id;
|
|
final int userId;
|
|
final DateTime start;
|
|
final DateTime finish;
|
|
final List<dynamic>? features;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
const UserSubscription(
|
|
{required this.id,
|
|
required this.userId,
|
|
required this.start,
|
|
required this.finish,
|
|
this.features,
|
|
required this.createdAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['start'] = Variable<DateTime>(start);
|
|
map['finish'] = Variable<DateTime>(finish);
|
|
if (!nullToAbsent || features != null) {
|
|
map['features'] = Variable<String>(
|
|
$UserSubscriptionsTable.$converterfeatures.toSql(features));
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
UserSubscriptionsCompanion toCompanion(bool nullToAbsent) {
|
|
return UserSubscriptionsCompanion(
|
|
id: Value(id),
|
|
userId: Value(userId),
|
|
start: Value(start),
|
|
finish: Value(finish),
|
|
features: features == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(features),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory UserSubscription.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return UserSubscription(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
start: serializer.fromJson<DateTime>(json['start']),
|
|
finish: serializer.fromJson<DateTime>(json['finish']),
|
|
features: serializer.fromJson<List<dynamic>?>(json['features']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'start': serializer.toJson<DateTime>(start),
|
|
'finish': serializer.toJson<DateTime>(finish),
|
|
'features': serializer.toJson<List<dynamic>?>(features),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
UserSubscription copyWith(
|
|
{int? id,
|
|
int? userId,
|
|
DateTime? start,
|
|
DateTime? finish,
|
|
Value<List<dynamic>?> features = const Value.absent(),
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt}) =>
|
|
UserSubscription(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
start: start ?? this.start,
|
|
finish: finish ?? this.finish,
|
|
features: features.present ? features.value : this.features,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserSubscription(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('start: $start, ')
|
|
..write('finish: $finish, ')
|
|
..write('features: $features, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode =>
|
|
Object.hash(id, userId, start, finish, features, createdAt, updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is UserSubscription &&
|
|
other.id == this.id &&
|
|
other.userId == this.userId &&
|
|
other.start == this.start &&
|
|
other.finish == this.finish &&
|
|
other.features == this.features &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class UserSubscriptionsCompanion extends UpdateCompanion<UserSubscription> {
|
|
final Value<int> id;
|
|
final Value<int> userId;
|
|
final Value<DateTime> start;
|
|
final Value<DateTime> finish;
|
|
final Value<List<dynamic>?> features;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
const UserSubscriptionsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.start = const Value.absent(),
|
|
this.finish = const Value.absent(),
|
|
this.features = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
UserSubscriptionsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int userId,
|
|
required DateTime start,
|
|
required DateTime finish,
|
|
this.features = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : userId = Value(userId),
|
|
start = Value(start),
|
|
finish = Value(finish);
|
|
static Insertable<UserSubscription> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? userId,
|
|
Expression<DateTime>? start,
|
|
Expression<DateTime>? finish,
|
|
Expression<String>? features,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'user_id': userId,
|
|
if (start != null) 'start': start,
|
|
if (finish != null) 'finish': finish,
|
|
if (features != null) 'features': features,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
UserSubscriptionsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? userId,
|
|
Value<DateTime>? start,
|
|
Value<DateTime>? finish,
|
|
Value<List<dynamic>?>? features,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return UserSubscriptionsCompanion(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
start: start ?? this.start,
|
|
finish: finish ?? this.finish,
|
|
features: features ?? this.features,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (start.present) {
|
|
map['start'] = Variable<DateTime>(start.value);
|
|
}
|
|
if (finish.present) {
|
|
map['finish'] = Variable<DateTime>(finish.value);
|
|
}
|
|
if (features.present) {
|
|
map['features'] = Variable<String>(
|
|
$UserSubscriptionsTable.$converterfeatures.toSql(features.value));
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserSubscriptionsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('start: $start, ')
|
|
..write('finish: $finish, ')
|
|
..write('features: $features, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $PaymentsTable extends Payments with TableInfo<$PaymentsTable, Payment> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$PaymentsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _amountMeta = const VerificationMeta('amount');
|
|
@override
|
|
late final GeneratedColumn<String> amount = GeneratedColumn<String>(
|
|
'amount', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _currencyMeta =
|
|
const VerificationMeta('currency');
|
|
@override
|
|
late final GeneratedColumn<String> currency = GeneratedColumn<String>(
|
|
'currency', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _statusMeta = const VerificationMeta('status');
|
|
@override
|
|
late final GeneratedColumn<String> status = GeneratedColumn<String>(
|
|
'status', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _paymentSystemMeta =
|
|
const VerificationMeta('paymentSystem');
|
|
@override
|
|
late final GeneratedColumn<String> paymentSystem = GeneratedColumn<String>(
|
|
'payment_system', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _externalTokenMeta =
|
|
const VerificationMeta('externalToken');
|
|
@override
|
|
late final GeneratedColumn<String> externalToken = GeneratedColumn<String>(
|
|
'external_token', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _metaMeta = const VerificationMeta('meta');
|
|
@override
|
|
late final GeneratedColumn<String> meta = GeneratedColumn<String>(
|
|
'meta', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _dateMeta = const VerificationMeta('date');
|
|
@override
|
|
late final GeneratedColumn<DateTime> date = GeneratedColumn<DateTime>(
|
|
'date', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _productsMeta =
|
|
const VerificationMeta('products');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<dynamic>?, String> products =
|
|
GeneratedColumn<String>('products', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<dynamic>?>($PaymentsTable.$converterproducts);
|
|
static const VerificationMeta _packsMeta = const VerificationMeta('packs');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<String>, String> packs =
|
|
GeneratedColumn<String>('packs', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<String>>($PaymentsTable.$converterpacks);
|
|
static const VerificationMeta _subscriptionMeta =
|
|
const VerificationMeta('subscription');
|
|
@override
|
|
late final GeneratedColumn<bool> subscription = GeneratedColumn<bool>(
|
|
'subscription', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'CHECK ("subscription" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
userId,
|
|
amount,
|
|
currency,
|
|
status,
|
|
paymentSystem,
|
|
externalToken,
|
|
meta,
|
|
date,
|
|
products,
|
|
packs,
|
|
subscription,
|
|
createdAt,
|
|
updatedAt
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'payments';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<Payment> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('amount')) {
|
|
context.handle(_amountMeta,
|
|
amount.isAcceptableOrUnknown(data['amount']!, _amountMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_amountMeta);
|
|
}
|
|
if (data.containsKey('currency')) {
|
|
context.handle(_currencyMeta,
|
|
currency.isAcceptableOrUnknown(data['currency']!, _currencyMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_currencyMeta);
|
|
}
|
|
if (data.containsKey('status')) {
|
|
context.handle(_statusMeta,
|
|
status.isAcceptableOrUnknown(data['status']!, _statusMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_statusMeta);
|
|
}
|
|
if (data.containsKey('payment_system')) {
|
|
context.handle(
|
|
_paymentSystemMeta,
|
|
paymentSystem.isAcceptableOrUnknown(
|
|
data['payment_system']!, _paymentSystemMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_paymentSystemMeta);
|
|
}
|
|
if (data.containsKey('external_token')) {
|
|
context.handle(
|
|
_externalTokenMeta,
|
|
externalToken.isAcceptableOrUnknown(
|
|
data['external_token']!, _externalTokenMeta));
|
|
}
|
|
if (data.containsKey('meta')) {
|
|
context.handle(
|
|
_metaMeta, meta.isAcceptableOrUnknown(data['meta']!, _metaMeta));
|
|
}
|
|
if (data.containsKey('date')) {
|
|
context.handle(
|
|
_dateMeta, date.isAcceptableOrUnknown(data['date']!, _dateMeta));
|
|
}
|
|
context.handle(_productsMeta, const VerificationResult.success());
|
|
context.handle(_packsMeta, const VerificationResult.success());
|
|
if (data.containsKey('subscription')) {
|
|
context.handle(
|
|
_subscriptionMeta,
|
|
subscription.isAcceptableOrUnknown(
|
|
data['subscription']!, _subscriptionMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
Payment map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return Payment(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
amount: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}amount'])!,
|
|
currency: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}currency'])!,
|
|
status: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}status'])!,
|
|
paymentSystem: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}payment_system'])!,
|
|
externalToken: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}external_token']),
|
|
meta: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}meta']),
|
|
date: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}date'])!,
|
|
products: $PaymentsTable.$converterproducts.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}products'])!),
|
|
packs: $PaymentsTable.$converterpacks.fromSql(attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}packs'])!),
|
|
subscription: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}subscription'])!,
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$PaymentsTable createAlias(String alias) {
|
|
return $PaymentsTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<List<dynamic>?, String> $converterproducts =
|
|
const JsonListConverter();
|
|
static TypeConverter<List<String>, String> $converterpacks =
|
|
const StringListConverter();
|
|
}
|
|
|
|
class Payment extends DataClass implements Insertable<Payment> {
|
|
final int id;
|
|
final int userId;
|
|
final String amount;
|
|
final String currency;
|
|
final String status;
|
|
final String paymentSystem;
|
|
final String? externalToken;
|
|
final String? meta;
|
|
final DateTime date;
|
|
final List<dynamic>? products;
|
|
final List<String> packs;
|
|
final bool subscription;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
const Payment(
|
|
{required this.id,
|
|
required this.userId,
|
|
required this.amount,
|
|
required this.currency,
|
|
required this.status,
|
|
required this.paymentSystem,
|
|
this.externalToken,
|
|
this.meta,
|
|
required this.date,
|
|
this.products,
|
|
required this.packs,
|
|
required this.subscription,
|
|
required this.createdAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['amount'] = Variable<String>(amount);
|
|
map['currency'] = Variable<String>(currency);
|
|
map['status'] = Variable<String>(status);
|
|
map['payment_system'] = Variable<String>(paymentSystem);
|
|
if (!nullToAbsent || externalToken != null) {
|
|
map['external_token'] = Variable<String>(externalToken);
|
|
}
|
|
if (!nullToAbsent || meta != null) {
|
|
map['meta'] = Variable<String>(meta);
|
|
}
|
|
map['date'] = Variable<DateTime>(date);
|
|
if (!nullToAbsent || products != null) {
|
|
map['products'] =
|
|
Variable<String>($PaymentsTable.$converterproducts.toSql(products));
|
|
}
|
|
{
|
|
map['packs'] =
|
|
Variable<String>($PaymentsTable.$converterpacks.toSql(packs));
|
|
}
|
|
map['subscription'] = Variable<bool>(subscription);
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
PaymentsCompanion toCompanion(bool nullToAbsent) {
|
|
return PaymentsCompanion(
|
|
id: Value(id),
|
|
userId: Value(userId),
|
|
amount: Value(amount),
|
|
currency: Value(currency),
|
|
status: Value(status),
|
|
paymentSystem: Value(paymentSystem),
|
|
externalToken: externalToken == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(externalToken),
|
|
meta: meta == null && nullToAbsent ? const Value.absent() : Value(meta),
|
|
date: Value(date),
|
|
products: products == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(products),
|
|
packs: Value(packs),
|
|
subscription: Value(subscription),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory Payment.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return Payment(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
amount: serializer.fromJson<String>(json['amount']),
|
|
currency: serializer.fromJson<String>(json['currency']),
|
|
status: serializer.fromJson<String>(json['status']),
|
|
paymentSystem: serializer.fromJson<String>(json['paymentSystem']),
|
|
externalToken: serializer.fromJson<String?>(json['externalToken']),
|
|
meta: serializer.fromJson<String?>(json['meta']),
|
|
date: serializer.fromJson<DateTime>(json['date']),
|
|
products: serializer.fromJson<List<dynamic>?>(json['products']),
|
|
packs: serializer.fromJson<List<String>>(json['packs']),
|
|
subscription: serializer.fromJson<bool>(json['subscription']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'amount': serializer.toJson<String>(amount),
|
|
'currency': serializer.toJson<String>(currency),
|
|
'status': serializer.toJson<String>(status),
|
|
'paymentSystem': serializer.toJson<String>(paymentSystem),
|
|
'externalToken': serializer.toJson<String?>(externalToken),
|
|
'meta': serializer.toJson<String?>(meta),
|
|
'date': serializer.toJson<DateTime>(date),
|
|
'products': serializer.toJson<List<dynamic>?>(products),
|
|
'packs': serializer.toJson<List<String>>(packs),
|
|
'subscription': serializer.toJson<bool>(subscription),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
Payment copyWith(
|
|
{int? id,
|
|
int? userId,
|
|
String? amount,
|
|
String? currency,
|
|
String? status,
|
|
String? paymentSystem,
|
|
Value<String?> externalToken = const Value.absent(),
|
|
Value<String?> meta = const Value.absent(),
|
|
DateTime? date,
|
|
Value<List<dynamic>?> products = const Value.absent(),
|
|
List<String>? packs,
|
|
bool? subscription,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt}) =>
|
|
Payment(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
amount: amount ?? this.amount,
|
|
currency: currency ?? this.currency,
|
|
status: status ?? this.status,
|
|
paymentSystem: paymentSystem ?? this.paymentSystem,
|
|
externalToken:
|
|
externalToken.present ? externalToken.value : this.externalToken,
|
|
meta: meta.present ? meta.value : this.meta,
|
|
date: date ?? this.date,
|
|
products: products.present ? products.value : this.products,
|
|
packs: packs ?? this.packs,
|
|
subscription: subscription ?? this.subscription,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('Payment(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('amount: $amount, ')
|
|
..write('currency: $currency, ')
|
|
..write('status: $status, ')
|
|
..write('paymentSystem: $paymentSystem, ')
|
|
..write('externalToken: $externalToken, ')
|
|
..write('meta: $meta, ')
|
|
..write('date: $date, ')
|
|
..write('products: $products, ')
|
|
..write('packs: $packs, ')
|
|
..write('subscription: $subscription, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id,
|
|
userId,
|
|
amount,
|
|
currency,
|
|
status,
|
|
paymentSystem,
|
|
externalToken,
|
|
meta,
|
|
date,
|
|
products,
|
|
packs,
|
|
subscription,
|
|
createdAt,
|
|
updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is Payment &&
|
|
other.id == this.id &&
|
|
other.userId == this.userId &&
|
|
other.amount == this.amount &&
|
|
other.currency == this.currency &&
|
|
other.status == this.status &&
|
|
other.paymentSystem == this.paymentSystem &&
|
|
other.externalToken == this.externalToken &&
|
|
other.meta == this.meta &&
|
|
other.date == this.date &&
|
|
other.products == this.products &&
|
|
other.packs == this.packs &&
|
|
other.subscription == this.subscription &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class PaymentsCompanion extends UpdateCompanion<Payment> {
|
|
final Value<int> id;
|
|
final Value<int> userId;
|
|
final Value<String> amount;
|
|
final Value<String> currency;
|
|
final Value<String> status;
|
|
final Value<String> paymentSystem;
|
|
final Value<String?> externalToken;
|
|
final Value<String?> meta;
|
|
final Value<DateTime> date;
|
|
final Value<List<dynamic>?> products;
|
|
final Value<List<String>> packs;
|
|
final Value<bool> subscription;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
const PaymentsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.amount = const Value.absent(),
|
|
this.currency = const Value.absent(),
|
|
this.status = const Value.absent(),
|
|
this.paymentSystem = const Value.absent(),
|
|
this.externalToken = const Value.absent(),
|
|
this.meta = const Value.absent(),
|
|
this.date = const Value.absent(),
|
|
this.products = const Value.absent(),
|
|
this.packs = const Value.absent(),
|
|
this.subscription = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
PaymentsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int userId,
|
|
required String amount,
|
|
required String currency,
|
|
required String status,
|
|
required String paymentSystem,
|
|
this.externalToken = const Value.absent(),
|
|
this.meta = const Value.absent(),
|
|
this.date = const Value.absent(),
|
|
this.products = const Value.absent(),
|
|
this.packs = const Value.absent(),
|
|
this.subscription = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : userId = Value(userId),
|
|
amount = Value(amount),
|
|
currency = Value(currency),
|
|
status = Value(status),
|
|
paymentSystem = Value(paymentSystem);
|
|
static Insertable<Payment> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? userId,
|
|
Expression<String>? amount,
|
|
Expression<String>? currency,
|
|
Expression<String>? status,
|
|
Expression<String>? paymentSystem,
|
|
Expression<String>? externalToken,
|
|
Expression<String>? meta,
|
|
Expression<DateTime>? date,
|
|
Expression<String>? products,
|
|
Expression<String>? packs,
|
|
Expression<bool>? subscription,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'user_id': userId,
|
|
if (amount != null) 'amount': amount,
|
|
if (currency != null) 'currency': currency,
|
|
if (status != null) 'status': status,
|
|
if (paymentSystem != null) 'payment_system': paymentSystem,
|
|
if (externalToken != null) 'external_token': externalToken,
|
|
if (meta != null) 'meta': meta,
|
|
if (date != null) 'date': date,
|
|
if (products != null) 'products': products,
|
|
if (packs != null) 'packs': packs,
|
|
if (subscription != null) 'subscription': subscription,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
PaymentsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? userId,
|
|
Value<String>? amount,
|
|
Value<String>? currency,
|
|
Value<String>? status,
|
|
Value<String>? paymentSystem,
|
|
Value<String?>? externalToken,
|
|
Value<String?>? meta,
|
|
Value<DateTime>? date,
|
|
Value<List<dynamic>?>? products,
|
|
Value<List<String>>? packs,
|
|
Value<bool>? subscription,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return PaymentsCompanion(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
amount: amount ?? this.amount,
|
|
currency: currency ?? this.currency,
|
|
status: status ?? this.status,
|
|
paymentSystem: paymentSystem ?? this.paymentSystem,
|
|
externalToken: externalToken ?? this.externalToken,
|
|
meta: meta ?? this.meta,
|
|
date: date ?? this.date,
|
|
products: products ?? this.products,
|
|
packs: packs ?? this.packs,
|
|
subscription: subscription ?? this.subscription,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (amount.present) {
|
|
map['amount'] = Variable<String>(amount.value);
|
|
}
|
|
if (currency.present) {
|
|
map['currency'] = Variable<String>(currency.value);
|
|
}
|
|
if (status.present) {
|
|
map['status'] = Variable<String>(status.value);
|
|
}
|
|
if (paymentSystem.present) {
|
|
map['payment_system'] = Variable<String>(paymentSystem.value);
|
|
}
|
|
if (externalToken.present) {
|
|
map['external_token'] = Variable<String>(externalToken.value);
|
|
}
|
|
if (meta.present) {
|
|
map['meta'] = Variable<String>(meta.value);
|
|
}
|
|
if (date.present) {
|
|
map['date'] = Variable<DateTime>(date.value);
|
|
}
|
|
if (products.present) {
|
|
map['products'] = Variable<String>(
|
|
$PaymentsTable.$converterproducts.toSql(products.value));
|
|
}
|
|
if (packs.present) {
|
|
map['packs'] =
|
|
Variable<String>($PaymentsTable.$converterpacks.toSql(packs.value));
|
|
}
|
|
if (subscription.present) {
|
|
map['subscription'] = Variable<bool>(subscription.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PaymentsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('amount: $amount, ')
|
|
..write('currency: $currency, ')
|
|
..write('status: $status, ')
|
|
..write('paymentSystem: $paymentSystem, ')
|
|
..write('externalToken: $externalToken, ')
|
|
..write('meta: $meta, ')
|
|
..write('date: $date, ')
|
|
..write('products: $products, ')
|
|
..write('packs: $packs, ')
|
|
..write('subscription: $subscription, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $TestsTable extends Tests with TableInfo<$TestsTable, Test> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$TestsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _nameMeta = const VerificationMeta('name');
|
|
@override
|
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
|
'name', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _colorMeta = const VerificationMeta('color');
|
|
@override
|
|
late final GeneratedColumn<String> color = GeneratedColumn<String>(
|
|
'color', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _coverMeta = const VerificationMeta('cover');
|
|
@override
|
|
late final GeneratedColumn<String> cover = GeneratedColumn<String>(
|
|
'cover', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _versionMeta =
|
|
const VerificationMeta('version');
|
|
@override
|
|
late final GeneratedColumn<String> version = GeneratedColumn<String>(
|
|
'version', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _timeMeta = const VerificationMeta('time');
|
|
@override
|
|
late final GeneratedColumn<String> time = GeneratedColumn<String>(
|
|
'time', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _timeSubtitleMeta =
|
|
const VerificationMeta('timeSubtitle');
|
|
@override
|
|
late final GeneratedColumn<String> timeSubtitle = GeneratedColumn<String>(
|
|
'time_subtitle', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _isDeletedMeta =
|
|
const VerificationMeta('isDeleted');
|
|
@override
|
|
late final GeneratedColumn<bool> isDeleted = GeneratedColumn<bool>(
|
|
'is_deleted', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("is_deleted" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
name,
|
|
color,
|
|
cover,
|
|
version,
|
|
time,
|
|
timeSubtitle,
|
|
createdAt,
|
|
updatedAt,
|
|
isDeleted
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'tests';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<Test> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('name')) {
|
|
context.handle(
|
|
_nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_nameMeta);
|
|
}
|
|
if (data.containsKey('color')) {
|
|
context.handle(
|
|
_colorMeta, color.isAcceptableOrUnknown(data['color']!, _colorMeta));
|
|
}
|
|
if (data.containsKey('cover')) {
|
|
context.handle(
|
|
_coverMeta, cover.isAcceptableOrUnknown(data['cover']!, _coverMeta));
|
|
}
|
|
if (data.containsKey('version')) {
|
|
context.handle(_versionMeta,
|
|
version.isAcceptableOrUnknown(data['version']!, _versionMeta));
|
|
}
|
|
if (data.containsKey('time')) {
|
|
context.handle(
|
|
_timeMeta, time.isAcceptableOrUnknown(data['time']!, _timeMeta));
|
|
}
|
|
if (data.containsKey('time_subtitle')) {
|
|
context.handle(
|
|
_timeSubtitleMeta,
|
|
timeSubtitle.isAcceptableOrUnknown(
|
|
data['time_subtitle']!, _timeSubtitleMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
if (data.containsKey('is_deleted')) {
|
|
context.handle(_isDeletedMeta,
|
|
isDeleted.isAcceptableOrUnknown(data['is_deleted']!, _isDeletedMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
Test map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return Test(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
name: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
|
color: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}color']),
|
|
cover: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}cover']),
|
|
version: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}version']),
|
|
time: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}time']),
|
|
timeSubtitle: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}time_subtitle']),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
isDeleted: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_deleted'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$TestsTable createAlias(String alias) {
|
|
return $TestsTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class Test extends DataClass implements Insertable<Test> {
|
|
final int id;
|
|
final String name;
|
|
final String? color;
|
|
final String? cover;
|
|
final String? version;
|
|
final String? time;
|
|
final String? timeSubtitle;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
final bool isDeleted;
|
|
const Test(
|
|
{required this.id,
|
|
required this.name,
|
|
this.color,
|
|
this.cover,
|
|
this.version,
|
|
this.time,
|
|
this.timeSubtitle,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.isDeleted});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['name'] = Variable<String>(name);
|
|
if (!nullToAbsent || color != null) {
|
|
map['color'] = Variable<String>(color);
|
|
}
|
|
if (!nullToAbsent || cover != null) {
|
|
map['cover'] = Variable<String>(cover);
|
|
}
|
|
if (!nullToAbsent || version != null) {
|
|
map['version'] = Variable<String>(version);
|
|
}
|
|
if (!nullToAbsent || time != null) {
|
|
map['time'] = Variable<String>(time);
|
|
}
|
|
if (!nullToAbsent || timeSubtitle != null) {
|
|
map['time_subtitle'] = Variable<String>(timeSubtitle);
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
map['is_deleted'] = Variable<bool>(isDeleted);
|
|
return map;
|
|
}
|
|
|
|
TestsCompanion toCompanion(bool nullToAbsent) {
|
|
return TestsCompanion(
|
|
id: Value(id),
|
|
name: Value(name),
|
|
color:
|
|
color == null && nullToAbsent ? const Value.absent() : Value(color),
|
|
cover:
|
|
cover == null && nullToAbsent ? const Value.absent() : Value(cover),
|
|
version: version == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(version),
|
|
time: time == null && nullToAbsent ? const Value.absent() : Value(time),
|
|
timeSubtitle: timeSubtitle == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(timeSubtitle),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
isDeleted: Value(isDeleted),
|
|
);
|
|
}
|
|
|
|
factory Test.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return Test(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
name: serializer.fromJson<String>(json['name']),
|
|
color: serializer.fromJson<String?>(json['color']),
|
|
cover: serializer.fromJson<String?>(json['cover']),
|
|
version: serializer.fromJson<String?>(json['version']),
|
|
time: serializer.fromJson<String?>(json['time']),
|
|
timeSubtitle: serializer.fromJson<String?>(json['timeSubtitle']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
isDeleted: serializer.fromJson<bool>(json['isDeleted']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'name': serializer.toJson<String>(name),
|
|
'color': serializer.toJson<String?>(color),
|
|
'cover': serializer.toJson<String?>(cover),
|
|
'version': serializer.toJson<String?>(version),
|
|
'time': serializer.toJson<String?>(time),
|
|
'timeSubtitle': serializer.toJson<String?>(timeSubtitle),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
'isDeleted': serializer.toJson<bool>(isDeleted),
|
|
};
|
|
}
|
|
|
|
Test copyWith(
|
|
{int? id,
|
|
String? name,
|
|
Value<String?> color = const Value.absent(),
|
|
Value<String?> cover = const Value.absent(),
|
|
Value<String?> version = const Value.absent(),
|
|
Value<String?> time = const Value.absent(),
|
|
Value<String?> timeSubtitle = const Value.absent(),
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
bool? isDeleted}) =>
|
|
Test(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
color: color.present ? color.value : this.color,
|
|
cover: cover.present ? cover.value : this.cover,
|
|
version: version.present ? version.value : this.version,
|
|
time: time.present ? time.value : this.time,
|
|
timeSubtitle:
|
|
timeSubtitle.present ? timeSubtitle.value : this.timeSubtitle,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('Test(')
|
|
..write('id: $id, ')
|
|
..write('name: $name, ')
|
|
..write('color: $color, ')
|
|
..write('cover: $cover, ')
|
|
..write('version: $version, ')
|
|
..write('time: $time, ')
|
|
..write('timeSubtitle: $timeSubtitle, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, name, color, cover, version, time,
|
|
timeSubtitle, createdAt, updatedAt, isDeleted);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is Test &&
|
|
other.id == this.id &&
|
|
other.name == this.name &&
|
|
other.color == this.color &&
|
|
other.cover == this.cover &&
|
|
other.version == this.version &&
|
|
other.time == this.time &&
|
|
other.timeSubtitle == this.timeSubtitle &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt &&
|
|
other.isDeleted == this.isDeleted);
|
|
}
|
|
|
|
class TestsCompanion extends UpdateCompanion<Test> {
|
|
final Value<int> id;
|
|
final Value<String> name;
|
|
final Value<String?> color;
|
|
final Value<String?> cover;
|
|
final Value<String?> version;
|
|
final Value<String?> time;
|
|
final Value<String?> timeSubtitle;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
final Value<bool> isDeleted;
|
|
const TestsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.name = const Value.absent(),
|
|
this.color = const Value.absent(),
|
|
this.cover = const Value.absent(),
|
|
this.version = const Value.absent(),
|
|
this.time = const Value.absent(),
|
|
this.timeSubtitle = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
});
|
|
TestsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String name,
|
|
this.color = const Value.absent(),
|
|
this.cover = const Value.absent(),
|
|
this.version = const Value.absent(),
|
|
this.time = const Value.absent(),
|
|
this.timeSubtitle = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
}) : name = Value(name);
|
|
static Insertable<Test> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? name,
|
|
Expression<String>? color,
|
|
Expression<String>? cover,
|
|
Expression<String>? version,
|
|
Expression<String>? time,
|
|
Expression<String>? timeSubtitle,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
Expression<bool>? isDeleted,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (name != null) 'name': name,
|
|
if (color != null) 'color': color,
|
|
if (cover != null) 'cover': cover,
|
|
if (version != null) 'version': version,
|
|
if (time != null) 'time': time,
|
|
if (timeSubtitle != null) 'time_subtitle': timeSubtitle,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
if (isDeleted != null) 'is_deleted': isDeleted,
|
|
});
|
|
}
|
|
|
|
TestsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String>? name,
|
|
Value<String?>? color,
|
|
Value<String?>? cover,
|
|
Value<String?>? version,
|
|
Value<String?>? time,
|
|
Value<String?>? timeSubtitle,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt,
|
|
Value<bool>? isDeleted}) {
|
|
return TestsCompanion(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
color: color ?? this.color,
|
|
cover: cover ?? this.cover,
|
|
version: version ?? this.version,
|
|
time: time ?? this.time,
|
|
timeSubtitle: timeSubtitle ?? this.timeSubtitle,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (name.present) {
|
|
map['name'] = Variable<String>(name.value);
|
|
}
|
|
if (color.present) {
|
|
map['color'] = Variable<String>(color.value);
|
|
}
|
|
if (cover.present) {
|
|
map['cover'] = Variable<String>(cover.value);
|
|
}
|
|
if (version.present) {
|
|
map['version'] = Variable<String>(version.value);
|
|
}
|
|
if (time.present) {
|
|
map['time'] = Variable<String>(time.value);
|
|
}
|
|
if (timeSubtitle.present) {
|
|
map['time_subtitle'] = Variable<String>(timeSubtitle.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
if (isDeleted.present) {
|
|
map['is_deleted'] = Variable<bool>(isDeleted.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TestsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('name: $name, ')
|
|
..write('color: $color, ')
|
|
..write('cover: $cover, ')
|
|
..write('version: $version, ')
|
|
..write('time: $time, ')
|
|
..write('timeSubtitle: $timeSubtitle, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $TestQuestionsTable extends TestQuestions
|
|
with TableInfo<$TestQuestionsTable, TestQuestion> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$TestQuestionsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _testIdMeta = const VerificationMeta('testId');
|
|
@override
|
|
late final GeneratedColumn<int> testId = GeneratedColumn<int>(
|
|
'test_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES tests (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _questionTypeMeta =
|
|
const VerificationMeta('questionType');
|
|
@override
|
|
late final GeneratedColumn<String> questionType = GeneratedColumn<String>(
|
|
'question_type', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _bodyMeta = const VerificationMeta('body');
|
|
@override
|
|
late final GeneratedColumn<String> body = GeneratedColumn<String>(
|
|
'body', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, testId, questionType, body, createdAt, updatedAt];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'test_questions';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<TestQuestion> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('test_id')) {
|
|
context.handle(_testIdMeta,
|
|
testId.isAcceptableOrUnknown(data['test_id']!, _testIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_testIdMeta);
|
|
}
|
|
if (data.containsKey('question_type')) {
|
|
context.handle(
|
|
_questionTypeMeta,
|
|
questionType.isAcceptableOrUnknown(
|
|
data['question_type']!, _questionTypeMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_questionTypeMeta);
|
|
}
|
|
if (data.containsKey('body')) {
|
|
context.handle(
|
|
_bodyMeta, body.isAcceptableOrUnknown(data['body']!, _bodyMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_bodyMeta);
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
TestQuestion map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return TestQuestion(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
testId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}test_id'])!,
|
|
questionType: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}question_type'])!,
|
|
body: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}body'])!,
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$TestQuestionsTable createAlias(String alias) {
|
|
return $TestQuestionsTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class TestQuestion extends DataClass implements Insertable<TestQuestion> {
|
|
final int id;
|
|
final int testId;
|
|
final String questionType;
|
|
final String body;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
const TestQuestion(
|
|
{required this.id,
|
|
required this.testId,
|
|
required this.questionType,
|
|
required this.body,
|
|
required this.createdAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['test_id'] = Variable<int>(testId);
|
|
map['question_type'] = Variable<String>(questionType);
|
|
map['body'] = Variable<String>(body);
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
TestQuestionsCompanion toCompanion(bool nullToAbsent) {
|
|
return TestQuestionsCompanion(
|
|
id: Value(id),
|
|
testId: Value(testId),
|
|
questionType: Value(questionType),
|
|
body: Value(body),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory TestQuestion.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return TestQuestion(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
testId: serializer.fromJson<int>(json['testId']),
|
|
questionType: serializer.fromJson<String>(json['questionType']),
|
|
body: serializer.fromJson<String>(json['body']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'testId': serializer.toJson<int>(testId),
|
|
'questionType': serializer.toJson<String>(questionType),
|
|
'body': serializer.toJson<String>(body),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
TestQuestion copyWith(
|
|
{int? id,
|
|
int? testId,
|
|
String? questionType,
|
|
String? body,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt}) =>
|
|
TestQuestion(
|
|
id: id ?? this.id,
|
|
testId: testId ?? this.testId,
|
|
questionType: questionType ?? this.questionType,
|
|
body: body ?? this.body,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TestQuestion(')
|
|
..write('id: $id, ')
|
|
..write('testId: $testId, ')
|
|
..write('questionType: $questionType, ')
|
|
..write('body: $body, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode =>
|
|
Object.hash(id, testId, questionType, body, createdAt, updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is TestQuestion &&
|
|
other.id == this.id &&
|
|
other.testId == this.testId &&
|
|
other.questionType == this.questionType &&
|
|
other.body == this.body &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class TestQuestionsCompanion extends UpdateCompanion<TestQuestion> {
|
|
final Value<int> id;
|
|
final Value<int> testId;
|
|
final Value<String> questionType;
|
|
final Value<String> body;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
const TestQuestionsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.testId = const Value.absent(),
|
|
this.questionType = const Value.absent(),
|
|
this.body = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
TestQuestionsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int testId,
|
|
required String questionType,
|
|
required String body,
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : testId = Value(testId),
|
|
questionType = Value(questionType),
|
|
body = Value(body);
|
|
static Insertable<TestQuestion> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? testId,
|
|
Expression<String>? questionType,
|
|
Expression<String>? body,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (testId != null) 'test_id': testId,
|
|
if (questionType != null) 'question_type': questionType,
|
|
if (body != null) 'body': body,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
TestQuestionsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? testId,
|
|
Value<String>? questionType,
|
|
Value<String>? body,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return TestQuestionsCompanion(
|
|
id: id ?? this.id,
|
|
testId: testId ?? this.testId,
|
|
questionType: questionType ?? this.questionType,
|
|
body: body ?? this.body,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (testId.present) {
|
|
map['test_id'] = Variable<int>(testId.value);
|
|
}
|
|
if (questionType.present) {
|
|
map['question_type'] = Variable<String>(questionType.value);
|
|
}
|
|
if (body.present) {
|
|
map['body'] = Variable<String>(body.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TestQuestionsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('testId: $testId, ')
|
|
..write('questionType: $questionType, ')
|
|
..write('body: $body, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $TestPackRelationsTable extends TestPackRelations
|
|
with TableInfo<$TestPackRelationsTable, TestPackRelation> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$TestPackRelationsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _testIdMeta = const VerificationMeta('testId');
|
|
@override
|
|
late final GeneratedColumn<int> testId = GeneratedColumn<int>(
|
|
'test_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES tests (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _packIdMeta = const VerificationMeta('packId');
|
|
@override
|
|
late final GeneratedColumn<int> packId = GeneratedColumn<int>(
|
|
'pack_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES card_packs (id) ON DELETE CASCADE'));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [testId, packId];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'test_pack_relations';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<TestPackRelation> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('test_id')) {
|
|
context.handle(_testIdMeta,
|
|
testId.isAcceptableOrUnknown(data['test_id']!, _testIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_testIdMeta);
|
|
}
|
|
if (data.containsKey('pack_id')) {
|
|
context.handle(_packIdMeta,
|
|
packId.isAcceptableOrUnknown(data['pack_id']!, _packIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_packIdMeta);
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {testId, packId};
|
|
@override
|
|
TestPackRelation map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return TestPackRelation(
|
|
testId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}test_id'])!,
|
|
packId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}pack_id'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$TestPackRelationsTable createAlias(String alias) {
|
|
return $TestPackRelationsTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class TestPackRelation extends DataClass
|
|
implements Insertable<TestPackRelation> {
|
|
final int testId;
|
|
final int packId;
|
|
const TestPackRelation({required this.testId, required this.packId});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['test_id'] = Variable<int>(testId);
|
|
map['pack_id'] = Variable<int>(packId);
|
|
return map;
|
|
}
|
|
|
|
TestPackRelationsCompanion toCompanion(bool nullToAbsent) {
|
|
return TestPackRelationsCompanion(
|
|
testId: Value(testId),
|
|
packId: Value(packId),
|
|
);
|
|
}
|
|
|
|
factory TestPackRelation.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return TestPackRelation(
|
|
testId: serializer.fromJson<int>(json['testId']),
|
|
packId: serializer.fromJson<int>(json['packId']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'testId': serializer.toJson<int>(testId),
|
|
'packId': serializer.toJson<int>(packId),
|
|
};
|
|
}
|
|
|
|
TestPackRelation copyWith({int? testId, int? packId}) => TestPackRelation(
|
|
testId: testId ?? this.testId,
|
|
packId: packId ?? this.packId,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TestPackRelation(')
|
|
..write('testId: $testId, ')
|
|
..write('packId: $packId')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(testId, packId);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is TestPackRelation &&
|
|
other.testId == this.testId &&
|
|
other.packId == this.packId);
|
|
}
|
|
|
|
class TestPackRelationsCompanion extends UpdateCompanion<TestPackRelation> {
|
|
final Value<int> testId;
|
|
final Value<int> packId;
|
|
final Value<int> rowid;
|
|
const TestPackRelationsCompanion({
|
|
this.testId = const Value.absent(),
|
|
this.packId = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
});
|
|
TestPackRelationsCompanion.insert({
|
|
required int testId,
|
|
required int packId,
|
|
this.rowid = const Value.absent(),
|
|
}) : testId = Value(testId),
|
|
packId = Value(packId);
|
|
static Insertable<TestPackRelation> custom({
|
|
Expression<int>? testId,
|
|
Expression<int>? packId,
|
|
Expression<int>? rowid,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (testId != null) 'test_id': testId,
|
|
if (packId != null) 'pack_id': packId,
|
|
if (rowid != null) 'rowid': rowid,
|
|
});
|
|
}
|
|
|
|
TestPackRelationsCompanion copyWith(
|
|
{Value<int>? testId, Value<int>? packId, Value<int>? rowid}) {
|
|
return TestPackRelationsCompanion(
|
|
testId: testId ?? this.testId,
|
|
packId: packId ?? this.packId,
|
|
rowid: rowid ?? this.rowid,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (testId.present) {
|
|
map['test_id'] = Variable<int>(testId.value);
|
|
}
|
|
if (packId.present) {
|
|
map['pack_id'] = Variable<int>(packId.value);
|
|
}
|
|
if (rowid.present) {
|
|
map['rowid'] = Variable<int>(rowid.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TestPackRelationsCompanion(')
|
|
..write('testId: $testId, ')
|
|
..write('packId: $packId, ')
|
|
..write('rowid: $rowid')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $TestStatisticsTable extends TestStatistics
|
|
with TableInfo<$TestStatisticsTable, TestStatistic> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$TestStatisticsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _testIdMeta = const VerificationMeta('testId');
|
|
@override
|
|
late final GeneratedColumn<int> testId = GeneratedColumn<int>(
|
|
'test_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES tests (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _resultsMeta =
|
|
const VerificationMeta('results');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<Map<String, dynamic>?, String>
|
|
results = GeneratedColumn<String>('results', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('{}'))
|
|
.withConverter<Map<String, dynamic>?>(
|
|
$TestStatisticsTable.$converterresults);
|
|
static const VerificationMeta _completedAtMeta =
|
|
const VerificationMeta('completedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> completedAt = GeneratedColumn<DateTime>(
|
|
'completed_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, userId, testId, results, completedAt, createdAt, updatedAt];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'test_statistics';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<TestStatistic> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('test_id')) {
|
|
context.handle(_testIdMeta,
|
|
testId.isAcceptableOrUnknown(data['test_id']!, _testIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_testIdMeta);
|
|
}
|
|
context.handle(_resultsMeta, const VerificationResult.success());
|
|
if (data.containsKey('completed_at')) {
|
|
context.handle(
|
|
_completedAtMeta,
|
|
completedAt.isAcceptableOrUnknown(
|
|
data['completed_at']!, _completedAtMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
TestStatistic map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return TestStatistic(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
testId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}test_id'])!,
|
|
results: $TestStatisticsTable.$converterresults.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}results'])!),
|
|
completedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}completed_at'])!,
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$TestStatisticsTable createAlias(String alias) {
|
|
return $TestStatisticsTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<Map<String, dynamic>?, String> $converterresults =
|
|
const JsonMapConverter();
|
|
}
|
|
|
|
class TestStatistic extends DataClass implements Insertable<TestStatistic> {
|
|
final int id;
|
|
final int userId;
|
|
final int testId;
|
|
final Map<String, dynamic>? results;
|
|
final DateTime completedAt;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
const TestStatistic(
|
|
{required this.id,
|
|
required this.userId,
|
|
required this.testId,
|
|
this.results,
|
|
required this.completedAt,
|
|
required this.createdAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['test_id'] = Variable<int>(testId);
|
|
if (!nullToAbsent || results != null) {
|
|
map['results'] = Variable<String>(
|
|
$TestStatisticsTable.$converterresults.toSql(results));
|
|
}
|
|
map['completed_at'] = Variable<DateTime>(completedAt);
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
TestStatisticsCompanion toCompanion(bool nullToAbsent) {
|
|
return TestStatisticsCompanion(
|
|
id: Value(id),
|
|
userId: Value(userId),
|
|
testId: Value(testId),
|
|
results: results == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(results),
|
|
completedAt: Value(completedAt),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory TestStatistic.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return TestStatistic(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
testId: serializer.fromJson<int>(json['testId']),
|
|
results: serializer.fromJson<Map<String, dynamic>?>(json['results']),
|
|
completedAt: serializer.fromJson<DateTime>(json['completedAt']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'testId': serializer.toJson<int>(testId),
|
|
'results': serializer.toJson<Map<String, dynamic>?>(results),
|
|
'completedAt': serializer.toJson<DateTime>(completedAt),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
TestStatistic copyWith(
|
|
{int? id,
|
|
int? userId,
|
|
int? testId,
|
|
Value<Map<String, dynamic>?> results = const Value.absent(),
|
|
DateTime? completedAt,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt}) =>
|
|
TestStatistic(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
testId: testId ?? this.testId,
|
|
results: results.present ? results.value : this.results,
|
|
completedAt: completedAt ?? this.completedAt,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TestStatistic(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('testId: $testId, ')
|
|
..write('results: $results, ')
|
|
..write('completedAt: $completedAt, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id, userId, testId, results, completedAt, createdAt, updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is TestStatistic &&
|
|
other.id == this.id &&
|
|
other.userId == this.userId &&
|
|
other.testId == this.testId &&
|
|
other.results == this.results &&
|
|
other.completedAt == this.completedAt &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class TestStatisticsCompanion extends UpdateCompanion<TestStatistic> {
|
|
final Value<int> id;
|
|
final Value<int> userId;
|
|
final Value<int> testId;
|
|
final Value<Map<String, dynamic>?> results;
|
|
final Value<DateTime> completedAt;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
const TestStatisticsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.testId = const Value.absent(),
|
|
this.results = const Value.absent(),
|
|
this.completedAt = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
TestStatisticsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int userId,
|
|
required int testId,
|
|
this.results = const Value.absent(),
|
|
this.completedAt = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : userId = Value(userId),
|
|
testId = Value(testId);
|
|
static Insertable<TestStatistic> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? userId,
|
|
Expression<int>? testId,
|
|
Expression<String>? results,
|
|
Expression<DateTime>? completedAt,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'user_id': userId,
|
|
if (testId != null) 'test_id': testId,
|
|
if (results != null) 'results': results,
|
|
if (completedAt != null) 'completed_at': completedAt,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
TestStatisticsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? userId,
|
|
Value<int>? testId,
|
|
Value<Map<String, dynamic>?>? results,
|
|
Value<DateTime>? completedAt,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return TestStatisticsCompanion(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
testId: testId ?? this.testId,
|
|
results: results ?? this.results,
|
|
completedAt: completedAt ?? this.completedAt,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (testId.present) {
|
|
map['test_id'] = Variable<int>(testId.value);
|
|
}
|
|
if (results.present) {
|
|
map['results'] = Variable<String>(
|
|
$TestStatisticsTable.$converterresults.toSql(results.value));
|
|
}
|
|
if (completedAt.present) {
|
|
map['completed_at'] = Variable<DateTime>(completedAt.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TestStatisticsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('testId: $testId, ')
|
|
..write('results: $results, ')
|
|
..write('completedAt: $completedAt, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $TasksTable extends Tasks with TableInfo<$TasksTable, Task> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$TasksTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _nameMeta = const VerificationMeta('name');
|
|
@override
|
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
|
'name', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _minCycleMillisMeta =
|
|
const VerificationMeta('minCycleMillis');
|
|
@override
|
|
late final GeneratedColumn<int> minCycleMillis = GeneratedColumn<int>(
|
|
'min_cycle_millis', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _maxCycleMillisMeta =
|
|
const VerificationMeta('maxCycleMillis');
|
|
@override
|
|
late final GeneratedColumn<int> maxCycleMillis = GeneratedColumn<int>(
|
|
'max_cycle_millis', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _intervalMillisMeta =
|
|
const VerificationMeta('intervalMillis');
|
|
@override
|
|
late final GeneratedColumn<int> intervalMillis = GeneratedColumn<int>(
|
|
'interval_millis', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _timeoutMillisMeta =
|
|
const VerificationMeta('timeoutMillis');
|
|
@override
|
|
late final GeneratedColumn<int> timeoutMillis = GeneratedColumn<int>(
|
|
'timeout_millis', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _statusMeta = const VerificationMeta('status');
|
|
@override
|
|
late final GeneratedColumn<String> status = GeneratedColumn<String>(
|
|
'status', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _descriptionMeta =
|
|
const VerificationMeta('description');
|
|
@override
|
|
late final GeneratedColumn<String> description = GeneratedColumn<String>(
|
|
'description', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _lastExecutionMeta =
|
|
const VerificationMeta('lastExecution');
|
|
@override
|
|
late final GeneratedColumn<DateTime> lastExecution =
|
|
GeneratedColumn<DateTime>('last_execution', aliasedName, true,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: false);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
name,
|
|
minCycleMillis,
|
|
maxCycleMillis,
|
|
intervalMillis,
|
|
timeoutMillis,
|
|
status,
|
|
description,
|
|
lastExecution,
|
|
createdAt,
|
|
updatedAt
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'tasks';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<Task> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('name')) {
|
|
context.handle(
|
|
_nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_nameMeta);
|
|
}
|
|
if (data.containsKey('min_cycle_millis')) {
|
|
context.handle(
|
|
_minCycleMillisMeta,
|
|
minCycleMillis.isAcceptableOrUnknown(
|
|
data['min_cycle_millis']!, _minCycleMillisMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_minCycleMillisMeta);
|
|
}
|
|
if (data.containsKey('max_cycle_millis')) {
|
|
context.handle(
|
|
_maxCycleMillisMeta,
|
|
maxCycleMillis.isAcceptableOrUnknown(
|
|
data['max_cycle_millis']!, _maxCycleMillisMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_maxCycleMillisMeta);
|
|
}
|
|
if (data.containsKey('interval_millis')) {
|
|
context.handle(
|
|
_intervalMillisMeta,
|
|
intervalMillis.isAcceptableOrUnknown(
|
|
data['interval_millis']!, _intervalMillisMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_intervalMillisMeta);
|
|
}
|
|
if (data.containsKey('timeout_millis')) {
|
|
context.handle(
|
|
_timeoutMillisMeta,
|
|
timeoutMillis.isAcceptableOrUnknown(
|
|
data['timeout_millis']!, _timeoutMillisMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_timeoutMillisMeta);
|
|
}
|
|
if (data.containsKey('status')) {
|
|
context.handle(_statusMeta,
|
|
status.isAcceptableOrUnknown(data['status']!, _statusMeta));
|
|
}
|
|
if (data.containsKey('description')) {
|
|
context.handle(
|
|
_descriptionMeta,
|
|
description.isAcceptableOrUnknown(
|
|
data['description']!, _descriptionMeta));
|
|
}
|
|
if (data.containsKey('last_execution')) {
|
|
context.handle(
|
|
_lastExecutionMeta,
|
|
lastExecution.isAcceptableOrUnknown(
|
|
data['last_execution']!, _lastExecutionMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
Task map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return Task(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
name: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}name'])!,
|
|
minCycleMillis: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}min_cycle_millis'])!,
|
|
maxCycleMillis: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}max_cycle_millis'])!,
|
|
intervalMillis: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}interval_millis'])!,
|
|
timeoutMillis: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}timeout_millis'])!,
|
|
status: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}status']),
|
|
description: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}description']),
|
|
lastExecution: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.dateTime, data['${effectivePrefix}last_execution']),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$TasksTable createAlias(String alias) {
|
|
return $TasksTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class Task extends DataClass implements Insertable<Task> {
|
|
final int id;
|
|
final String name;
|
|
final int minCycleMillis;
|
|
final int maxCycleMillis;
|
|
final int intervalMillis;
|
|
final int timeoutMillis;
|
|
final String? status;
|
|
final String? description;
|
|
final DateTime? lastExecution;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
const Task(
|
|
{required this.id,
|
|
required this.name,
|
|
required this.minCycleMillis,
|
|
required this.maxCycleMillis,
|
|
required this.intervalMillis,
|
|
required this.timeoutMillis,
|
|
this.status,
|
|
this.description,
|
|
this.lastExecution,
|
|
required this.createdAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['name'] = Variable<String>(name);
|
|
map['min_cycle_millis'] = Variable<int>(minCycleMillis);
|
|
map['max_cycle_millis'] = Variable<int>(maxCycleMillis);
|
|
map['interval_millis'] = Variable<int>(intervalMillis);
|
|
map['timeout_millis'] = Variable<int>(timeoutMillis);
|
|
if (!nullToAbsent || status != null) {
|
|
map['status'] = Variable<String>(status);
|
|
}
|
|
if (!nullToAbsent || description != null) {
|
|
map['description'] = Variable<String>(description);
|
|
}
|
|
if (!nullToAbsent || lastExecution != null) {
|
|
map['last_execution'] = Variable<DateTime>(lastExecution);
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
TasksCompanion toCompanion(bool nullToAbsent) {
|
|
return TasksCompanion(
|
|
id: Value(id),
|
|
name: Value(name),
|
|
minCycleMillis: Value(minCycleMillis),
|
|
maxCycleMillis: Value(maxCycleMillis),
|
|
intervalMillis: Value(intervalMillis),
|
|
timeoutMillis: Value(timeoutMillis),
|
|
status:
|
|
status == null && nullToAbsent ? const Value.absent() : Value(status),
|
|
description: description == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(description),
|
|
lastExecution: lastExecution == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(lastExecution),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory Task.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return Task(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
name: serializer.fromJson<String>(json['name']),
|
|
minCycleMillis: serializer.fromJson<int>(json['minCycleMillis']),
|
|
maxCycleMillis: serializer.fromJson<int>(json['maxCycleMillis']),
|
|
intervalMillis: serializer.fromJson<int>(json['intervalMillis']),
|
|
timeoutMillis: serializer.fromJson<int>(json['timeoutMillis']),
|
|
status: serializer.fromJson<String?>(json['status']),
|
|
description: serializer.fromJson<String?>(json['description']),
|
|
lastExecution: serializer.fromJson<DateTime?>(json['lastExecution']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'name': serializer.toJson<String>(name),
|
|
'minCycleMillis': serializer.toJson<int>(minCycleMillis),
|
|
'maxCycleMillis': serializer.toJson<int>(maxCycleMillis),
|
|
'intervalMillis': serializer.toJson<int>(intervalMillis),
|
|
'timeoutMillis': serializer.toJson<int>(timeoutMillis),
|
|
'status': serializer.toJson<String?>(status),
|
|
'description': serializer.toJson<String?>(description),
|
|
'lastExecution': serializer.toJson<DateTime?>(lastExecution),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
Task copyWith(
|
|
{int? id,
|
|
String? name,
|
|
int? minCycleMillis,
|
|
int? maxCycleMillis,
|
|
int? intervalMillis,
|
|
int? timeoutMillis,
|
|
Value<String?> status = const Value.absent(),
|
|
Value<String?> description = const Value.absent(),
|
|
Value<DateTime?> lastExecution = const Value.absent(),
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt}) =>
|
|
Task(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
minCycleMillis: minCycleMillis ?? this.minCycleMillis,
|
|
maxCycleMillis: maxCycleMillis ?? this.maxCycleMillis,
|
|
intervalMillis: intervalMillis ?? this.intervalMillis,
|
|
timeoutMillis: timeoutMillis ?? this.timeoutMillis,
|
|
status: status.present ? status.value : this.status,
|
|
description: description.present ? description.value : this.description,
|
|
lastExecution:
|
|
lastExecution.present ? lastExecution.value : this.lastExecution,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('Task(')
|
|
..write('id: $id, ')
|
|
..write('name: $name, ')
|
|
..write('minCycleMillis: $minCycleMillis, ')
|
|
..write('maxCycleMillis: $maxCycleMillis, ')
|
|
..write('intervalMillis: $intervalMillis, ')
|
|
..write('timeoutMillis: $timeoutMillis, ')
|
|
..write('status: $status, ')
|
|
..write('description: $description, ')
|
|
..write('lastExecution: $lastExecution, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id,
|
|
name,
|
|
minCycleMillis,
|
|
maxCycleMillis,
|
|
intervalMillis,
|
|
timeoutMillis,
|
|
status,
|
|
description,
|
|
lastExecution,
|
|
createdAt,
|
|
updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is Task &&
|
|
other.id == this.id &&
|
|
other.name == this.name &&
|
|
other.minCycleMillis == this.minCycleMillis &&
|
|
other.maxCycleMillis == this.maxCycleMillis &&
|
|
other.intervalMillis == this.intervalMillis &&
|
|
other.timeoutMillis == this.timeoutMillis &&
|
|
other.status == this.status &&
|
|
other.description == this.description &&
|
|
other.lastExecution == this.lastExecution &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class TasksCompanion extends UpdateCompanion<Task> {
|
|
final Value<int> id;
|
|
final Value<String> name;
|
|
final Value<int> minCycleMillis;
|
|
final Value<int> maxCycleMillis;
|
|
final Value<int> intervalMillis;
|
|
final Value<int> timeoutMillis;
|
|
final Value<String?> status;
|
|
final Value<String?> description;
|
|
final Value<DateTime?> lastExecution;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
const TasksCompanion({
|
|
this.id = const Value.absent(),
|
|
this.name = const Value.absent(),
|
|
this.minCycleMillis = const Value.absent(),
|
|
this.maxCycleMillis = const Value.absent(),
|
|
this.intervalMillis = const Value.absent(),
|
|
this.timeoutMillis = const Value.absent(),
|
|
this.status = const Value.absent(),
|
|
this.description = const Value.absent(),
|
|
this.lastExecution = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
TasksCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String name,
|
|
required int minCycleMillis,
|
|
required int maxCycleMillis,
|
|
required int intervalMillis,
|
|
required int timeoutMillis,
|
|
this.status = const Value.absent(),
|
|
this.description = const Value.absent(),
|
|
this.lastExecution = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : name = Value(name),
|
|
minCycleMillis = Value(minCycleMillis),
|
|
maxCycleMillis = Value(maxCycleMillis),
|
|
intervalMillis = Value(intervalMillis),
|
|
timeoutMillis = Value(timeoutMillis);
|
|
static Insertable<Task> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? name,
|
|
Expression<int>? minCycleMillis,
|
|
Expression<int>? maxCycleMillis,
|
|
Expression<int>? intervalMillis,
|
|
Expression<int>? timeoutMillis,
|
|
Expression<String>? status,
|
|
Expression<String>? description,
|
|
Expression<DateTime>? lastExecution,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (name != null) 'name': name,
|
|
if (minCycleMillis != null) 'min_cycle_millis': minCycleMillis,
|
|
if (maxCycleMillis != null) 'max_cycle_millis': maxCycleMillis,
|
|
if (intervalMillis != null) 'interval_millis': intervalMillis,
|
|
if (timeoutMillis != null) 'timeout_millis': timeoutMillis,
|
|
if (status != null) 'status': status,
|
|
if (description != null) 'description': description,
|
|
if (lastExecution != null) 'last_execution': lastExecution,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
TasksCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String>? name,
|
|
Value<int>? minCycleMillis,
|
|
Value<int>? maxCycleMillis,
|
|
Value<int>? intervalMillis,
|
|
Value<int>? timeoutMillis,
|
|
Value<String?>? status,
|
|
Value<String?>? description,
|
|
Value<DateTime?>? lastExecution,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return TasksCompanion(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
minCycleMillis: minCycleMillis ?? this.minCycleMillis,
|
|
maxCycleMillis: maxCycleMillis ?? this.maxCycleMillis,
|
|
intervalMillis: intervalMillis ?? this.intervalMillis,
|
|
timeoutMillis: timeoutMillis ?? this.timeoutMillis,
|
|
status: status ?? this.status,
|
|
description: description ?? this.description,
|
|
lastExecution: lastExecution ?? this.lastExecution,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (name.present) {
|
|
map['name'] = Variable<String>(name.value);
|
|
}
|
|
if (minCycleMillis.present) {
|
|
map['min_cycle_millis'] = Variable<int>(minCycleMillis.value);
|
|
}
|
|
if (maxCycleMillis.present) {
|
|
map['max_cycle_millis'] = Variable<int>(maxCycleMillis.value);
|
|
}
|
|
if (intervalMillis.present) {
|
|
map['interval_millis'] = Variable<int>(intervalMillis.value);
|
|
}
|
|
if (timeoutMillis.present) {
|
|
map['timeout_millis'] = Variable<int>(timeoutMillis.value);
|
|
}
|
|
if (status.present) {
|
|
map['status'] = Variable<String>(status.value);
|
|
}
|
|
if (description.present) {
|
|
map['description'] = Variable<String>(description.value);
|
|
}
|
|
if (lastExecution.present) {
|
|
map['last_execution'] = Variable<DateTime>(lastExecution.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('TasksCompanion(')
|
|
..write('id: $id, ')
|
|
..write('name: $name, ')
|
|
..write('minCycleMillis: $minCycleMillis, ')
|
|
..write('maxCycleMillis: $maxCycleMillis, ')
|
|
..write('intervalMillis: $intervalMillis, ')
|
|
..write('timeoutMillis: $timeoutMillis, ')
|
|
..write('status: $status, ')
|
|
..write('description: $description, ')
|
|
..write('lastExecution: $lastExecution, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $UserTasksTable extends UserTasks
|
|
with TableInfo<$UserTasksTable, UserTask> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$UserTasksTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _titleMeta = const VerificationMeta('title');
|
|
@override
|
|
late final GeneratedColumn<String> title = GeneratedColumn<String>(
|
|
'title', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _descriptionMeta =
|
|
const VerificationMeta('description');
|
|
@override
|
|
late final GeneratedColumn<String> description = GeneratedColumn<String>(
|
|
'description', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _typeMeta = const VerificationMeta('type');
|
|
@override
|
|
late final GeneratedColumn<String> type = GeneratedColumn<String>(
|
|
'type', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _difficultyMeta =
|
|
const VerificationMeta('difficulty');
|
|
@override
|
|
late final GeneratedColumn<String> difficulty = GeneratedColumn<String>(
|
|
'difficulty', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _statusMeta = const VerificationMeta('status');
|
|
@override
|
|
late final GeneratedColumn<String> status = GeneratedColumn<String>(
|
|
'status', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _rewardsMeta =
|
|
const VerificationMeta('rewards');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<dynamic>?, String> rewards =
|
|
GeneratedColumn<String>('rewards', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<dynamic>?>($UserTasksTable.$converterrewards);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _expiresAtMeta =
|
|
const VerificationMeta('expiresAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> expiresAt = GeneratedColumn<DateTime>(
|
|
'expires_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
static const VerificationMeta _completedAtMeta =
|
|
const VerificationMeta('completedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> completedAt = GeneratedColumn<DateTime>(
|
|
'completed_at', aliasedName, true,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: false);
|
|
static const VerificationMeta _proofUrlMeta =
|
|
const VerificationMeta('proofUrl');
|
|
@override
|
|
late final GeneratedColumn<String> proofUrl = GeneratedColumn<String>(
|
|
'proof_url', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _instructionsMeta =
|
|
const VerificationMeta('instructions');
|
|
@override
|
|
late final GeneratedColumn<String> instructions = GeneratedColumn<String>(
|
|
'instructions', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _tagsMeta = const VerificationMeta('tags');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<String>, String> tags =
|
|
GeneratedColumn<String>('tags', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<String>>($UserTasksTable.$convertertags);
|
|
static const VerificationMeta _imageUrlMeta =
|
|
const VerificationMeta('imageUrl');
|
|
@override
|
|
late final GeneratedColumn<String> imageUrl = GeneratedColumn<String>(
|
|
'image_url', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
title,
|
|
description,
|
|
type,
|
|
difficulty,
|
|
status,
|
|
rewards,
|
|
createdAt,
|
|
expiresAt,
|
|
completedAt,
|
|
proofUrl,
|
|
instructions,
|
|
tags,
|
|
imageUrl,
|
|
updatedAt
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'user_tasks';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<UserTask> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('title')) {
|
|
context.handle(
|
|
_titleMeta, title.isAcceptableOrUnknown(data['title']!, _titleMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_titleMeta);
|
|
}
|
|
if (data.containsKey('description')) {
|
|
context.handle(
|
|
_descriptionMeta,
|
|
description.isAcceptableOrUnknown(
|
|
data['description']!, _descriptionMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_descriptionMeta);
|
|
}
|
|
if (data.containsKey('type')) {
|
|
context.handle(
|
|
_typeMeta, type.isAcceptableOrUnknown(data['type']!, _typeMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_typeMeta);
|
|
}
|
|
if (data.containsKey('difficulty')) {
|
|
context.handle(
|
|
_difficultyMeta,
|
|
difficulty.isAcceptableOrUnknown(
|
|
data['difficulty']!, _difficultyMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_difficultyMeta);
|
|
}
|
|
if (data.containsKey('status')) {
|
|
context.handle(_statusMeta,
|
|
status.isAcceptableOrUnknown(data['status']!, _statusMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_statusMeta);
|
|
}
|
|
context.handle(_rewardsMeta, const VerificationResult.success());
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('expires_at')) {
|
|
context.handle(_expiresAtMeta,
|
|
expiresAt.isAcceptableOrUnknown(data['expires_at']!, _expiresAtMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_expiresAtMeta);
|
|
}
|
|
if (data.containsKey('completed_at')) {
|
|
context.handle(
|
|
_completedAtMeta,
|
|
completedAt.isAcceptableOrUnknown(
|
|
data['completed_at']!, _completedAtMeta));
|
|
}
|
|
if (data.containsKey('proof_url')) {
|
|
context.handle(_proofUrlMeta,
|
|
proofUrl.isAcceptableOrUnknown(data['proof_url']!, _proofUrlMeta));
|
|
}
|
|
if (data.containsKey('instructions')) {
|
|
context.handle(
|
|
_instructionsMeta,
|
|
instructions.isAcceptableOrUnknown(
|
|
data['instructions']!, _instructionsMeta));
|
|
}
|
|
context.handle(_tagsMeta, const VerificationResult.success());
|
|
if (data.containsKey('image_url')) {
|
|
context.handle(_imageUrlMeta,
|
|
imageUrl.isAcceptableOrUnknown(data['image_url']!, _imageUrlMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
UserTask map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return UserTask(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
title: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}title'])!,
|
|
description: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}description'])!,
|
|
type: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}type'])!,
|
|
difficulty: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}difficulty'])!,
|
|
status: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}status'])!,
|
|
rewards: $UserTasksTable.$converterrewards.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}rewards'])!),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
expiresAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}expires_at'])!,
|
|
completedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}completed_at']),
|
|
proofUrl: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}proof_url']),
|
|
instructions: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}instructions']),
|
|
tags: $UserTasksTable.$convertertags.fromSql(attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}tags'])!),
|
|
imageUrl: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}image_url']),
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$UserTasksTable createAlias(String alias) {
|
|
return $UserTasksTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<List<dynamic>?, String> $converterrewards =
|
|
const JsonListConverter();
|
|
static TypeConverter<List<String>, String> $convertertags =
|
|
const StringListConverter();
|
|
}
|
|
|
|
class UserTask extends DataClass implements Insertable<UserTask> {
|
|
final int id;
|
|
final String title;
|
|
final String description;
|
|
final String type;
|
|
final String difficulty;
|
|
final String status;
|
|
final List<dynamic>? rewards;
|
|
final DateTime createdAt;
|
|
final DateTime expiresAt;
|
|
final DateTime? completedAt;
|
|
final String? proofUrl;
|
|
final String? instructions;
|
|
final List<String> tags;
|
|
final String? imageUrl;
|
|
final DateTime updatedAt;
|
|
const UserTask(
|
|
{required this.id,
|
|
required this.title,
|
|
required this.description,
|
|
required this.type,
|
|
required this.difficulty,
|
|
required this.status,
|
|
this.rewards,
|
|
required this.createdAt,
|
|
required this.expiresAt,
|
|
this.completedAt,
|
|
this.proofUrl,
|
|
this.instructions,
|
|
required this.tags,
|
|
this.imageUrl,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['title'] = Variable<String>(title);
|
|
map['description'] = Variable<String>(description);
|
|
map['type'] = Variable<String>(type);
|
|
map['difficulty'] = Variable<String>(difficulty);
|
|
map['status'] = Variable<String>(status);
|
|
if (!nullToAbsent || rewards != null) {
|
|
map['rewards'] =
|
|
Variable<String>($UserTasksTable.$converterrewards.toSql(rewards));
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['expires_at'] = Variable<DateTime>(expiresAt);
|
|
if (!nullToAbsent || completedAt != null) {
|
|
map['completed_at'] = Variable<DateTime>(completedAt);
|
|
}
|
|
if (!nullToAbsent || proofUrl != null) {
|
|
map['proof_url'] = Variable<String>(proofUrl);
|
|
}
|
|
if (!nullToAbsent || instructions != null) {
|
|
map['instructions'] = Variable<String>(instructions);
|
|
}
|
|
{
|
|
map['tags'] =
|
|
Variable<String>($UserTasksTable.$convertertags.toSql(tags));
|
|
}
|
|
if (!nullToAbsent || imageUrl != null) {
|
|
map['image_url'] = Variable<String>(imageUrl);
|
|
}
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
UserTasksCompanion toCompanion(bool nullToAbsent) {
|
|
return UserTasksCompanion(
|
|
id: Value(id),
|
|
title: Value(title),
|
|
description: Value(description),
|
|
type: Value(type),
|
|
difficulty: Value(difficulty),
|
|
status: Value(status),
|
|
rewards: rewards == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(rewards),
|
|
createdAt: Value(createdAt),
|
|
expiresAt: Value(expiresAt),
|
|
completedAt: completedAt == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(completedAt),
|
|
proofUrl: proofUrl == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(proofUrl),
|
|
instructions: instructions == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(instructions),
|
|
tags: Value(tags),
|
|
imageUrl: imageUrl == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(imageUrl),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory UserTask.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return UserTask(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
title: serializer.fromJson<String>(json['title']),
|
|
description: serializer.fromJson<String>(json['description']),
|
|
type: serializer.fromJson<String>(json['type']),
|
|
difficulty: serializer.fromJson<String>(json['difficulty']),
|
|
status: serializer.fromJson<String>(json['status']),
|
|
rewards: serializer.fromJson<List<dynamic>?>(json['rewards']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
expiresAt: serializer.fromJson<DateTime>(json['expiresAt']),
|
|
completedAt: serializer.fromJson<DateTime?>(json['completedAt']),
|
|
proofUrl: serializer.fromJson<String?>(json['proofUrl']),
|
|
instructions: serializer.fromJson<String?>(json['instructions']),
|
|
tags: serializer.fromJson<List<String>>(json['tags']),
|
|
imageUrl: serializer.fromJson<String?>(json['imageUrl']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'title': serializer.toJson<String>(title),
|
|
'description': serializer.toJson<String>(description),
|
|
'type': serializer.toJson<String>(type),
|
|
'difficulty': serializer.toJson<String>(difficulty),
|
|
'status': serializer.toJson<String>(status),
|
|
'rewards': serializer.toJson<List<dynamic>?>(rewards),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'expiresAt': serializer.toJson<DateTime>(expiresAt),
|
|
'completedAt': serializer.toJson<DateTime?>(completedAt),
|
|
'proofUrl': serializer.toJson<String?>(proofUrl),
|
|
'instructions': serializer.toJson<String?>(instructions),
|
|
'tags': serializer.toJson<List<String>>(tags),
|
|
'imageUrl': serializer.toJson<String?>(imageUrl),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
UserTask copyWith(
|
|
{int? id,
|
|
String? title,
|
|
String? description,
|
|
String? type,
|
|
String? difficulty,
|
|
String? status,
|
|
Value<List<dynamic>?> rewards = const Value.absent(),
|
|
DateTime? createdAt,
|
|
DateTime? expiresAt,
|
|
Value<DateTime?> completedAt = const Value.absent(),
|
|
Value<String?> proofUrl = const Value.absent(),
|
|
Value<String?> instructions = const Value.absent(),
|
|
List<String>? tags,
|
|
Value<String?> imageUrl = const Value.absent(),
|
|
DateTime? updatedAt}) =>
|
|
UserTask(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
description: description ?? this.description,
|
|
type: type ?? this.type,
|
|
difficulty: difficulty ?? this.difficulty,
|
|
status: status ?? this.status,
|
|
rewards: rewards.present ? rewards.value : this.rewards,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
expiresAt: expiresAt ?? this.expiresAt,
|
|
completedAt: completedAt.present ? completedAt.value : this.completedAt,
|
|
proofUrl: proofUrl.present ? proofUrl.value : this.proofUrl,
|
|
instructions:
|
|
instructions.present ? instructions.value : this.instructions,
|
|
tags: tags ?? this.tags,
|
|
imageUrl: imageUrl.present ? imageUrl.value : this.imageUrl,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserTask(')
|
|
..write('id: $id, ')
|
|
..write('title: $title, ')
|
|
..write('description: $description, ')
|
|
..write('type: $type, ')
|
|
..write('difficulty: $difficulty, ')
|
|
..write('status: $status, ')
|
|
..write('rewards: $rewards, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('expiresAt: $expiresAt, ')
|
|
..write('completedAt: $completedAt, ')
|
|
..write('proofUrl: $proofUrl, ')
|
|
..write('instructions: $instructions, ')
|
|
..write('tags: $tags, ')
|
|
..write('imageUrl: $imageUrl, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id,
|
|
title,
|
|
description,
|
|
type,
|
|
difficulty,
|
|
status,
|
|
rewards,
|
|
createdAt,
|
|
expiresAt,
|
|
completedAt,
|
|
proofUrl,
|
|
instructions,
|
|
tags,
|
|
imageUrl,
|
|
updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is UserTask &&
|
|
other.id == this.id &&
|
|
other.title == this.title &&
|
|
other.description == this.description &&
|
|
other.type == this.type &&
|
|
other.difficulty == this.difficulty &&
|
|
other.status == this.status &&
|
|
other.rewards == this.rewards &&
|
|
other.createdAt == this.createdAt &&
|
|
other.expiresAt == this.expiresAt &&
|
|
other.completedAt == this.completedAt &&
|
|
other.proofUrl == this.proofUrl &&
|
|
other.instructions == this.instructions &&
|
|
other.tags == this.tags &&
|
|
other.imageUrl == this.imageUrl &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class UserTasksCompanion extends UpdateCompanion<UserTask> {
|
|
final Value<int> id;
|
|
final Value<String> title;
|
|
final Value<String> description;
|
|
final Value<String> type;
|
|
final Value<String> difficulty;
|
|
final Value<String> status;
|
|
final Value<List<dynamic>?> rewards;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> expiresAt;
|
|
final Value<DateTime?> completedAt;
|
|
final Value<String?> proofUrl;
|
|
final Value<String?> instructions;
|
|
final Value<List<String>> tags;
|
|
final Value<String?> imageUrl;
|
|
final Value<DateTime> updatedAt;
|
|
const UserTasksCompanion({
|
|
this.id = const Value.absent(),
|
|
this.title = const Value.absent(),
|
|
this.description = const Value.absent(),
|
|
this.type = const Value.absent(),
|
|
this.difficulty = const Value.absent(),
|
|
this.status = const Value.absent(),
|
|
this.rewards = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.expiresAt = const Value.absent(),
|
|
this.completedAt = const Value.absent(),
|
|
this.proofUrl = const Value.absent(),
|
|
this.instructions = const Value.absent(),
|
|
this.tags = const Value.absent(),
|
|
this.imageUrl = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
UserTasksCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String title,
|
|
required String description,
|
|
required String type,
|
|
required String difficulty,
|
|
required String status,
|
|
this.rewards = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
required DateTime expiresAt,
|
|
this.completedAt = const Value.absent(),
|
|
this.proofUrl = const Value.absent(),
|
|
this.instructions = const Value.absent(),
|
|
this.tags = const Value.absent(),
|
|
this.imageUrl = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : title = Value(title),
|
|
description = Value(description),
|
|
type = Value(type),
|
|
difficulty = Value(difficulty),
|
|
status = Value(status),
|
|
expiresAt = Value(expiresAt);
|
|
static Insertable<UserTask> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? title,
|
|
Expression<String>? description,
|
|
Expression<String>? type,
|
|
Expression<String>? difficulty,
|
|
Expression<String>? status,
|
|
Expression<String>? rewards,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? expiresAt,
|
|
Expression<DateTime>? completedAt,
|
|
Expression<String>? proofUrl,
|
|
Expression<String>? instructions,
|
|
Expression<String>? tags,
|
|
Expression<String>? imageUrl,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (title != null) 'title': title,
|
|
if (description != null) 'description': description,
|
|
if (type != null) 'type': type,
|
|
if (difficulty != null) 'difficulty': difficulty,
|
|
if (status != null) 'status': status,
|
|
if (rewards != null) 'rewards': rewards,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (expiresAt != null) 'expires_at': expiresAt,
|
|
if (completedAt != null) 'completed_at': completedAt,
|
|
if (proofUrl != null) 'proof_url': proofUrl,
|
|
if (instructions != null) 'instructions': instructions,
|
|
if (tags != null) 'tags': tags,
|
|
if (imageUrl != null) 'image_url': imageUrl,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
UserTasksCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String>? title,
|
|
Value<String>? description,
|
|
Value<String>? type,
|
|
Value<String>? difficulty,
|
|
Value<String>? status,
|
|
Value<List<dynamic>?>? rewards,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? expiresAt,
|
|
Value<DateTime?>? completedAt,
|
|
Value<String?>? proofUrl,
|
|
Value<String?>? instructions,
|
|
Value<List<String>>? tags,
|
|
Value<String?>? imageUrl,
|
|
Value<DateTime>? updatedAt}) {
|
|
return UserTasksCompanion(
|
|
id: id ?? this.id,
|
|
title: title ?? this.title,
|
|
description: description ?? this.description,
|
|
type: type ?? this.type,
|
|
difficulty: difficulty ?? this.difficulty,
|
|
status: status ?? this.status,
|
|
rewards: rewards ?? this.rewards,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
expiresAt: expiresAt ?? this.expiresAt,
|
|
completedAt: completedAt ?? this.completedAt,
|
|
proofUrl: proofUrl ?? this.proofUrl,
|
|
instructions: instructions ?? this.instructions,
|
|
tags: tags ?? this.tags,
|
|
imageUrl: imageUrl ?? this.imageUrl,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (title.present) {
|
|
map['title'] = Variable<String>(title.value);
|
|
}
|
|
if (description.present) {
|
|
map['description'] = Variable<String>(description.value);
|
|
}
|
|
if (type.present) {
|
|
map['type'] = Variable<String>(type.value);
|
|
}
|
|
if (difficulty.present) {
|
|
map['difficulty'] = Variable<String>(difficulty.value);
|
|
}
|
|
if (status.present) {
|
|
map['status'] = Variable<String>(status.value);
|
|
}
|
|
if (rewards.present) {
|
|
map['rewards'] = Variable<String>(
|
|
$UserTasksTable.$converterrewards.toSql(rewards.value));
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (expiresAt.present) {
|
|
map['expires_at'] = Variable<DateTime>(expiresAt.value);
|
|
}
|
|
if (completedAt.present) {
|
|
map['completed_at'] = Variable<DateTime>(completedAt.value);
|
|
}
|
|
if (proofUrl.present) {
|
|
map['proof_url'] = Variable<String>(proofUrl.value);
|
|
}
|
|
if (instructions.present) {
|
|
map['instructions'] = Variable<String>(instructions.value);
|
|
}
|
|
if (tags.present) {
|
|
map['tags'] =
|
|
Variable<String>($UserTasksTable.$convertertags.toSql(tags.value));
|
|
}
|
|
if (imageUrl.present) {
|
|
map['image_url'] = Variable<String>(imageUrl.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserTasksCompanion(')
|
|
..write('id: $id, ')
|
|
..write('title: $title, ')
|
|
..write('description: $description, ')
|
|
..write('type: $type, ')
|
|
..write('difficulty: $difficulty, ')
|
|
..write('status: $status, ')
|
|
..write('rewards: $rewards, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('expiresAt: $expiresAt, ')
|
|
..write('completedAt: $completedAt, ')
|
|
..write('proofUrl: $proofUrl, ')
|
|
..write('instructions: $instructions, ')
|
|
..write('tags: $tags, ')
|
|
..write('imageUrl: $imageUrl, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $UserTaskProgressesTable extends UserTaskProgresses
|
|
with TableInfo<$UserTaskProgressesTable, UserTaskProgresses> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$UserTaskProgressesTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _taskIdMeta = const VerificationMeta('taskId');
|
|
@override
|
|
late final GeneratedColumn<int> taskId = GeneratedColumn<int>(
|
|
'task_id', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _progressMeta =
|
|
const VerificationMeta('progress');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<Map<String, dynamic>?, String>
|
|
progress = GeneratedColumn<String>('progress', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('{}'))
|
|
.withConverter<Map<String, dynamic>?>(
|
|
$UserTaskProgressesTable.$converterprogress);
|
|
static const VerificationMeta _startedAtMeta =
|
|
const VerificationMeta('startedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> startedAt = GeneratedColumn<DateTime>(
|
|
'started_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, userId, taskId, progress, startedAt, updatedAt];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'user_task_progresses';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<UserTaskProgresses> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('task_id')) {
|
|
context.handle(_taskIdMeta,
|
|
taskId.isAcceptableOrUnknown(data['task_id']!, _taskIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_taskIdMeta);
|
|
}
|
|
context.handle(_progressMeta, const VerificationResult.success());
|
|
if (data.containsKey('started_at')) {
|
|
context.handle(_startedAtMeta,
|
|
startedAt.isAcceptableOrUnknown(data['started_at']!, _startedAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
UserTaskProgresses map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return UserTaskProgresses(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
taskId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}task_id'])!,
|
|
progress: $UserTaskProgressesTable.$converterprogress.fromSql(
|
|
attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}progress'])!),
|
|
startedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}started_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$UserTaskProgressesTable createAlias(String alias) {
|
|
return $UserTaskProgressesTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<Map<String, dynamic>?, String> $converterprogress =
|
|
const JsonMapConverter();
|
|
}
|
|
|
|
class UserTaskProgresses extends DataClass
|
|
implements Insertable<UserTaskProgresses> {
|
|
final int id;
|
|
final int userId;
|
|
final int taskId;
|
|
final Map<String, dynamic>? progress;
|
|
final DateTime startedAt;
|
|
final DateTime updatedAt;
|
|
const UserTaskProgresses(
|
|
{required this.id,
|
|
required this.userId,
|
|
required this.taskId,
|
|
this.progress,
|
|
required this.startedAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['task_id'] = Variable<int>(taskId);
|
|
if (!nullToAbsent || progress != null) {
|
|
map['progress'] = Variable<String>(
|
|
$UserTaskProgressesTable.$converterprogress.toSql(progress));
|
|
}
|
|
map['started_at'] = Variable<DateTime>(startedAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
UserTaskProgressesCompanion toCompanion(bool nullToAbsent) {
|
|
return UserTaskProgressesCompanion(
|
|
id: Value(id),
|
|
userId: Value(userId),
|
|
taskId: Value(taskId),
|
|
progress: progress == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(progress),
|
|
startedAt: Value(startedAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory UserTaskProgresses.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return UserTaskProgresses(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
taskId: serializer.fromJson<int>(json['taskId']),
|
|
progress: serializer.fromJson<Map<String, dynamic>?>(json['progress']),
|
|
startedAt: serializer.fromJson<DateTime>(json['startedAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'taskId': serializer.toJson<int>(taskId),
|
|
'progress': serializer.toJson<Map<String, dynamic>?>(progress),
|
|
'startedAt': serializer.toJson<DateTime>(startedAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
UserTaskProgresses copyWith(
|
|
{int? id,
|
|
int? userId,
|
|
int? taskId,
|
|
Value<Map<String, dynamic>?> progress = const Value.absent(),
|
|
DateTime? startedAt,
|
|
DateTime? updatedAt}) =>
|
|
UserTaskProgresses(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
taskId: taskId ?? this.taskId,
|
|
progress: progress.present ? progress.value : this.progress,
|
|
startedAt: startedAt ?? this.startedAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserTaskProgresses(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('taskId: $taskId, ')
|
|
..write('progress: $progress, ')
|
|
..write('startedAt: $startedAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode =>
|
|
Object.hash(id, userId, taskId, progress, startedAt, updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is UserTaskProgresses &&
|
|
other.id == this.id &&
|
|
other.userId == this.userId &&
|
|
other.taskId == this.taskId &&
|
|
other.progress == this.progress &&
|
|
other.startedAt == this.startedAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class UserTaskProgressesCompanion extends UpdateCompanion<UserTaskProgresses> {
|
|
final Value<int> id;
|
|
final Value<int> userId;
|
|
final Value<int> taskId;
|
|
final Value<Map<String, dynamic>?> progress;
|
|
final Value<DateTime> startedAt;
|
|
final Value<DateTime> updatedAt;
|
|
const UserTaskProgressesCompanion({
|
|
this.id = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.taskId = const Value.absent(),
|
|
this.progress = const Value.absent(),
|
|
this.startedAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
UserTaskProgressesCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int userId,
|
|
required int taskId,
|
|
this.progress = const Value.absent(),
|
|
this.startedAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : userId = Value(userId),
|
|
taskId = Value(taskId);
|
|
static Insertable<UserTaskProgresses> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? userId,
|
|
Expression<int>? taskId,
|
|
Expression<String>? progress,
|
|
Expression<DateTime>? startedAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'user_id': userId,
|
|
if (taskId != null) 'task_id': taskId,
|
|
if (progress != null) 'progress': progress,
|
|
if (startedAt != null) 'started_at': startedAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
UserTaskProgressesCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? userId,
|
|
Value<int>? taskId,
|
|
Value<Map<String, dynamic>?>? progress,
|
|
Value<DateTime>? startedAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return UserTaskProgressesCompanion(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
taskId: taskId ?? this.taskId,
|
|
progress: progress ?? this.progress,
|
|
startedAt: startedAt ?? this.startedAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (taskId.present) {
|
|
map['task_id'] = Variable<int>(taskId.value);
|
|
}
|
|
if (progress.present) {
|
|
map['progress'] = Variable<String>(
|
|
$UserTaskProgressesTable.$converterprogress.toSql(progress.value));
|
|
}
|
|
if (startedAt.present) {
|
|
map['started_at'] = Variable<DateTime>(startedAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserTaskProgressesCompanion(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('taskId: $taskId, ')
|
|
..write('progress: $progress, ')
|
|
..write('startedAt: $startedAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $UserTaskResultsTable extends UserTaskResults
|
|
with TableInfo<$UserTaskResultsTable, UserTaskResult> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$UserTaskResultsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _taskIdMeta = const VerificationMeta('taskId');
|
|
@override
|
|
late final GeneratedColumn<int> taskId = GeneratedColumn<int>(
|
|
'task_id', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _resultsMeta =
|
|
const VerificationMeta('results');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<Map<String, dynamic>?, String>
|
|
results = GeneratedColumn<String>('results', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('{}'))
|
|
.withConverter<Map<String, dynamic>?>(
|
|
$UserTaskResultsTable.$converterresults);
|
|
static const VerificationMeta _completedAtMeta =
|
|
const VerificationMeta('completedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> completedAt = GeneratedColumn<DateTime>(
|
|
'completed_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, userId, taskId, results, completedAt, createdAt];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'user_task_results';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<UserTaskResult> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('task_id')) {
|
|
context.handle(_taskIdMeta,
|
|
taskId.isAcceptableOrUnknown(data['task_id']!, _taskIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_taskIdMeta);
|
|
}
|
|
context.handle(_resultsMeta, const VerificationResult.success());
|
|
if (data.containsKey('completed_at')) {
|
|
context.handle(
|
|
_completedAtMeta,
|
|
completedAt.isAcceptableOrUnknown(
|
|
data['completed_at']!, _completedAtMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
UserTaskResult map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return UserTaskResult(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
taskId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}task_id'])!,
|
|
results: $UserTaskResultsTable.$converterresults.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}results'])!),
|
|
completedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}completed_at'])!,
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$UserTaskResultsTable createAlias(String alias) {
|
|
return $UserTaskResultsTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<Map<String, dynamic>?, String> $converterresults =
|
|
const JsonMapConverter();
|
|
}
|
|
|
|
class UserTaskResult extends DataClass implements Insertable<UserTaskResult> {
|
|
final int id;
|
|
final int userId;
|
|
final int taskId;
|
|
final Map<String, dynamic>? results;
|
|
final DateTime completedAt;
|
|
final DateTime createdAt;
|
|
const UserTaskResult(
|
|
{required this.id,
|
|
required this.userId,
|
|
required this.taskId,
|
|
this.results,
|
|
required this.completedAt,
|
|
required this.createdAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['task_id'] = Variable<int>(taskId);
|
|
if (!nullToAbsent || results != null) {
|
|
map['results'] = Variable<String>(
|
|
$UserTaskResultsTable.$converterresults.toSql(results));
|
|
}
|
|
map['completed_at'] = Variable<DateTime>(completedAt);
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
return map;
|
|
}
|
|
|
|
UserTaskResultsCompanion toCompanion(bool nullToAbsent) {
|
|
return UserTaskResultsCompanion(
|
|
id: Value(id),
|
|
userId: Value(userId),
|
|
taskId: Value(taskId),
|
|
results: results == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(results),
|
|
completedAt: Value(completedAt),
|
|
createdAt: Value(createdAt),
|
|
);
|
|
}
|
|
|
|
factory UserTaskResult.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return UserTaskResult(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
taskId: serializer.fromJson<int>(json['taskId']),
|
|
results: serializer.fromJson<Map<String, dynamic>?>(json['results']),
|
|
completedAt: serializer.fromJson<DateTime>(json['completedAt']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'taskId': serializer.toJson<int>(taskId),
|
|
'results': serializer.toJson<Map<String, dynamic>?>(results),
|
|
'completedAt': serializer.toJson<DateTime>(completedAt),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
};
|
|
}
|
|
|
|
UserTaskResult copyWith(
|
|
{int? id,
|
|
int? userId,
|
|
int? taskId,
|
|
Value<Map<String, dynamic>?> results = const Value.absent(),
|
|
DateTime? completedAt,
|
|
DateTime? createdAt}) =>
|
|
UserTaskResult(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
taskId: taskId ?? this.taskId,
|
|
results: results.present ? results.value : this.results,
|
|
completedAt: completedAt ?? this.completedAt,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserTaskResult(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('taskId: $taskId, ')
|
|
..write('results: $results, ')
|
|
..write('completedAt: $completedAt, ')
|
|
..write('createdAt: $createdAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode =>
|
|
Object.hash(id, userId, taskId, results, completedAt, createdAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is UserTaskResult &&
|
|
other.id == this.id &&
|
|
other.userId == this.userId &&
|
|
other.taskId == this.taskId &&
|
|
other.results == this.results &&
|
|
other.completedAt == this.completedAt &&
|
|
other.createdAt == this.createdAt);
|
|
}
|
|
|
|
class UserTaskResultsCompanion extends UpdateCompanion<UserTaskResult> {
|
|
final Value<int> id;
|
|
final Value<int> userId;
|
|
final Value<int> taskId;
|
|
final Value<Map<String, dynamic>?> results;
|
|
final Value<DateTime> completedAt;
|
|
final Value<DateTime> createdAt;
|
|
const UserTaskResultsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.taskId = const Value.absent(),
|
|
this.results = const Value.absent(),
|
|
this.completedAt = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
});
|
|
UserTaskResultsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int userId,
|
|
required int taskId,
|
|
this.results = const Value.absent(),
|
|
this.completedAt = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
}) : userId = Value(userId),
|
|
taskId = Value(taskId);
|
|
static Insertable<UserTaskResult> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? userId,
|
|
Expression<int>? taskId,
|
|
Expression<String>? results,
|
|
Expression<DateTime>? completedAt,
|
|
Expression<DateTime>? createdAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'user_id': userId,
|
|
if (taskId != null) 'task_id': taskId,
|
|
if (results != null) 'results': results,
|
|
if (completedAt != null) 'completed_at': completedAt,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
});
|
|
}
|
|
|
|
UserTaskResultsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? userId,
|
|
Value<int>? taskId,
|
|
Value<Map<String, dynamic>?>? results,
|
|
Value<DateTime>? completedAt,
|
|
Value<DateTime>? createdAt}) {
|
|
return UserTaskResultsCompanion(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
taskId: taskId ?? this.taskId,
|
|
results: results ?? this.results,
|
|
completedAt: completedAt ?? this.completedAt,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (taskId.present) {
|
|
map['task_id'] = Variable<int>(taskId.value);
|
|
}
|
|
if (results.present) {
|
|
map['results'] = Variable<String>(
|
|
$UserTaskResultsTable.$converterresults.toSql(results.value));
|
|
}
|
|
if (completedAt.present) {
|
|
map['completed_at'] = Variable<DateTime>(completedAt.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserTaskResultsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('taskId: $taskId, ')
|
|
..write('results: $results, ')
|
|
..write('completedAt: $completedAt, ')
|
|
..write('createdAt: $createdAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $PromoCodesCampaignsTable extends PromoCodesCampaigns
|
|
with TableInfo<$PromoCodesCampaignsTable, PromoCodesCampaign> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$PromoCodesCampaignsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _templateMeta =
|
|
const VerificationMeta('template');
|
|
@override
|
|
late final GeneratedColumn<String> template = GeneratedColumn<String>(
|
|
'template', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _nameMeta = const VerificationMeta('name');
|
|
@override
|
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
|
'name', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _productsMeta =
|
|
const VerificationMeta('products');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<dynamic>?, String> products =
|
|
GeneratedColumn<String>('products', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<dynamic>?>(
|
|
$PromoCodesCampaignsTable.$converterproducts);
|
|
static const VerificationMeta _activationsPerCodeMeta =
|
|
const VerificationMeta('activationsPerCode');
|
|
@override
|
|
late final GeneratedColumn<int> activationsPerCode = GeneratedColumn<int>(
|
|
'activations_per_code', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _activationsPerUserMeta =
|
|
const VerificationMeta('activationsPerUser');
|
|
@override
|
|
late final GeneratedColumn<int> activationsPerUser = GeneratedColumn<int>(
|
|
'activations_per_user', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _generationSizeMeta =
|
|
const VerificationMeta('generationSize');
|
|
@override
|
|
late final GeneratedColumn<int> generationSize = GeneratedColumn<int>(
|
|
'generation_size', aliasedName, false,
|
|
type: DriftSqlType.int, requiredDuringInsert: true);
|
|
static const VerificationMeta _startMeta = const VerificationMeta('start');
|
|
@override
|
|
late final GeneratedColumn<DateTime> start = GeneratedColumn<DateTime>(
|
|
'start', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
static const VerificationMeta _finishMeta = const VerificationMeta('finish');
|
|
@override
|
|
late final GeneratedColumn<DateTime> finish = GeneratedColumn<DateTime>(
|
|
'finish', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
static const VerificationMeta _statusMeta = const VerificationMeta('status');
|
|
@override
|
|
late final GeneratedColumn<String> status = GeneratedColumn<String>(
|
|
'status', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _tagsMeta = const VerificationMeta('tags');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<String>, String> tags =
|
|
GeneratedColumn<String>('tags', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<String>>(
|
|
$PromoCodesCampaignsTable.$convertertags);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _isDeletedMeta =
|
|
const VerificationMeta('isDeleted');
|
|
@override
|
|
late final GeneratedColumn<bool> isDeleted = GeneratedColumn<bool>(
|
|
'is_deleted', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("is_deleted" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
template,
|
|
name,
|
|
products,
|
|
activationsPerCode,
|
|
activationsPerUser,
|
|
generationSize,
|
|
start,
|
|
finish,
|
|
status,
|
|
tags,
|
|
createdAt,
|
|
updatedAt,
|
|
isDeleted
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'promo_codes_campaigns';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<PromoCodesCampaign> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('template')) {
|
|
context.handle(_templateMeta,
|
|
template.isAcceptableOrUnknown(data['template']!, _templateMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_templateMeta);
|
|
}
|
|
if (data.containsKey('name')) {
|
|
context.handle(
|
|
_nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta));
|
|
}
|
|
context.handle(_productsMeta, const VerificationResult.success());
|
|
if (data.containsKey('activations_per_code')) {
|
|
context.handle(
|
|
_activationsPerCodeMeta,
|
|
activationsPerCode.isAcceptableOrUnknown(
|
|
data['activations_per_code']!, _activationsPerCodeMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_activationsPerCodeMeta);
|
|
}
|
|
if (data.containsKey('activations_per_user')) {
|
|
context.handle(
|
|
_activationsPerUserMeta,
|
|
activationsPerUser.isAcceptableOrUnknown(
|
|
data['activations_per_user']!, _activationsPerUserMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_activationsPerUserMeta);
|
|
}
|
|
if (data.containsKey('generation_size')) {
|
|
context.handle(
|
|
_generationSizeMeta,
|
|
generationSize.isAcceptableOrUnknown(
|
|
data['generation_size']!, _generationSizeMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_generationSizeMeta);
|
|
}
|
|
if (data.containsKey('start')) {
|
|
context.handle(
|
|
_startMeta, start.isAcceptableOrUnknown(data['start']!, _startMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_startMeta);
|
|
}
|
|
if (data.containsKey('finish')) {
|
|
context.handle(_finishMeta,
|
|
finish.isAcceptableOrUnknown(data['finish']!, _finishMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_finishMeta);
|
|
}
|
|
if (data.containsKey('status')) {
|
|
context.handle(_statusMeta,
|
|
status.isAcceptableOrUnknown(data['status']!, _statusMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_statusMeta);
|
|
}
|
|
context.handle(_tagsMeta, const VerificationResult.success());
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
if (data.containsKey('is_deleted')) {
|
|
context.handle(_isDeletedMeta,
|
|
isDeleted.isAcceptableOrUnknown(data['is_deleted']!, _isDeletedMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
PromoCodesCampaign map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return PromoCodesCampaign(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
template: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}template'])!,
|
|
name: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}name']),
|
|
products: $PromoCodesCampaignsTable.$converterproducts.fromSql(
|
|
attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}products'])!),
|
|
activationsPerCode: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.int, data['${effectivePrefix}activations_per_code'])!,
|
|
activationsPerUser: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.int, data['${effectivePrefix}activations_per_user'])!,
|
|
generationSize: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}generation_size'])!,
|
|
start: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}start'])!,
|
|
finish: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}finish'])!,
|
|
status: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}status'])!,
|
|
tags: $PromoCodesCampaignsTable.$convertertags.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}tags'])!),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
isDeleted: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_deleted'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$PromoCodesCampaignsTable createAlias(String alias) {
|
|
return $PromoCodesCampaignsTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<List<dynamic>?, String> $converterproducts =
|
|
const JsonListConverter();
|
|
static TypeConverter<List<String>, String> $convertertags =
|
|
const StringListConverter();
|
|
}
|
|
|
|
class PromoCodesCampaign extends DataClass
|
|
implements Insertable<PromoCodesCampaign> {
|
|
final int id;
|
|
final String template;
|
|
final String? name;
|
|
final List<dynamic>? products;
|
|
final int activationsPerCode;
|
|
final int activationsPerUser;
|
|
final int generationSize;
|
|
final DateTime start;
|
|
final DateTime finish;
|
|
final String status;
|
|
final List<String> tags;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
final bool isDeleted;
|
|
const PromoCodesCampaign(
|
|
{required this.id,
|
|
required this.template,
|
|
this.name,
|
|
this.products,
|
|
required this.activationsPerCode,
|
|
required this.activationsPerUser,
|
|
required this.generationSize,
|
|
required this.start,
|
|
required this.finish,
|
|
required this.status,
|
|
required this.tags,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.isDeleted});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['template'] = Variable<String>(template);
|
|
if (!nullToAbsent || name != null) {
|
|
map['name'] = Variable<String>(name);
|
|
}
|
|
if (!nullToAbsent || products != null) {
|
|
map['products'] = Variable<String>(
|
|
$PromoCodesCampaignsTable.$converterproducts.toSql(products));
|
|
}
|
|
map['activations_per_code'] = Variable<int>(activationsPerCode);
|
|
map['activations_per_user'] = Variable<int>(activationsPerUser);
|
|
map['generation_size'] = Variable<int>(generationSize);
|
|
map['start'] = Variable<DateTime>(start);
|
|
map['finish'] = Variable<DateTime>(finish);
|
|
map['status'] = Variable<String>(status);
|
|
{
|
|
map['tags'] = Variable<String>(
|
|
$PromoCodesCampaignsTable.$convertertags.toSql(tags));
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
map['is_deleted'] = Variable<bool>(isDeleted);
|
|
return map;
|
|
}
|
|
|
|
PromoCodesCampaignsCompanion toCompanion(bool nullToAbsent) {
|
|
return PromoCodesCampaignsCompanion(
|
|
id: Value(id),
|
|
template: Value(template),
|
|
name: name == null && nullToAbsent ? const Value.absent() : Value(name),
|
|
products: products == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(products),
|
|
activationsPerCode: Value(activationsPerCode),
|
|
activationsPerUser: Value(activationsPerUser),
|
|
generationSize: Value(generationSize),
|
|
start: Value(start),
|
|
finish: Value(finish),
|
|
status: Value(status),
|
|
tags: Value(tags),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
isDeleted: Value(isDeleted),
|
|
);
|
|
}
|
|
|
|
factory PromoCodesCampaign.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return PromoCodesCampaign(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
template: serializer.fromJson<String>(json['template']),
|
|
name: serializer.fromJson<String?>(json['name']),
|
|
products: serializer.fromJson<List<dynamic>?>(json['products']),
|
|
activationsPerCode: serializer.fromJson<int>(json['activationsPerCode']),
|
|
activationsPerUser: serializer.fromJson<int>(json['activationsPerUser']),
|
|
generationSize: serializer.fromJson<int>(json['generationSize']),
|
|
start: serializer.fromJson<DateTime>(json['start']),
|
|
finish: serializer.fromJson<DateTime>(json['finish']),
|
|
status: serializer.fromJson<String>(json['status']),
|
|
tags: serializer.fromJson<List<String>>(json['tags']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
isDeleted: serializer.fromJson<bool>(json['isDeleted']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'template': serializer.toJson<String>(template),
|
|
'name': serializer.toJson<String?>(name),
|
|
'products': serializer.toJson<List<dynamic>?>(products),
|
|
'activationsPerCode': serializer.toJson<int>(activationsPerCode),
|
|
'activationsPerUser': serializer.toJson<int>(activationsPerUser),
|
|
'generationSize': serializer.toJson<int>(generationSize),
|
|
'start': serializer.toJson<DateTime>(start),
|
|
'finish': serializer.toJson<DateTime>(finish),
|
|
'status': serializer.toJson<String>(status),
|
|
'tags': serializer.toJson<List<String>>(tags),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
'isDeleted': serializer.toJson<bool>(isDeleted),
|
|
};
|
|
}
|
|
|
|
PromoCodesCampaign copyWith(
|
|
{int? id,
|
|
String? template,
|
|
Value<String?> name = const Value.absent(),
|
|
Value<List<dynamic>?> products = const Value.absent(),
|
|
int? activationsPerCode,
|
|
int? activationsPerUser,
|
|
int? generationSize,
|
|
DateTime? start,
|
|
DateTime? finish,
|
|
String? status,
|
|
List<String>? tags,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
bool? isDeleted}) =>
|
|
PromoCodesCampaign(
|
|
id: id ?? this.id,
|
|
template: template ?? this.template,
|
|
name: name.present ? name.value : this.name,
|
|
products: products.present ? products.value : this.products,
|
|
activationsPerCode: activationsPerCode ?? this.activationsPerCode,
|
|
activationsPerUser: activationsPerUser ?? this.activationsPerUser,
|
|
generationSize: generationSize ?? this.generationSize,
|
|
start: start ?? this.start,
|
|
finish: finish ?? this.finish,
|
|
status: status ?? this.status,
|
|
tags: tags ?? this.tags,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PromoCodesCampaign(')
|
|
..write('id: $id, ')
|
|
..write('template: $template, ')
|
|
..write('name: $name, ')
|
|
..write('products: $products, ')
|
|
..write('activationsPerCode: $activationsPerCode, ')
|
|
..write('activationsPerUser: $activationsPerUser, ')
|
|
..write('generationSize: $generationSize, ')
|
|
..write('start: $start, ')
|
|
..write('finish: $finish, ')
|
|
..write('status: $status, ')
|
|
..write('tags: $tags, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id,
|
|
template,
|
|
name,
|
|
products,
|
|
activationsPerCode,
|
|
activationsPerUser,
|
|
generationSize,
|
|
start,
|
|
finish,
|
|
status,
|
|
tags,
|
|
createdAt,
|
|
updatedAt,
|
|
isDeleted);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is PromoCodesCampaign &&
|
|
other.id == this.id &&
|
|
other.template == this.template &&
|
|
other.name == this.name &&
|
|
other.products == this.products &&
|
|
other.activationsPerCode == this.activationsPerCode &&
|
|
other.activationsPerUser == this.activationsPerUser &&
|
|
other.generationSize == this.generationSize &&
|
|
other.start == this.start &&
|
|
other.finish == this.finish &&
|
|
other.status == this.status &&
|
|
other.tags == this.tags &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt &&
|
|
other.isDeleted == this.isDeleted);
|
|
}
|
|
|
|
class PromoCodesCampaignsCompanion extends UpdateCompanion<PromoCodesCampaign> {
|
|
final Value<int> id;
|
|
final Value<String> template;
|
|
final Value<String?> name;
|
|
final Value<List<dynamic>?> products;
|
|
final Value<int> activationsPerCode;
|
|
final Value<int> activationsPerUser;
|
|
final Value<int> generationSize;
|
|
final Value<DateTime> start;
|
|
final Value<DateTime> finish;
|
|
final Value<String> status;
|
|
final Value<List<String>> tags;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
final Value<bool> isDeleted;
|
|
const PromoCodesCampaignsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.template = const Value.absent(),
|
|
this.name = const Value.absent(),
|
|
this.products = const Value.absent(),
|
|
this.activationsPerCode = const Value.absent(),
|
|
this.activationsPerUser = const Value.absent(),
|
|
this.generationSize = const Value.absent(),
|
|
this.start = const Value.absent(),
|
|
this.finish = const Value.absent(),
|
|
this.status = const Value.absent(),
|
|
this.tags = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
});
|
|
PromoCodesCampaignsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String template,
|
|
this.name = const Value.absent(),
|
|
this.products = const Value.absent(),
|
|
required int activationsPerCode,
|
|
required int activationsPerUser,
|
|
required int generationSize,
|
|
required DateTime start,
|
|
required DateTime finish,
|
|
required String status,
|
|
this.tags = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
}) : template = Value(template),
|
|
activationsPerCode = Value(activationsPerCode),
|
|
activationsPerUser = Value(activationsPerUser),
|
|
generationSize = Value(generationSize),
|
|
start = Value(start),
|
|
finish = Value(finish),
|
|
status = Value(status);
|
|
static Insertable<PromoCodesCampaign> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? template,
|
|
Expression<String>? name,
|
|
Expression<String>? products,
|
|
Expression<int>? activationsPerCode,
|
|
Expression<int>? activationsPerUser,
|
|
Expression<int>? generationSize,
|
|
Expression<DateTime>? start,
|
|
Expression<DateTime>? finish,
|
|
Expression<String>? status,
|
|
Expression<String>? tags,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
Expression<bool>? isDeleted,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (template != null) 'template': template,
|
|
if (name != null) 'name': name,
|
|
if (products != null) 'products': products,
|
|
if (activationsPerCode != null)
|
|
'activations_per_code': activationsPerCode,
|
|
if (activationsPerUser != null)
|
|
'activations_per_user': activationsPerUser,
|
|
if (generationSize != null) 'generation_size': generationSize,
|
|
if (start != null) 'start': start,
|
|
if (finish != null) 'finish': finish,
|
|
if (status != null) 'status': status,
|
|
if (tags != null) 'tags': tags,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
if (isDeleted != null) 'is_deleted': isDeleted,
|
|
});
|
|
}
|
|
|
|
PromoCodesCampaignsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String>? template,
|
|
Value<String?>? name,
|
|
Value<List<dynamic>?>? products,
|
|
Value<int>? activationsPerCode,
|
|
Value<int>? activationsPerUser,
|
|
Value<int>? generationSize,
|
|
Value<DateTime>? start,
|
|
Value<DateTime>? finish,
|
|
Value<String>? status,
|
|
Value<List<String>>? tags,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt,
|
|
Value<bool>? isDeleted}) {
|
|
return PromoCodesCampaignsCompanion(
|
|
id: id ?? this.id,
|
|
template: template ?? this.template,
|
|
name: name ?? this.name,
|
|
products: products ?? this.products,
|
|
activationsPerCode: activationsPerCode ?? this.activationsPerCode,
|
|
activationsPerUser: activationsPerUser ?? this.activationsPerUser,
|
|
generationSize: generationSize ?? this.generationSize,
|
|
start: start ?? this.start,
|
|
finish: finish ?? this.finish,
|
|
status: status ?? this.status,
|
|
tags: tags ?? this.tags,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (template.present) {
|
|
map['template'] = Variable<String>(template.value);
|
|
}
|
|
if (name.present) {
|
|
map['name'] = Variable<String>(name.value);
|
|
}
|
|
if (products.present) {
|
|
map['products'] = Variable<String>(
|
|
$PromoCodesCampaignsTable.$converterproducts.toSql(products.value));
|
|
}
|
|
if (activationsPerCode.present) {
|
|
map['activations_per_code'] = Variable<int>(activationsPerCode.value);
|
|
}
|
|
if (activationsPerUser.present) {
|
|
map['activations_per_user'] = Variable<int>(activationsPerUser.value);
|
|
}
|
|
if (generationSize.present) {
|
|
map['generation_size'] = Variable<int>(generationSize.value);
|
|
}
|
|
if (start.present) {
|
|
map['start'] = Variable<DateTime>(start.value);
|
|
}
|
|
if (finish.present) {
|
|
map['finish'] = Variable<DateTime>(finish.value);
|
|
}
|
|
if (status.present) {
|
|
map['status'] = Variable<String>(status.value);
|
|
}
|
|
if (tags.present) {
|
|
map['tags'] = Variable<String>(
|
|
$PromoCodesCampaignsTable.$convertertags.toSql(tags.value));
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
if (isDeleted.present) {
|
|
map['is_deleted'] = Variable<bool>(isDeleted.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PromoCodesCampaignsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('template: $template, ')
|
|
..write('name: $name, ')
|
|
..write('products: $products, ')
|
|
..write('activationsPerCode: $activationsPerCode, ')
|
|
..write('activationsPerUser: $activationsPerUser, ')
|
|
..write('generationSize: $generationSize, ')
|
|
..write('start: $start, ')
|
|
..write('finish: $finish, ')
|
|
..write('status: $status, ')
|
|
..write('tags: $tags, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $PromoCodesTable extends PromoCodes
|
|
with TableInfo<$PromoCodesTable, PromoCode> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$PromoCodesTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _campaignIdMeta =
|
|
const VerificationMeta('campaignId');
|
|
@override
|
|
late final GeneratedColumn<int> campaignId = GeneratedColumn<int>(
|
|
'campaign_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES promo_codes_campaigns (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _codeMeta = const VerificationMeta('code');
|
|
@override
|
|
late final GeneratedColumn<String> code = GeneratedColumn<String>(
|
|
'code', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways('UNIQUE'));
|
|
static const VerificationMeta _activationsMeta =
|
|
const VerificationMeta('activations');
|
|
@override
|
|
late final GeneratedColumn<int> activations = GeneratedColumn<int>(
|
|
'activations', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, campaignId, code, activations, userId, createdAt, updatedAt];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'promo_codes';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<PromoCode> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('campaign_id')) {
|
|
context.handle(
|
|
_campaignIdMeta,
|
|
campaignId.isAcceptableOrUnknown(
|
|
data['campaign_id']!, _campaignIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_campaignIdMeta);
|
|
}
|
|
if (data.containsKey('code')) {
|
|
context.handle(
|
|
_codeMeta, code.isAcceptableOrUnknown(data['code']!, _codeMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_codeMeta);
|
|
}
|
|
if (data.containsKey('activations')) {
|
|
context.handle(
|
|
_activationsMeta,
|
|
activations.isAcceptableOrUnknown(
|
|
data['activations']!, _activationsMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
PromoCode map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return PromoCode(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
campaignId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}campaign_id'])!,
|
|
code: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}code'])!,
|
|
activations: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}activations'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id']),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$PromoCodesTable createAlias(String alias) {
|
|
return $PromoCodesTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class PromoCode extends DataClass implements Insertable<PromoCode> {
|
|
final int id;
|
|
final int campaignId;
|
|
final String code;
|
|
final int activations;
|
|
final int? userId;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
const PromoCode(
|
|
{required this.id,
|
|
required this.campaignId,
|
|
required this.code,
|
|
required this.activations,
|
|
this.userId,
|
|
required this.createdAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['campaign_id'] = Variable<int>(campaignId);
|
|
map['code'] = Variable<String>(code);
|
|
map['activations'] = Variable<int>(activations);
|
|
if (!nullToAbsent || userId != null) {
|
|
map['user_id'] = Variable<int>(userId);
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
PromoCodesCompanion toCompanion(bool nullToAbsent) {
|
|
return PromoCodesCompanion(
|
|
id: Value(id),
|
|
campaignId: Value(campaignId),
|
|
code: Value(code),
|
|
activations: Value(activations),
|
|
userId:
|
|
userId == null && nullToAbsent ? const Value.absent() : Value(userId),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory PromoCode.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return PromoCode(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
campaignId: serializer.fromJson<int>(json['campaignId']),
|
|
code: serializer.fromJson<String>(json['code']),
|
|
activations: serializer.fromJson<int>(json['activations']),
|
|
userId: serializer.fromJson<int?>(json['userId']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'campaignId': serializer.toJson<int>(campaignId),
|
|
'code': serializer.toJson<String>(code),
|
|
'activations': serializer.toJson<int>(activations),
|
|
'userId': serializer.toJson<int?>(userId),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
PromoCode copyWith(
|
|
{int? id,
|
|
int? campaignId,
|
|
String? code,
|
|
int? activations,
|
|
Value<int?> userId = const Value.absent(),
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt}) =>
|
|
PromoCode(
|
|
id: id ?? this.id,
|
|
campaignId: campaignId ?? this.campaignId,
|
|
code: code ?? this.code,
|
|
activations: activations ?? this.activations,
|
|
userId: userId.present ? userId.value : this.userId,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PromoCode(')
|
|
..write('id: $id, ')
|
|
..write('campaignId: $campaignId, ')
|
|
..write('code: $code, ')
|
|
..write('activations: $activations, ')
|
|
..write('userId: $userId, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id, campaignId, code, activations, userId, createdAt, updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is PromoCode &&
|
|
other.id == this.id &&
|
|
other.campaignId == this.campaignId &&
|
|
other.code == this.code &&
|
|
other.activations == this.activations &&
|
|
other.userId == this.userId &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class PromoCodesCompanion extends UpdateCompanion<PromoCode> {
|
|
final Value<int> id;
|
|
final Value<int> campaignId;
|
|
final Value<String> code;
|
|
final Value<int> activations;
|
|
final Value<int?> userId;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
const PromoCodesCompanion({
|
|
this.id = const Value.absent(),
|
|
this.campaignId = const Value.absent(),
|
|
this.code = const Value.absent(),
|
|
this.activations = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
PromoCodesCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int campaignId,
|
|
required String code,
|
|
this.activations = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : campaignId = Value(campaignId),
|
|
code = Value(code);
|
|
static Insertable<PromoCode> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? campaignId,
|
|
Expression<String>? code,
|
|
Expression<int>? activations,
|
|
Expression<int>? userId,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (campaignId != null) 'campaign_id': campaignId,
|
|
if (code != null) 'code': code,
|
|
if (activations != null) 'activations': activations,
|
|
if (userId != null) 'user_id': userId,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
PromoCodesCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? campaignId,
|
|
Value<String>? code,
|
|
Value<int>? activations,
|
|
Value<int?>? userId,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return PromoCodesCompanion(
|
|
id: id ?? this.id,
|
|
campaignId: campaignId ?? this.campaignId,
|
|
code: code ?? this.code,
|
|
activations: activations ?? this.activations,
|
|
userId: userId ?? this.userId,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (campaignId.present) {
|
|
map['campaign_id'] = Variable<int>(campaignId.value);
|
|
}
|
|
if (code.present) {
|
|
map['code'] = Variable<String>(code.value);
|
|
}
|
|
if (activations.present) {
|
|
map['activations'] = Variable<int>(activations.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('PromoCodesCompanion(')
|
|
..write('id: $id, ')
|
|
..write('campaignId: $campaignId, ')
|
|
..write('code: $code, ')
|
|
..write('activations: $activations, ')
|
|
..write('userId: $userId, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $DiscountCampaignsTable extends DiscountCampaigns
|
|
with TableInfo<$DiscountCampaignsTable, DiscountCampaign> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$DiscountCampaignsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _nameMeta = const VerificationMeta('name');
|
|
@override
|
|
late final GeneratedColumn<String> name = GeneratedColumn<String>(
|
|
'name', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _startMeta = const VerificationMeta('start');
|
|
@override
|
|
late final GeneratedColumn<DateTime> start = GeneratedColumn<DateTime>(
|
|
'start', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
static const VerificationMeta _finishMeta = const VerificationMeta('finish');
|
|
@override
|
|
late final GeneratedColumn<DateTime> finish = GeneratedColumn<DateTime>(
|
|
'finish', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
static const VerificationMeta _statusMeta = const VerificationMeta('status');
|
|
@override
|
|
late final GeneratedColumn<String> status = GeneratedColumn<String>(
|
|
'status', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _tagsMeta = const VerificationMeta('tags');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<String>, String> tags =
|
|
GeneratedColumn<String>('tags', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<String>>($DiscountCampaignsTable.$convertertags);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _isDeletedMeta =
|
|
const VerificationMeta('isDeleted');
|
|
@override
|
|
late final GeneratedColumn<bool> isDeleted = GeneratedColumn<bool>(
|
|
'is_deleted', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("is_deleted" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, name, start, finish, status, tags, createdAt, updatedAt, isDeleted];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'discount_campaigns';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<DiscountCampaign> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('name')) {
|
|
context.handle(
|
|
_nameMeta, name.isAcceptableOrUnknown(data['name']!, _nameMeta));
|
|
}
|
|
if (data.containsKey('start')) {
|
|
context.handle(
|
|
_startMeta, start.isAcceptableOrUnknown(data['start']!, _startMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_startMeta);
|
|
}
|
|
if (data.containsKey('finish')) {
|
|
context.handle(_finishMeta,
|
|
finish.isAcceptableOrUnknown(data['finish']!, _finishMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_finishMeta);
|
|
}
|
|
if (data.containsKey('status')) {
|
|
context.handle(_statusMeta,
|
|
status.isAcceptableOrUnknown(data['status']!, _statusMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_statusMeta);
|
|
}
|
|
context.handle(_tagsMeta, const VerificationResult.success());
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
if (data.containsKey('is_deleted')) {
|
|
context.handle(_isDeletedMeta,
|
|
isDeleted.isAcceptableOrUnknown(data['is_deleted']!, _isDeletedMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
DiscountCampaign map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return DiscountCampaign(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
name: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}name']),
|
|
start: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}start'])!,
|
|
finish: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}finish'])!,
|
|
status: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}status'])!,
|
|
tags: $DiscountCampaignsTable.$convertertags.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}tags'])!),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
isDeleted: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_deleted'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$DiscountCampaignsTable createAlias(String alias) {
|
|
return $DiscountCampaignsTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<List<String>, String> $convertertags =
|
|
const StringListConverter();
|
|
}
|
|
|
|
class DiscountCampaign extends DataClass
|
|
implements Insertable<DiscountCampaign> {
|
|
final int id;
|
|
final String? name;
|
|
final DateTime start;
|
|
final DateTime finish;
|
|
final String status;
|
|
final List<String> tags;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
final bool isDeleted;
|
|
const DiscountCampaign(
|
|
{required this.id,
|
|
this.name,
|
|
required this.start,
|
|
required this.finish,
|
|
required this.status,
|
|
required this.tags,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.isDeleted});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
if (!nullToAbsent || name != null) {
|
|
map['name'] = Variable<String>(name);
|
|
}
|
|
map['start'] = Variable<DateTime>(start);
|
|
map['finish'] = Variable<DateTime>(finish);
|
|
map['status'] = Variable<String>(status);
|
|
{
|
|
map['tags'] =
|
|
Variable<String>($DiscountCampaignsTable.$convertertags.toSql(tags));
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
map['is_deleted'] = Variable<bool>(isDeleted);
|
|
return map;
|
|
}
|
|
|
|
DiscountCampaignsCompanion toCompanion(bool nullToAbsent) {
|
|
return DiscountCampaignsCompanion(
|
|
id: Value(id),
|
|
name: name == null && nullToAbsent ? const Value.absent() : Value(name),
|
|
start: Value(start),
|
|
finish: Value(finish),
|
|
status: Value(status),
|
|
tags: Value(tags),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
isDeleted: Value(isDeleted),
|
|
);
|
|
}
|
|
|
|
factory DiscountCampaign.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return DiscountCampaign(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
name: serializer.fromJson<String?>(json['name']),
|
|
start: serializer.fromJson<DateTime>(json['start']),
|
|
finish: serializer.fromJson<DateTime>(json['finish']),
|
|
status: serializer.fromJson<String>(json['status']),
|
|
tags: serializer.fromJson<List<String>>(json['tags']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
isDeleted: serializer.fromJson<bool>(json['isDeleted']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'name': serializer.toJson<String?>(name),
|
|
'start': serializer.toJson<DateTime>(start),
|
|
'finish': serializer.toJson<DateTime>(finish),
|
|
'status': serializer.toJson<String>(status),
|
|
'tags': serializer.toJson<List<String>>(tags),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
'isDeleted': serializer.toJson<bool>(isDeleted),
|
|
};
|
|
}
|
|
|
|
DiscountCampaign copyWith(
|
|
{int? id,
|
|
Value<String?> name = const Value.absent(),
|
|
DateTime? start,
|
|
DateTime? finish,
|
|
String? status,
|
|
List<String>? tags,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
bool? isDeleted}) =>
|
|
DiscountCampaign(
|
|
id: id ?? this.id,
|
|
name: name.present ? name.value : this.name,
|
|
start: start ?? this.start,
|
|
finish: finish ?? this.finish,
|
|
status: status ?? this.status,
|
|
tags: tags ?? this.tags,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('DiscountCampaign(')
|
|
..write('id: $id, ')
|
|
..write('name: $name, ')
|
|
..write('start: $start, ')
|
|
..write('finish: $finish, ')
|
|
..write('status: $status, ')
|
|
..write('tags: $tags, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id, name, start, finish, status, tags, createdAt, updatedAt, isDeleted);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is DiscountCampaign &&
|
|
other.id == this.id &&
|
|
other.name == this.name &&
|
|
other.start == this.start &&
|
|
other.finish == this.finish &&
|
|
other.status == this.status &&
|
|
other.tags == this.tags &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt &&
|
|
other.isDeleted == this.isDeleted);
|
|
}
|
|
|
|
class DiscountCampaignsCompanion extends UpdateCompanion<DiscountCampaign> {
|
|
final Value<int> id;
|
|
final Value<String?> name;
|
|
final Value<DateTime> start;
|
|
final Value<DateTime> finish;
|
|
final Value<String> status;
|
|
final Value<List<String>> tags;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
final Value<bool> isDeleted;
|
|
const DiscountCampaignsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.name = const Value.absent(),
|
|
this.start = const Value.absent(),
|
|
this.finish = const Value.absent(),
|
|
this.status = const Value.absent(),
|
|
this.tags = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
});
|
|
DiscountCampaignsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
this.name = const Value.absent(),
|
|
required DateTime start,
|
|
required DateTime finish,
|
|
required String status,
|
|
this.tags = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
}) : start = Value(start),
|
|
finish = Value(finish),
|
|
status = Value(status);
|
|
static Insertable<DiscountCampaign> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? name,
|
|
Expression<DateTime>? start,
|
|
Expression<DateTime>? finish,
|
|
Expression<String>? status,
|
|
Expression<String>? tags,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
Expression<bool>? isDeleted,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (name != null) 'name': name,
|
|
if (start != null) 'start': start,
|
|
if (finish != null) 'finish': finish,
|
|
if (status != null) 'status': status,
|
|
if (tags != null) 'tags': tags,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
if (isDeleted != null) 'is_deleted': isDeleted,
|
|
});
|
|
}
|
|
|
|
DiscountCampaignsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String?>? name,
|
|
Value<DateTime>? start,
|
|
Value<DateTime>? finish,
|
|
Value<String>? status,
|
|
Value<List<String>>? tags,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt,
|
|
Value<bool>? isDeleted}) {
|
|
return DiscountCampaignsCompanion(
|
|
id: id ?? this.id,
|
|
name: name ?? this.name,
|
|
start: start ?? this.start,
|
|
finish: finish ?? this.finish,
|
|
status: status ?? this.status,
|
|
tags: tags ?? this.tags,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (name.present) {
|
|
map['name'] = Variable<String>(name.value);
|
|
}
|
|
if (start.present) {
|
|
map['start'] = Variable<DateTime>(start.value);
|
|
}
|
|
if (finish.present) {
|
|
map['finish'] = Variable<DateTime>(finish.value);
|
|
}
|
|
if (status.present) {
|
|
map['status'] = Variable<String>(status.value);
|
|
}
|
|
if (tags.present) {
|
|
map['tags'] = Variable<String>(
|
|
$DiscountCampaignsTable.$convertertags.toSql(tags.value));
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
if (isDeleted.present) {
|
|
map['is_deleted'] = Variable<bool>(isDeleted.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('DiscountCampaignsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('name: $name, ')
|
|
..write('start: $start, ')
|
|
..write('finish: $finish, ')
|
|
..write('status: $status, ')
|
|
..write('tags: $tags, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $DiscountsTable extends Discounts
|
|
with TableInfo<$DiscountsTable, Discount> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$DiscountsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _campaignIdMeta =
|
|
const VerificationMeta('campaignId');
|
|
@override
|
|
late final GeneratedColumn<int> campaignId = GeneratedColumn<int>(
|
|
'campaign_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES discount_campaigns (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _discountPercentMeta =
|
|
const VerificationMeta('discountPercent');
|
|
@override
|
|
late final GeneratedColumn<double> discountPercent = GeneratedColumn<double>(
|
|
'discount_percent', aliasedName, false,
|
|
type: DriftSqlType.double, requiredDuringInsert: true);
|
|
static const VerificationMeta _productsMeta =
|
|
const VerificationMeta('products');
|
|
@override
|
|
late final GeneratedColumnWithTypeConverter<List<dynamic>?, String> products =
|
|
GeneratedColumn<String>('products', aliasedName, false,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant('[]'))
|
|
.withConverter<List<dynamic>?>($DiscountsTable.$converterproducts);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _isDeletedMeta =
|
|
const VerificationMeta('isDeleted');
|
|
@override
|
|
late final GeneratedColumn<bool> isDeleted = GeneratedColumn<bool>(
|
|
'is_deleted', aliasedName, false,
|
|
type: DriftSqlType.bool,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('CHECK ("is_deleted" IN (0, 1))'),
|
|
defaultValue: const Constant(false));
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
campaignId,
|
|
discountPercent,
|
|
products,
|
|
createdAt,
|
|
updatedAt,
|
|
isDeleted
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'discounts';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<Discount> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('campaign_id')) {
|
|
context.handle(
|
|
_campaignIdMeta,
|
|
campaignId.isAcceptableOrUnknown(
|
|
data['campaign_id']!, _campaignIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_campaignIdMeta);
|
|
}
|
|
if (data.containsKey('discount_percent')) {
|
|
context.handle(
|
|
_discountPercentMeta,
|
|
discountPercent.isAcceptableOrUnknown(
|
|
data['discount_percent']!, _discountPercentMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_discountPercentMeta);
|
|
}
|
|
context.handle(_productsMeta, const VerificationResult.success());
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
if (data.containsKey('is_deleted')) {
|
|
context.handle(_isDeletedMeta,
|
|
isDeleted.isAcceptableOrUnknown(data['is_deleted']!, _isDeletedMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
Discount map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return Discount(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
campaignId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}campaign_id'])!,
|
|
discountPercent: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.double, data['${effectivePrefix}discount_percent'])!,
|
|
products: $DiscountsTable.$converterproducts.fromSql(attachedDatabase
|
|
.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}products'])!),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
isDeleted: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.bool, data['${effectivePrefix}is_deleted'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$DiscountsTable createAlias(String alias) {
|
|
return $DiscountsTable(attachedDatabase, alias);
|
|
}
|
|
|
|
static TypeConverter<List<dynamic>?, String> $converterproducts =
|
|
const JsonListConverter();
|
|
}
|
|
|
|
class Discount extends DataClass implements Insertable<Discount> {
|
|
final int id;
|
|
final int campaignId;
|
|
final double discountPercent;
|
|
final List<dynamic>? products;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
final bool isDeleted;
|
|
const Discount(
|
|
{required this.id,
|
|
required this.campaignId,
|
|
required this.discountPercent,
|
|
this.products,
|
|
required this.createdAt,
|
|
required this.updatedAt,
|
|
required this.isDeleted});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['campaign_id'] = Variable<int>(campaignId);
|
|
map['discount_percent'] = Variable<double>(discountPercent);
|
|
if (!nullToAbsent || products != null) {
|
|
map['products'] =
|
|
Variable<String>($DiscountsTable.$converterproducts.toSql(products));
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
map['is_deleted'] = Variable<bool>(isDeleted);
|
|
return map;
|
|
}
|
|
|
|
DiscountsCompanion toCompanion(bool nullToAbsent) {
|
|
return DiscountsCompanion(
|
|
id: Value(id),
|
|
campaignId: Value(campaignId),
|
|
discountPercent: Value(discountPercent),
|
|
products: products == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(products),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
isDeleted: Value(isDeleted),
|
|
);
|
|
}
|
|
|
|
factory Discount.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return Discount(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
campaignId: serializer.fromJson<int>(json['campaignId']),
|
|
discountPercent: serializer.fromJson<double>(json['discountPercent']),
|
|
products: serializer.fromJson<List<dynamic>?>(json['products']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
isDeleted: serializer.fromJson<bool>(json['isDeleted']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'campaignId': serializer.toJson<int>(campaignId),
|
|
'discountPercent': serializer.toJson<double>(discountPercent),
|
|
'products': serializer.toJson<List<dynamic>?>(products),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
'isDeleted': serializer.toJson<bool>(isDeleted),
|
|
};
|
|
}
|
|
|
|
Discount copyWith(
|
|
{int? id,
|
|
int? campaignId,
|
|
double? discountPercent,
|
|
Value<List<dynamic>?> products = const Value.absent(),
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt,
|
|
bool? isDeleted}) =>
|
|
Discount(
|
|
id: id ?? this.id,
|
|
campaignId: campaignId ?? this.campaignId,
|
|
discountPercent: discountPercent ?? this.discountPercent,
|
|
products: products.present ? products.value : this.products,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('Discount(')
|
|
..write('id: $id, ')
|
|
..write('campaignId: $campaignId, ')
|
|
..write('discountPercent: $discountPercent, ')
|
|
..write('products: $products, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, campaignId, discountPercent, products,
|
|
createdAt, updatedAt, isDeleted);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is Discount &&
|
|
other.id == this.id &&
|
|
other.campaignId == this.campaignId &&
|
|
other.discountPercent == this.discountPercent &&
|
|
other.products == this.products &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt &&
|
|
other.isDeleted == this.isDeleted);
|
|
}
|
|
|
|
class DiscountsCompanion extends UpdateCompanion<Discount> {
|
|
final Value<int> id;
|
|
final Value<int> campaignId;
|
|
final Value<double> discountPercent;
|
|
final Value<List<dynamic>?> products;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
final Value<bool> isDeleted;
|
|
const DiscountsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.campaignId = const Value.absent(),
|
|
this.discountPercent = const Value.absent(),
|
|
this.products = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
});
|
|
DiscountsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int campaignId,
|
|
required double discountPercent,
|
|
this.products = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
this.isDeleted = const Value.absent(),
|
|
}) : campaignId = Value(campaignId),
|
|
discountPercent = Value(discountPercent);
|
|
static Insertable<Discount> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? campaignId,
|
|
Expression<double>? discountPercent,
|
|
Expression<String>? products,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
Expression<bool>? isDeleted,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (campaignId != null) 'campaign_id': campaignId,
|
|
if (discountPercent != null) 'discount_percent': discountPercent,
|
|
if (products != null) 'products': products,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
if (isDeleted != null) 'is_deleted': isDeleted,
|
|
});
|
|
}
|
|
|
|
DiscountsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? campaignId,
|
|
Value<double>? discountPercent,
|
|
Value<List<dynamic>?>? products,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt,
|
|
Value<bool>? isDeleted}) {
|
|
return DiscountsCompanion(
|
|
id: id ?? this.id,
|
|
campaignId: campaignId ?? this.campaignId,
|
|
discountPercent: discountPercent ?? this.discountPercent,
|
|
products: products ?? this.products,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
isDeleted: isDeleted ?? this.isDeleted,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (campaignId.present) {
|
|
map['campaign_id'] = Variable<int>(campaignId.value);
|
|
}
|
|
if (discountPercent.present) {
|
|
map['discount_percent'] = Variable<double>(discountPercent.value);
|
|
}
|
|
if (products.present) {
|
|
map['products'] = Variable<String>(
|
|
$DiscountsTable.$converterproducts.toSql(products.value));
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
if (isDeleted.present) {
|
|
map['is_deleted'] = Variable<bool>(isDeleted.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('DiscountsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('campaignId: $campaignId, ')
|
|
..write('discountPercent: $discountPercent, ')
|
|
..write('products: $products, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt, ')
|
|
..write('isDeleted: $isDeleted')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $DiscountUserDatasTable extends DiscountUserDatas
|
|
with TableInfo<$DiscountUserDatasTable, DiscountUserData> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$DiscountUserDatasTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _discountIdMeta =
|
|
const VerificationMeta('discountId');
|
|
@override
|
|
late final GeneratedColumn<int> discountId = GeneratedColumn<int>(
|
|
'discount_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES discounts (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _grantedAtMeta =
|
|
const VerificationMeta('grantedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> grantedAt = GeneratedColumn<DateTime>(
|
|
'granted_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [discountId, userId, grantedAt];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'discount_user_datas';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<DiscountUserData> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('discount_id')) {
|
|
context.handle(
|
|
_discountIdMeta,
|
|
discountId.isAcceptableOrUnknown(
|
|
data['discount_id']!, _discountIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_discountIdMeta);
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('granted_at')) {
|
|
context.handle(_grantedAtMeta,
|
|
grantedAt.isAcceptableOrUnknown(data['granted_at']!, _grantedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {discountId, userId};
|
|
@override
|
|
DiscountUserData map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return DiscountUserData(
|
|
discountId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}discount_id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
grantedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}granted_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$DiscountUserDatasTable createAlias(String alias) {
|
|
return $DiscountUserDatasTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class DiscountUserData extends DataClass
|
|
implements Insertable<DiscountUserData> {
|
|
final int discountId;
|
|
final int userId;
|
|
final DateTime grantedAt;
|
|
const DiscountUserData(
|
|
{required this.discountId,
|
|
required this.userId,
|
|
required this.grantedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['discount_id'] = Variable<int>(discountId);
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['granted_at'] = Variable<DateTime>(grantedAt);
|
|
return map;
|
|
}
|
|
|
|
DiscountUserDatasCompanion toCompanion(bool nullToAbsent) {
|
|
return DiscountUserDatasCompanion(
|
|
discountId: Value(discountId),
|
|
userId: Value(userId),
|
|
grantedAt: Value(grantedAt),
|
|
);
|
|
}
|
|
|
|
factory DiscountUserData.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return DiscountUserData(
|
|
discountId: serializer.fromJson<int>(json['discountId']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
grantedAt: serializer.fromJson<DateTime>(json['grantedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'discountId': serializer.toJson<int>(discountId),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'grantedAt': serializer.toJson<DateTime>(grantedAt),
|
|
};
|
|
}
|
|
|
|
DiscountUserData copyWith(
|
|
{int? discountId, int? userId, DateTime? grantedAt}) =>
|
|
DiscountUserData(
|
|
discountId: discountId ?? this.discountId,
|
|
userId: userId ?? this.userId,
|
|
grantedAt: grantedAt ?? this.grantedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('DiscountUserData(')
|
|
..write('discountId: $discountId, ')
|
|
..write('userId: $userId, ')
|
|
..write('grantedAt: $grantedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(discountId, userId, grantedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is DiscountUserData &&
|
|
other.discountId == this.discountId &&
|
|
other.userId == this.userId &&
|
|
other.grantedAt == this.grantedAt);
|
|
}
|
|
|
|
class DiscountUserDatasCompanion extends UpdateCompanion<DiscountUserData> {
|
|
final Value<int> discountId;
|
|
final Value<int> userId;
|
|
final Value<DateTime> grantedAt;
|
|
final Value<int> rowid;
|
|
const DiscountUserDatasCompanion({
|
|
this.discountId = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.grantedAt = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
});
|
|
DiscountUserDatasCompanion.insert({
|
|
required int discountId,
|
|
required int userId,
|
|
this.grantedAt = const Value.absent(),
|
|
this.rowid = const Value.absent(),
|
|
}) : discountId = Value(discountId),
|
|
userId = Value(userId);
|
|
static Insertable<DiscountUserData> custom({
|
|
Expression<int>? discountId,
|
|
Expression<int>? userId,
|
|
Expression<DateTime>? grantedAt,
|
|
Expression<int>? rowid,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (discountId != null) 'discount_id': discountId,
|
|
if (userId != null) 'user_id': userId,
|
|
if (grantedAt != null) 'granted_at': grantedAt,
|
|
if (rowid != null) 'rowid': rowid,
|
|
});
|
|
}
|
|
|
|
DiscountUserDatasCompanion copyWith(
|
|
{Value<int>? discountId,
|
|
Value<int>? userId,
|
|
Value<DateTime>? grantedAt,
|
|
Value<int>? rowid}) {
|
|
return DiscountUserDatasCompanion(
|
|
discountId: discountId ?? this.discountId,
|
|
userId: userId ?? this.userId,
|
|
grantedAt: grantedAt ?? this.grantedAt,
|
|
rowid: rowid ?? this.rowid,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (discountId.present) {
|
|
map['discount_id'] = Variable<int>(discountId.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (grantedAt.present) {
|
|
map['granted_at'] = Variable<DateTime>(grantedAt.value);
|
|
}
|
|
if (rowid.present) {
|
|
map['rowid'] = Variable<int>(rowid.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('DiscountUserDatasCompanion(')
|
|
..write('discountId: $discountId, ')
|
|
..write('userId: $userId, ')
|
|
..write('grantedAt: $grantedAt, ')
|
|
..write('rowid: $rowid')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $StudySessionsTable extends StudySessions
|
|
with TableInfo<$StudySessionsTable, StudySession> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$StudySessionsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _sessionIdMeta =
|
|
const VerificationMeta('sessionId');
|
|
@override
|
|
late final GeneratedColumn<String> sessionId = GeneratedColumn<String>(
|
|
'session_id', aliasedName, true,
|
|
type: DriftSqlType.string,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways('UNIQUE'));
|
|
static const VerificationMeta _startTimeMeta =
|
|
const VerificationMeta('startTime');
|
|
@override
|
|
late final GeneratedColumn<DateTime> startTime = GeneratedColumn<DateTime>(
|
|
'start_time', aliasedName, false,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: true);
|
|
static const VerificationMeta _endTimeMeta =
|
|
const VerificationMeta('endTime');
|
|
@override
|
|
late final GeneratedColumn<DateTime> endTime = GeneratedColumn<DateTime>(
|
|
'end_time', aliasedName, true,
|
|
type: DriftSqlType.dateTime, requiredDuringInsert: false);
|
|
static const VerificationMeta _wordsLearnedMeta =
|
|
const VerificationMeta('wordsLearned');
|
|
@override
|
|
late final GeneratedColumn<int> wordsLearned = GeneratedColumn<int>(
|
|
'words_learned', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
static const VerificationMeta _testsCompletedMeta =
|
|
const VerificationMeta('testsCompleted');
|
|
@override
|
|
late final GeneratedColumn<int> testsCompleted = GeneratedColumn<int>(
|
|
'tests_completed', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0));
|
|
static const VerificationMeta _accuracyMeta =
|
|
const VerificationMeta('accuracy');
|
|
@override
|
|
late final GeneratedColumn<double> accuracy = GeneratedColumn<double>(
|
|
'accuracy', aliasedName, false,
|
|
type: DriftSqlType.double,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(0.0));
|
|
static const VerificationMeta _packIdMeta = const VerificationMeta('packId');
|
|
@override
|
|
late final GeneratedColumn<String> packId = GeneratedColumn<String>(
|
|
'pack_id', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _testIdMeta = const VerificationMeta('testId');
|
|
@override
|
|
late final GeneratedColumn<String> testId = GeneratedColumn<String>(
|
|
'test_id', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
userId,
|
|
sessionId,
|
|
startTime,
|
|
endTime,
|
|
wordsLearned,
|
|
testsCompleted,
|
|
accuracy,
|
|
packId,
|
|
testId,
|
|
createdAt,
|
|
updatedAt
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'study_sessions';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<StudySession> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('session_id')) {
|
|
context.handle(_sessionIdMeta,
|
|
sessionId.isAcceptableOrUnknown(data['session_id']!, _sessionIdMeta));
|
|
}
|
|
if (data.containsKey('start_time')) {
|
|
context.handle(_startTimeMeta,
|
|
startTime.isAcceptableOrUnknown(data['start_time']!, _startTimeMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_startTimeMeta);
|
|
}
|
|
if (data.containsKey('end_time')) {
|
|
context.handle(_endTimeMeta,
|
|
endTime.isAcceptableOrUnknown(data['end_time']!, _endTimeMeta));
|
|
}
|
|
if (data.containsKey('words_learned')) {
|
|
context.handle(
|
|
_wordsLearnedMeta,
|
|
wordsLearned.isAcceptableOrUnknown(
|
|
data['words_learned']!, _wordsLearnedMeta));
|
|
}
|
|
if (data.containsKey('tests_completed')) {
|
|
context.handle(
|
|
_testsCompletedMeta,
|
|
testsCompleted.isAcceptableOrUnknown(
|
|
data['tests_completed']!, _testsCompletedMeta));
|
|
}
|
|
if (data.containsKey('accuracy')) {
|
|
context.handle(_accuracyMeta,
|
|
accuracy.isAcceptableOrUnknown(data['accuracy']!, _accuracyMeta));
|
|
}
|
|
if (data.containsKey('pack_id')) {
|
|
context.handle(_packIdMeta,
|
|
packId.isAcceptableOrUnknown(data['pack_id']!, _packIdMeta));
|
|
}
|
|
if (data.containsKey('test_id')) {
|
|
context.handle(_testIdMeta,
|
|
testId.isAcceptableOrUnknown(data['test_id']!, _testIdMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
StudySession map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return StudySession(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
sessionId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}session_id']),
|
|
startTime: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}start_time'])!,
|
|
endTime: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}end_time']),
|
|
wordsLearned: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}words_learned'])!,
|
|
testsCompleted: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}tests_completed'])!,
|
|
accuracy: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.double, data['${effectivePrefix}accuracy'])!,
|
|
packId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}pack_id']),
|
|
testId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}test_id']),
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$StudySessionsTable createAlias(String alias) {
|
|
return $StudySessionsTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class StudySession extends DataClass implements Insertable<StudySession> {
|
|
final int id;
|
|
final int userId;
|
|
final String? sessionId;
|
|
final DateTime startTime;
|
|
final DateTime? endTime;
|
|
final int wordsLearned;
|
|
final int testsCompleted;
|
|
final double accuracy;
|
|
final String? packId;
|
|
final String? testId;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
const StudySession(
|
|
{required this.id,
|
|
required this.userId,
|
|
this.sessionId,
|
|
required this.startTime,
|
|
this.endTime,
|
|
required this.wordsLearned,
|
|
required this.testsCompleted,
|
|
required this.accuracy,
|
|
this.packId,
|
|
this.testId,
|
|
required this.createdAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['user_id'] = Variable<int>(userId);
|
|
if (!nullToAbsent || sessionId != null) {
|
|
map['session_id'] = Variable<String>(sessionId);
|
|
}
|
|
map['start_time'] = Variable<DateTime>(startTime);
|
|
if (!nullToAbsent || endTime != null) {
|
|
map['end_time'] = Variable<DateTime>(endTime);
|
|
}
|
|
map['words_learned'] = Variable<int>(wordsLearned);
|
|
map['tests_completed'] = Variable<int>(testsCompleted);
|
|
map['accuracy'] = Variable<double>(accuracy);
|
|
if (!nullToAbsent || packId != null) {
|
|
map['pack_id'] = Variable<String>(packId);
|
|
}
|
|
if (!nullToAbsent || testId != null) {
|
|
map['test_id'] = Variable<String>(testId);
|
|
}
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
StudySessionsCompanion toCompanion(bool nullToAbsent) {
|
|
return StudySessionsCompanion(
|
|
id: Value(id),
|
|
userId: Value(userId),
|
|
sessionId: sessionId == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(sessionId),
|
|
startTime: Value(startTime),
|
|
endTime: endTime == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(endTime),
|
|
wordsLearned: Value(wordsLearned),
|
|
testsCompleted: Value(testsCompleted),
|
|
accuracy: Value(accuracy),
|
|
packId:
|
|
packId == null && nullToAbsent ? const Value.absent() : Value(packId),
|
|
testId:
|
|
testId == null && nullToAbsent ? const Value.absent() : Value(testId),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory StudySession.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return StudySession(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
sessionId: serializer.fromJson<String?>(json['sessionId']),
|
|
startTime: serializer.fromJson<DateTime>(json['startTime']),
|
|
endTime: serializer.fromJson<DateTime?>(json['endTime']),
|
|
wordsLearned: serializer.fromJson<int>(json['wordsLearned']),
|
|
testsCompleted: serializer.fromJson<int>(json['testsCompleted']),
|
|
accuracy: serializer.fromJson<double>(json['accuracy']),
|
|
packId: serializer.fromJson<String?>(json['packId']),
|
|
testId: serializer.fromJson<String?>(json['testId']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'sessionId': serializer.toJson<String?>(sessionId),
|
|
'startTime': serializer.toJson<DateTime>(startTime),
|
|
'endTime': serializer.toJson<DateTime?>(endTime),
|
|
'wordsLearned': serializer.toJson<int>(wordsLearned),
|
|
'testsCompleted': serializer.toJson<int>(testsCompleted),
|
|
'accuracy': serializer.toJson<double>(accuracy),
|
|
'packId': serializer.toJson<String?>(packId),
|
|
'testId': serializer.toJson<String?>(testId),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
StudySession copyWith(
|
|
{int? id,
|
|
int? userId,
|
|
Value<String?> sessionId = const Value.absent(),
|
|
DateTime? startTime,
|
|
Value<DateTime?> endTime = const Value.absent(),
|
|
int? wordsLearned,
|
|
int? testsCompleted,
|
|
double? accuracy,
|
|
Value<String?> packId = const Value.absent(),
|
|
Value<String?> testId = const Value.absent(),
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt}) =>
|
|
StudySession(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
sessionId: sessionId.present ? sessionId.value : this.sessionId,
|
|
startTime: startTime ?? this.startTime,
|
|
endTime: endTime.present ? endTime.value : this.endTime,
|
|
wordsLearned: wordsLearned ?? this.wordsLearned,
|
|
testsCompleted: testsCompleted ?? this.testsCompleted,
|
|
accuracy: accuracy ?? this.accuracy,
|
|
packId: packId.present ? packId.value : this.packId,
|
|
testId: testId.present ? testId.value : this.testId,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('StudySession(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('sessionId: $sessionId, ')
|
|
..write('startTime: $startTime, ')
|
|
..write('endTime: $endTime, ')
|
|
..write('wordsLearned: $wordsLearned, ')
|
|
..write('testsCompleted: $testsCompleted, ')
|
|
..write('accuracy: $accuracy, ')
|
|
..write('packId: $packId, ')
|
|
..write('testId: $testId, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id,
|
|
userId,
|
|
sessionId,
|
|
startTime,
|
|
endTime,
|
|
wordsLearned,
|
|
testsCompleted,
|
|
accuracy,
|
|
packId,
|
|
testId,
|
|
createdAt,
|
|
updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is StudySession &&
|
|
other.id == this.id &&
|
|
other.userId == this.userId &&
|
|
other.sessionId == this.sessionId &&
|
|
other.startTime == this.startTime &&
|
|
other.endTime == this.endTime &&
|
|
other.wordsLearned == this.wordsLearned &&
|
|
other.testsCompleted == this.testsCompleted &&
|
|
other.accuracy == this.accuracy &&
|
|
other.packId == this.packId &&
|
|
other.testId == this.testId &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class StudySessionsCompanion extends UpdateCompanion<StudySession> {
|
|
final Value<int> id;
|
|
final Value<int> userId;
|
|
final Value<String?> sessionId;
|
|
final Value<DateTime> startTime;
|
|
final Value<DateTime?> endTime;
|
|
final Value<int> wordsLearned;
|
|
final Value<int> testsCompleted;
|
|
final Value<double> accuracy;
|
|
final Value<String?> packId;
|
|
final Value<String?> testId;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
const StudySessionsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.sessionId = const Value.absent(),
|
|
this.startTime = const Value.absent(),
|
|
this.endTime = const Value.absent(),
|
|
this.wordsLearned = const Value.absent(),
|
|
this.testsCompleted = const Value.absent(),
|
|
this.accuracy = const Value.absent(),
|
|
this.packId = const Value.absent(),
|
|
this.testId = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
StudySessionsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int userId,
|
|
this.sessionId = const Value.absent(),
|
|
required DateTime startTime,
|
|
this.endTime = const Value.absent(),
|
|
this.wordsLearned = const Value.absent(),
|
|
this.testsCompleted = const Value.absent(),
|
|
this.accuracy = const Value.absent(),
|
|
this.packId = const Value.absent(),
|
|
this.testId = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : userId = Value(userId),
|
|
startTime = Value(startTime);
|
|
static Insertable<StudySession> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? userId,
|
|
Expression<String>? sessionId,
|
|
Expression<DateTime>? startTime,
|
|
Expression<DateTime>? endTime,
|
|
Expression<int>? wordsLearned,
|
|
Expression<int>? testsCompleted,
|
|
Expression<double>? accuracy,
|
|
Expression<String>? packId,
|
|
Expression<String>? testId,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'user_id': userId,
|
|
if (sessionId != null) 'session_id': sessionId,
|
|
if (startTime != null) 'start_time': startTime,
|
|
if (endTime != null) 'end_time': endTime,
|
|
if (wordsLearned != null) 'words_learned': wordsLearned,
|
|
if (testsCompleted != null) 'tests_completed': testsCompleted,
|
|
if (accuracy != null) 'accuracy': accuracy,
|
|
if (packId != null) 'pack_id': packId,
|
|
if (testId != null) 'test_id': testId,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
StudySessionsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? userId,
|
|
Value<String?>? sessionId,
|
|
Value<DateTime>? startTime,
|
|
Value<DateTime?>? endTime,
|
|
Value<int>? wordsLearned,
|
|
Value<int>? testsCompleted,
|
|
Value<double>? accuracy,
|
|
Value<String?>? packId,
|
|
Value<String?>? testId,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return StudySessionsCompanion(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
sessionId: sessionId ?? this.sessionId,
|
|
startTime: startTime ?? this.startTime,
|
|
endTime: endTime ?? this.endTime,
|
|
wordsLearned: wordsLearned ?? this.wordsLearned,
|
|
testsCompleted: testsCompleted ?? this.testsCompleted,
|
|
accuracy: accuracy ?? this.accuracy,
|
|
packId: packId ?? this.packId,
|
|
testId: testId ?? this.testId,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (sessionId.present) {
|
|
map['session_id'] = Variable<String>(sessionId.value);
|
|
}
|
|
if (startTime.present) {
|
|
map['start_time'] = Variable<DateTime>(startTime.value);
|
|
}
|
|
if (endTime.present) {
|
|
map['end_time'] = Variable<DateTime>(endTime.value);
|
|
}
|
|
if (wordsLearned.present) {
|
|
map['words_learned'] = Variable<int>(wordsLearned.value);
|
|
}
|
|
if (testsCompleted.present) {
|
|
map['tests_completed'] = Variable<int>(testsCompleted.value);
|
|
}
|
|
if (accuracy.present) {
|
|
map['accuracy'] = Variable<double>(accuracy.value);
|
|
}
|
|
if (packId.present) {
|
|
map['pack_id'] = Variable<String>(packId.value);
|
|
}
|
|
if (testId.present) {
|
|
map['test_id'] = Variable<String>(testId.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('StudySessionsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('sessionId: $sessionId, ')
|
|
..write('startTime: $startTime, ')
|
|
..write('endTime: $endTime, ')
|
|
..write('wordsLearned: $wordsLearned, ')
|
|
..write('testsCompleted: $testsCompleted, ')
|
|
..write('accuracy: $accuracy, ')
|
|
..write('packId: $packId, ')
|
|
..write('testId: $testId, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $UserAchievementsTable extends UserAchievements
|
|
with TableInfo<$UserAchievementsTable, UserAchievement> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$UserAchievementsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _userIdMeta = const VerificationMeta('userId');
|
|
@override
|
|
late final GeneratedColumn<int> userId = GeneratedColumn<int>(
|
|
'user_id', aliasedName, false,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: true,
|
|
defaultConstraints: GeneratedColumn.constraintIsAlways(
|
|
'REFERENCES users (id) ON DELETE CASCADE'));
|
|
static const VerificationMeta _achievementIdMeta =
|
|
const VerificationMeta('achievementId');
|
|
@override
|
|
late final GeneratedColumn<String> achievementId = GeneratedColumn<String>(
|
|
'achievement_id', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _unlockedAtMeta =
|
|
const VerificationMeta('unlockedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> unlockedAt = GeneratedColumn<DateTime>(
|
|
'unlocked_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _progressMeta =
|
|
const VerificationMeta('progress');
|
|
@override
|
|
late final GeneratedColumn<double> progress = GeneratedColumn<double>(
|
|
'progress', aliasedName, false,
|
|
type: DriftSqlType.double,
|
|
requiredDuringInsert: false,
|
|
defaultValue: const Constant(1.0));
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns =>
|
|
[id, userId, achievementId, unlockedAt, progress, createdAt, updatedAt];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'user_achievements';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<UserAchievement> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('user_id')) {
|
|
context.handle(_userIdMeta,
|
|
userId.isAcceptableOrUnknown(data['user_id']!, _userIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_userIdMeta);
|
|
}
|
|
if (data.containsKey('achievement_id')) {
|
|
context.handle(
|
|
_achievementIdMeta,
|
|
achievementId.isAcceptableOrUnknown(
|
|
data['achievement_id']!, _achievementIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_achievementIdMeta);
|
|
}
|
|
if (data.containsKey('unlocked_at')) {
|
|
context.handle(
|
|
_unlockedAtMeta,
|
|
unlockedAt.isAcceptableOrUnknown(
|
|
data['unlocked_at']!, _unlockedAtMeta));
|
|
}
|
|
if (data.containsKey('progress')) {
|
|
context.handle(_progressMeta,
|
|
progress.isAcceptableOrUnknown(data['progress']!, _progressMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
UserAchievement map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return UserAchievement(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
userId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}user_id'])!,
|
|
achievementId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.string, data['${effectivePrefix}achievement_id'])!,
|
|
unlockedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}unlocked_at'])!,
|
|
progress: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.double, data['${effectivePrefix}progress'])!,
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$UserAchievementsTable createAlias(String alias) {
|
|
return $UserAchievementsTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class UserAchievement extends DataClass implements Insertable<UserAchievement> {
|
|
final int id;
|
|
final int userId;
|
|
final String achievementId;
|
|
final DateTime unlockedAt;
|
|
final double progress;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
const UserAchievement(
|
|
{required this.id,
|
|
required this.userId,
|
|
required this.achievementId,
|
|
required this.unlockedAt,
|
|
required this.progress,
|
|
required this.createdAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['user_id'] = Variable<int>(userId);
|
|
map['achievement_id'] = Variable<String>(achievementId);
|
|
map['unlocked_at'] = Variable<DateTime>(unlockedAt);
|
|
map['progress'] = Variable<double>(progress);
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
UserAchievementsCompanion toCompanion(bool nullToAbsent) {
|
|
return UserAchievementsCompanion(
|
|
id: Value(id),
|
|
userId: Value(userId),
|
|
achievementId: Value(achievementId),
|
|
unlockedAt: Value(unlockedAt),
|
|
progress: Value(progress),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory UserAchievement.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return UserAchievement(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
userId: serializer.fromJson<int>(json['userId']),
|
|
achievementId: serializer.fromJson<String>(json['achievementId']),
|
|
unlockedAt: serializer.fromJson<DateTime>(json['unlockedAt']),
|
|
progress: serializer.fromJson<double>(json['progress']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'userId': serializer.toJson<int>(userId),
|
|
'achievementId': serializer.toJson<String>(achievementId),
|
|
'unlockedAt': serializer.toJson<DateTime>(unlockedAt),
|
|
'progress': serializer.toJson<double>(progress),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
UserAchievement copyWith(
|
|
{int? id,
|
|
int? userId,
|
|
String? achievementId,
|
|
DateTime? unlockedAt,
|
|
double? progress,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt}) =>
|
|
UserAchievement(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
achievementId: achievementId ?? this.achievementId,
|
|
unlockedAt: unlockedAt ?? this.unlockedAt,
|
|
progress: progress ?? this.progress,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserAchievement(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('achievementId: $achievementId, ')
|
|
..write('unlockedAt: $unlockedAt, ')
|
|
..write('progress: $progress, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(
|
|
id, userId, achievementId, unlockedAt, progress, createdAt, updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is UserAchievement &&
|
|
other.id == this.id &&
|
|
other.userId == this.userId &&
|
|
other.achievementId == this.achievementId &&
|
|
other.unlockedAt == this.unlockedAt &&
|
|
other.progress == this.progress &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class UserAchievementsCompanion extends UpdateCompanion<UserAchievement> {
|
|
final Value<int> id;
|
|
final Value<int> userId;
|
|
final Value<String> achievementId;
|
|
final Value<DateTime> unlockedAt;
|
|
final Value<double> progress;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
const UserAchievementsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.userId = const Value.absent(),
|
|
this.achievementId = const Value.absent(),
|
|
this.unlockedAt = const Value.absent(),
|
|
this.progress = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
UserAchievementsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required int userId,
|
|
required String achievementId,
|
|
this.unlockedAt = const Value.absent(),
|
|
this.progress = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : userId = Value(userId),
|
|
achievementId = Value(achievementId);
|
|
static Insertable<UserAchievement> custom({
|
|
Expression<int>? id,
|
|
Expression<int>? userId,
|
|
Expression<String>? achievementId,
|
|
Expression<DateTime>? unlockedAt,
|
|
Expression<double>? progress,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (userId != null) 'user_id': userId,
|
|
if (achievementId != null) 'achievement_id': achievementId,
|
|
if (unlockedAt != null) 'unlocked_at': unlockedAt,
|
|
if (progress != null) 'progress': progress,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
UserAchievementsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<int>? userId,
|
|
Value<String>? achievementId,
|
|
Value<DateTime>? unlockedAt,
|
|
Value<double>? progress,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return UserAchievementsCompanion(
|
|
id: id ?? this.id,
|
|
userId: userId ?? this.userId,
|
|
achievementId: achievementId ?? this.achievementId,
|
|
unlockedAt: unlockedAt ?? this.unlockedAt,
|
|
progress: progress ?? this.progress,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (userId.present) {
|
|
map['user_id'] = Variable<int>(userId.value);
|
|
}
|
|
if (achievementId.present) {
|
|
map['achievement_id'] = Variable<String>(achievementId.value);
|
|
}
|
|
if (unlockedAt.present) {
|
|
map['unlocked_at'] = Variable<DateTime>(unlockedAt.value);
|
|
}
|
|
if (progress.present) {
|
|
map['progress'] = Variable<double>(progress.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('UserAchievementsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('userId: $userId, ')
|
|
..write('achievementId: $achievementId, ')
|
|
..write('unlockedAt: $unlockedAt, ')
|
|
..write('progress: $progress, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
class $ShareRequestsTable extends ShareRequests
|
|
with TableInfo<$ShareRequestsTable, ShareRequest> {
|
|
@override
|
|
final GeneratedDatabase attachedDatabase;
|
|
final String? _alias;
|
|
$ShareRequestsTable(this.attachedDatabase, [this._alias]);
|
|
static const VerificationMeta _idMeta = const VerificationMeta('id');
|
|
@override
|
|
late final GeneratedColumn<int> id = GeneratedColumn<int>(
|
|
'id', aliasedName, false,
|
|
hasAutoIncrement: true,
|
|
type: DriftSqlType.int,
|
|
requiredDuringInsert: false,
|
|
defaultConstraints:
|
|
GeneratedColumn.constraintIsAlways('PRIMARY KEY AUTOINCREMENT'));
|
|
static const VerificationMeta _telegramUserIdMeta =
|
|
const VerificationMeta('telegramUserId');
|
|
@override
|
|
late final GeneratedColumn<String> telegramUserId = GeneratedColumn<String>(
|
|
'telegram_user_id', aliasedName, false,
|
|
type: DriftSqlType.string, requiredDuringInsert: true);
|
|
static const VerificationMeta _telegramUsernameMeta =
|
|
const VerificationMeta('telegramUsername');
|
|
@override
|
|
late final GeneratedColumn<String> telegramUsername = GeneratedColumn<String>(
|
|
'telegram_username', aliasedName, true,
|
|
type: DriftSqlType.string, requiredDuringInsert: false);
|
|
static const VerificationMeta _sharedCardIdMeta =
|
|
const VerificationMeta('sharedCardId');
|
|
@override
|
|
late final GeneratedColumn<int> sharedCardId = GeneratedColumn<int>(
|
|
'shared_card_id', aliasedName, true,
|
|
type: DriftSqlType.int, requiredDuringInsert: false);
|
|
static const VerificationMeta _requestedAtMeta =
|
|
const VerificationMeta('requestedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> requestedAt = GeneratedColumn<DateTime>(
|
|
'requested_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _createdAtMeta =
|
|
const VerificationMeta('createdAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> createdAt = GeneratedColumn<DateTime>(
|
|
'created_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
static const VerificationMeta _updatedAtMeta =
|
|
const VerificationMeta('updatedAt');
|
|
@override
|
|
late final GeneratedColumn<DateTime> updatedAt = GeneratedColumn<DateTime>(
|
|
'updated_at', aliasedName, false,
|
|
type: DriftSqlType.dateTime,
|
|
requiredDuringInsert: false,
|
|
defaultValue: currentDateAndTime);
|
|
@override
|
|
List<GeneratedColumn> get $columns => [
|
|
id,
|
|
telegramUserId,
|
|
telegramUsername,
|
|
sharedCardId,
|
|
requestedAt,
|
|
createdAt,
|
|
updatedAt
|
|
];
|
|
@override
|
|
String get aliasedName => _alias ?? actualTableName;
|
|
@override
|
|
String get actualTableName => $name;
|
|
static const String $name = 'share_requests';
|
|
@override
|
|
VerificationContext validateIntegrity(Insertable<ShareRequest> instance,
|
|
{bool isInserting = false}) {
|
|
final context = VerificationContext();
|
|
final data = instance.toColumns(true);
|
|
if (data.containsKey('id')) {
|
|
context.handle(_idMeta, id.isAcceptableOrUnknown(data['id']!, _idMeta));
|
|
}
|
|
if (data.containsKey('telegram_user_id')) {
|
|
context.handle(
|
|
_telegramUserIdMeta,
|
|
telegramUserId.isAcceptableOrUnknown(
|
|
data['telegram_user_id']!, _telegramUserIdMeta));
|
|
} else if (isInserting) {
|
|
context.missing(_telegramUserIdMeta);
|
|
}
|
|
if (data.containsKey('telegram_username')) {
|
|
context.handle(
|
|
_telegramUsernameMeta,
|
|
telegramUsername.isAcceptableOrUnknown(
|
|
data['telegram_username']!, _telegramUsernameMeta));
|
|
}
|
|
if (data.containsKey('shared_card_id')) {
|
|
context.handle(
|
|
_sharedCardIdMeta,
|
|
sharedCardId.isAcceptableOrUnknown(
|
|
data['shared_card_id']!, _sharedCardIdMeta));
|
|
}
|
|
if (data.containsKey('requested_at')) {
|
|
context.handle(
|
|
_requestedAtMeta,
|
|
requestedAt.isAcceptableOrUnknown(
|
|
data['requested_at']!, _requestedAtMeta));
|
|
}
|
|
if (data.containsKey('created_at')) {
|
|
context.handle(_createdAtMeta,
|
|
createdAt.isAcceptableOrUnknown(data['created_at']!, _createdAtMeta));
|
|
}
|
|
if (data.containsKey('updated_at')) {
|
|
context.handle(_updatedAtMeta,
|
|
updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta));
|
|
}
|
|
return context;
|
|
}
|
|
|
|
@override
|
|
Set<GeneratedColumn> get $primaryKey => {id};
|
|
@override
|
|
ShareRequest map(Map<String, dynamic> data, {String? tablePrefix}) {
|
|
final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : '';
|
|
return ShareRequest(
|
|
id: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}id'])!,
|
|
telegramUserId: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.string, data['${effectivePrefix}telegram_user_id'])!,
|
|
telegramUsername: attachedDatabase.typeMapping.read(
|
|
DriftSqlType.string, data['${effectivePrefix}telegram_username']),
|
|
sharedCardId: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.int, data['${effectivePrefix}shared_card_id']),
|
|
requestedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}requested_at'])!,
|
|
createdAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}created_at'])!,
|
|
updatedAt: attachedDatabase.typeMapping
|
|
.read(DriftSqlType.dateTime, data['${effectivePrefix}updated_at'])!,
|
|
);
|
|
}
|
|
|
|
@override
|
|
$ShareRequestsTable createAlias(String alias) {
|
|
return $ShareRequestsTable(attachedDatabase, alias);
|
|
}
|
|
}
|
|
|
|
class ShareRequest extends DataClass implements Insertable<ShareRequest> {
|
|
final int id;
|
|
final String telegramUserId;
|
|
final String? telegramUsername;
|
|
final int? sharedCardId;
|
|
final DateTime requestedAt;
|
|
final DateTime createdAt;
|
|
final DateTime updatedAt;
|
|
const ShareRequest(
|
|
{required this.id,
|
|
required this.telegramUserId,
|
|
this.telegramUsername,
|
|
this.sharedCardId,
|
|
required this.requestedAt,
|
|
required this.createdAt,
|
|
required this.updatedAt});
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
map['id'] = Variable<int>(id);
|
|
map['telegram_user_id'] = Variable<String>(telegramUserId);
|
|
if (!nullToAbsent || telegramUsername != null) {
|
|
map['telegram_username'] = Variable<String>(telegramUsername);
|
|
}
|
|
if (!nullToAbsent || sharedCardId != null) {
|
|
map['shared_card_id'] = Variable<int>(sharedCardId);
|
|
}
|
|
map['requested_at'] = Variable<DateTime>(requestedAt);
|
|
map['created_at'] = Variable<DateTime>(createdAt);
|
|
map['updated_at'] = Variable<DateTime>(updatedAt);
|
|
return map;
|
|
}
|
|
|
|
ShareRequestsCompanion toCompanion(bool nullToAbsent) {
|
|
return ShareRequestsCompanion(
|
|
id: Value(id),
|
|
telegramUserId: Value(telegramUserId),
|
|
telegramUsername: telegramUsername == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(telegramUsername),
|
|
sharedCardId: sharedCardId == null && nullToAbsent
|
|
? const Value.absent()
|
|
: Value(sharedCardId),
|
|
requestedAt: Value(requestedAt),
|
|
createdAt: Value(createdAt),
|
|
updatedAt: Value(updatedAt),
|
|
);
|
|
}
|
|
|
|
factory ShareRequest.fromJson(Map<String, dynamic> json,
|
|
{ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return ShareRequest(
|
|
id: serializer.fromJson<int>(json['id']),
|
|
telegramUserId: serializer.fromJson<String>(json['telegramUserId']),
|
|
telegramUsername: serializer.fromJson<String?>(json['telegramUsername']),
|
|
sharedCardId: serializer.fromJson<int?>(json['sharedCardId']),
|
|
requestedAt: serializer.fromJson<DateTime>(json['requestedAt']),
|
|
createdAt: serializer.fromJson<DateTime>(json['createdAt']),
|
|
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
|
|
);
|
|
}
|
|
@override
|
|
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
|
|
serializer ??= driftRuntimeOptions.defaultSerializer;
|
|
return <String, dynamic>{
|
|
'id': serializer.toJson<int>(id),
|
|
'telegramUserId': serializer.toJson<String>(telegramUserId),
|
|
'telegramUsername': serializer.toJson<String?>(telegramUsername),
|
|
'sharedCardId': serializer.toJson<int?>(sharedCardId),
|
|
'requestedAt': serializer.toJson<DateTime>(requestedAt),
|
|
'createdAt': serializer.toJson<DateTime>(createdAt),
|
|
'updatedAt': serializer.toJson<DateTime>(updatedAt),
|
|
};
|
|
}
|
|
|
|
ShareRequest copyWith(
|
|
{int? id,
|
|
String? telegramUserId,
|
|
Value<String?> telegramUsername = const Value.absent(),
|
|
Value<int?> sharedCardId = const Value.absent(),
|
|
DateTime? requestedAt,
|
|
DateTime? createdAt,
|
|
DateTime? updatedAt}) =>
|
|
ShareRequest(
|
|
id: id ?? this.id,
|
|
telegramUserId: telegramUserId ?? this.telegramUserId,
|
|
telegramUsername: telegramUsername.present
|
|
? telegramUsername.value
|
|
: this.telegramUsername,
|
|
sharedCardId:
|
|
sharedCardId.present ? sharedCardId.value : this.sharedCardId,
|
|
requestedAt: requestedAt ?? this.requestedAt,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('ShareRequest(')
|
|
..write('id: $id, ')
|
|
..write('telegramUserId: $telegramUserId, ')
|
|
..write('telegramUsername: $telegramUsername, ')
|
|
..write('sharedCardId: $sharedCardId, ')
|
|
..write('requestedAt: $requestedAt, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
|
|
@override
|
|
int get hashCode => Object.hash(id, telegramUserId, telegramUsername,
|
|
sharedCardId, requestedAt, createdAt, updatedAt);
|
|
@override
|
|
bool operator ==(Object other) =>
|
|
identical(this, other) ||
|
|
(other is ShareRequest &&
|
|
other.id == this.id &&
|
|
other.telegramUserId == this.telegramUserId &&
|
|
other.telegramUsername == this.telegramUsername &&
|
|
other.sharedCardId == this.sharedCardId &&
|
|
other.requestedAt == this.requestedAt &&
|
|
other.createdAt == this.createdAt &&
|
|
other.updatedAt == this.updatedAt);
|
|
}
|
|
|
|
class ShareRequestsCompanion extends UpdateCompanion<ShareRequest> {
|
|
final Value<int> id;
|
|
final Value<String> telegramUserId;
|
|
final Value<String?> telegramUsername;
|
|
final Value<int?> sharedCardId;
|
|
final Value<DateTime> requestedAt;
|
|
final Value<DateTime> createdAt;
|
|
final Value<DateTime> updatedAt;
|
|
const ShareRequestsCompanion({
|
|
this.id = const Value.absent(),
|
|
this.telegramUserId = const Value.absent(),
|
|
this.telegramUsername = const Value.absent(),
|
|
this.sharedCardId = const Value.absent(),
|
|
this.requestedAt = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
});
|
|
ShareRequestsCompanion.insert({
|
|
this.id = const Value.absent(),
|
|
required String telegramUserId,
|
|
this.telegramUsername = const Value.absent(),
|
|
this.sharedCardId = const Value.absent(),
|
|
this.requestedAt = const Value.absent(),
|
|
this.createdAt = const Value.absent(),
|
|
this.updatedAt = const Value.absent(),
|
|
}) : telegramUserId = Value(telegramUserId);
|
|
static Insertable<ShareRequest> custom({
|
|
Expression<int>? id,
|
|
Expression<String>? telegramUserId,
|
|
Expression<String>? telegramUsername,
|
|
Expression<int>? sharedCardId,
|
|
Expression<DateTime>? requestedAt,
|
|
Expression<DateTime>? createdAt,
|
|
Expression<DateTime>? updatedAt,
|
|
}) {
|
|
return RawValuesInsertable({
|
|
if (id != null) 'id': id,
|
|
if (telegramUserId != null) 'telegram_user_id': telegramUserId,
|
|
if (telegramUsername != null) 'telegram_username': telegramUsername,
|
|
if (sharedCardId != null) 'shared_card_id': sharedCardId,
|
|
if (requestedAt != null) 'requested_at': requestedAt,
|
|
if (createdAt != null) 'created_at': createdAt,
|
|
if (updatedAt != null) 'updated_at': updatedAt,
|
|
});
|
|
}
|
|
|
|
ShareRequestsCompanion copyWith(
|
|
{Value<int>? id,
|
|
Value<String>? telegramUserId,
|
|
Value<String?>? telegramUsername,
|
|
Value<int?>? sharedCardId,
|
|
Value<DateTime>? requestedAt,
|
|
Value<DateTime>? createdAt,
|
|
Value<DateTime>? updatedAt}) {
|
|
return ShareRequestsCompanion(
|
|
id: id ?? this.id,
|
|
telegramUserId: telegramUserId ?? this.telegramUserId,
|
|
telegramUsername: telegramUsername ?? this.telegramUsername,
|
|
sharedCardId: sharedCardId ?? this.sharedCardId,
|
|
requestedAt: requestedAt ?? this.requestedAt,
|
|
createdAt: createdAt ?? this.createdAt,
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Map<String, Expression> toColumns(bool nullToAbsent) {
|
|
final map = <String, Expression>{};
|
|
if (id.present) {
|
|
map['id'] = Variable<int>(id.value);
|
|
}
|
|
if (telegramUserId.present) {
|
|
map['telegram_user_id'] = Variable<String>(telegramUserId.value);
|
|
}
|
|
if (telegramUsername.present) {
|
|
map['telegram_username'] = Variable<String>(telegramUsername.value);
|
|
}
|
|
if (sharedCardId.present) {
|
|
map['shared_card_id'] = Variable<int>(sharedCardId.value);
|
|
}
|
|
if (requestedAt.present) {
|
|
map['requested_at'] = Variable<DateTime>(requestedAt.value);
|
|
}
|
|
if (createdAt.present) {
|
|
map['created_at'] = Variable<DateTime>(createdAt.value);
|
|
}
|
|
if (updatedAt.present) {
|
|
map['updated_at'] = Variable<DateTime>(updatedAt.value);
|
|
}
|
|
return map;
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return (StringBuffer('ShareRequestsCompanion(')
|
|
..write('id: $id, ')
|
|
..write('telegramUserId: $telegramUserId, ')
|
|
..write('telegramUsername: $telegramUsername, ')
|
|
..write('sharedCardId: $sharedCardId, ')
|
|
..write('requestedAt: $requestedAt, ')
|
|
..write('createdAt: $createdAt, ')
|
|
..write('updatedAt: $updatedAt')
|
|
..write(')'))
|
|
.toString();
|
|
}
|
|
}
|
|
|
|
abstract class _$AppDatabase extends GeneratedDatabase {
|
|
_$AppDatabase(QueryExecutor e) : super(e);
|
|
late final $UsersTable users = $UsersTable(this);
|
|
late final $UserDatasTable userDatas = $UserDatasTable(this);
|
|
late final $TokensTable tokens = $TokensTable(this);
|
|
late final $RefreshTokensTable refreshTokens = $RefreshTokensTable(this);
|
|
late final $TelegramAuthCodesTable telegramAuthCodes =
|
|
$TelegramAuthCodesTable(this);
|
|
late final $CardPacksTable cardPacks = $CardPacksTable(this);
|
|
late final $GameCardsTable gameCards = $GameCardsTable(this);
|
|
late final $VoiceModelsTable voiceModels = $VoiceModelsTable(this);
|
|
late final $UserPacksTable userPacks = $UserPacksTable(this);
|
|
late final $PreviewCardsTable previewCards = $PreviewCardsTable(this);
|
|
late final $CardPackCardsTable cardPackCards = $CardPackCardsTable(this);
|
|
late final $CardVoicesTable cardVoices = $CardVoicesTable(this);
|
|
late final $SubscriptionPlansTable subscriptionPlans =
|
|
$SubscriptionPlansTable(this);
|
|
late final $UserSubscriptionsTable userSubscriptions =
|
|
$UserSubscriptionsTable(this);
|
|
late final $PaymentsTable payments = $PaymentsTable(this);
|
|
late final $TestsTable tests = $TestsTable(this);
|
|
late final $TestQuestionsTable testQuestions = $TestQuestionsTable(this);
|
|
late final $TestPackRelationsTable testPackRelations =
|
|
$TestPackRelationsTable(this);
|
|
late final $TestStatisticsTable testStatistics = $TestStatisticsTable(this);
|
|
late final $TasksTable tasks = $TasksTable(this);
|
|
late final $UserTasksTable userTasks = $UserTasksTable(this);
|
|
late final $UserTaskProgressesTable userTaskProgresses =
|
|
$UserTaskProgressesTable(this);
|
|
late final $UserTaskResultsTable userTaskResults =
|
|
$UserTaskResultsTable(this);
|
|
late final $PromoCodesCampaignsTable promoCodesCampaigns =
|
|
$PromoCodesCampaignsTable(this);
|
|
late final $PromoCodesTable promoCodes = $PromoCodesTable(this);
|
|
late final $DiscountCampaignsTable discountCampaigns =
|
|
$DiscountCampaignsTable(this);
|
|
late final $DiscountsTable discounts = $DiscountsTable(this);
|
|
late final $DiscountUserDatasTable discountUserDatas =
|
|
$DiscountUserDatasTable(this);
|
|
late final $StudySessionsTable studySessions = $StudySessionsTable(this);
|
|
late final $UserAchievementsTable userAchievements =
|
|
$UserAchievementsTable(this);
|
|
late final $ShareRequestsTable shareRequests = $ShareRequestsTable(this);
|
|
late final UserDao userDao = UserDao(this as AppDatabase);
|
|
late final PackDao packDao = PackDao(this as AppDatabase);
|
|
late final TestDao testDao = TestDao(this as AppDatabase);
|
|
late final PaymentDao paymentDao = PaymentDao(this as AppDatabase);
|
|
late final SubscriptionDao subscriptionDao =
|
|
SubscriptionDao(this as AppDatabase);
|
|
late final TaskDao taskDao = TaskDao(this as AppDatabase);
|
|
late final PromoCodeDao promoCodeDao = PromoCodeDao(this as AppDatabase);
|
|
late final DiscountDao discountDao = DiscountDao(this as AppDatabase);
|
|
late final StatisticsDao statisticsDao = StatisticsDao(this as AppDatabase);
|
|
late final AchievementDao achievementDao =
|
|
AchievementDao(this as AppDatabase);
|
|
@override
|
|
Iterable<TableInfo<Table, Object?>> get allTables =>
|
|
allSchemaEntities.whereType<TableInfo<Table, Object?>>();
|
|
@override
|
|
List<DatabaseSchemaEntity> get allSchemaEntities => [
|
|
users,
|
|
userDatas,
|
|
tokens,
|
|
refreshTokens,
|
|
telegramAuthCodes,
|
|
cardPacks,
|
|
gameCards,
|
|
voiceModels,
|
|
userPacks,
|
|
previewCards,
|
|
cardPackCards,
|
|
cardVoices,
|
|
subscriptionPlans,
|
|
userSubscriptions,
|
|
payments,
|
|
tests,
|
|
testQuestions,
|
|
testPackRelations,
|
|
testStatistics,
|
|
tasks,
|
|
userTasks,
|
|
userTaskProgresses,
|
|
userTaskResults,
|
|
promoCodesCampaigns,
|
|
promoCodes,
|
|
discountCampaigns,
|
|
discounts,
|
|
discountUserDatas,
|
|
studySessions,
|
|
userAchievements,
|
|
shareRequests
|
|
];
|
|
@override
|
|
StreamQueryUpdateRules get streamUpdateRules => const StreamQueryUpdateRules(
|
|
[
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('user_datas', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('tokens', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('refresh_tokens', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('card_packs',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('game_cards', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('game_cards',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('voice_models', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('user_packs', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('card_packs',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('user_packs', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('card_packs',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('preview_cards', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('game_cards',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('preview_cards', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('card_packs',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('card_pack_cards', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('game_cards',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('card_pack_cards', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('game_cards',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('card_voices', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('voice_models',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('card_voices', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('user_subscriptions', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('payments', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('tests',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('test_questions', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('tests',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('test_pack_relations', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('card_packs',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('test_pack_relations', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('tests',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('test_statistics', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('user_task_progresses', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('user_task_results', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('promo_codes_campaigns',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('promo_codes', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('promo_codes', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('discount_campaigns',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('discounts', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('discounts',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('discount_user_datas', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('discount_user_datas', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('study_sessions', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
WritePropagation(
|
|
on: TableUpdateQuery.onTableName('users',
|
|
limitUpdateKind: UpdateKind.delete),
|
|
result: [
|
|
TableUpdate('user_achievements', kind: UpdateKind.delete),
|
|
],
|
|
),
|
|
],
|
|
);
|
|
}
|