diff --git a/lib/Entities/drift_database.dart b/lib/Entities/drift_database.dart index 712c929..496b348 100644 --- a/lib/Entities/drift_database.dart +++ b/lib/Entities/drift_database.dart @@ -87,7 +87,7 @@ class SyncLog extends Table { } /// Hauptklasse für die Drift-Datenbank der Anwendung. -@DriftDatabase(tables: [Accounts, Transactions, RecurringTransactions]) +@DriftDatabase(tables: [Accounts, Transactions, RecurringTransactions, SyncLog]) class AppDatabase extends _$AppDatabase { /// Erstellt eine neue Datenbankinstanz AppDatabase() : super(_openConnection()); diff --git a/lib/Entities/drift_database.g.dart b/lib/Entities/drift_database.g.dart index 540bd7a..9c1c3e3 100644 --- a/lib/Entities/drift_database.g.dart +++ b/lib/Entities/drift_database.g.dart @@ -578,8 +578,8 @@ class RecurringTransaction extends DataClass return (StringBuffer('RecurringTransaction(') ..write('id: $id, ') ..write('name: $name, ') - ..write('startDate: $startDate, ') - ..write('timeFrame: $timeFrame, ')..write('amount: $amount, ')..write( + ..write('startDate: $startDate, ')..write( + 'timeFrame: $timeFrame, ')..write('amount: $amount, ')..write( 'accountId: $accountId, ')..write('updatedAt: $updatedAt') ..write(')')) .toString(); @@ -703,8 +703,8 @@ class RecurringTransactionsCompanion return (StringBuffer('RecurringTransactionsCompanion(') ..write('id: $id, ') ..write('name: $name, ') - ..write('startDate: $startDate, ') - ..write('timeFrame: $timeFrame, ')..write('amount: $amount, ')..write( + ..write('startDate: $startDate, ')..write( + 'timeFrame: $timeFrame, ')..write('amount: $amount, ')..write( 'accountId: $accountId, ')..write('updatedAt: $updatedAt') ..write(')')) .toString(); @@ -1076,10 +1076,9 @@ class Transaction extends DataClass implements Insertable { @override String toString() { return (StringBuffer('Transaction(') - ..write('id: $id, ') - ..write('name: $name, ')..write('date: $date, ')..write( - 'amount: $amount, ')..write('checked: $checked, ')..write( - 'accountId: $accountId, ')..write( + ..write('id: $id, ')..write('name: $name, ')..write( + 'date: $date, ')..write('amount: $amount, ')..write( + 'checked: $checked, ')..write('accountId: $accountId, ')..write( 'recurringTransactionId: $recurringTransactionId, ')..write( 'updatedAt: $updatedAt') ..write(')')) @@ -1221,12 +1220,328 @@ class TransactionsCompanion extends UpdateCompanion { @override String toString() { return (StringBuffer('TransactionsCompanion(') - ..write('id: $id, ') - ..write('name: $name, ')..write('date: $date, ')..write( - 'amount: $amount, ')..write('checked: $checked, ')..write( - 'accountId: $accountId, ')..write( + ..write('id: $id, ')..write('name: $name, ')..write( + 'date: $date, ')..write('amount: $amount, ')..write( + 'checked: $checked, ')..write('accountId: $accountId, ')..write( 'recurringTransactionId: $recurringTransactionId, ')..write( - 'updatedAt: $updatedAt') + 'updatedAt: $updatedAt')..write(')')) + .toString(); + } +} + +class $SyncLogTable extends SyncLog with TableInfo<$SyncLogTable, SyncLogData> { + @override + final GeneratedDatabase attachedDatabase; + final String? _alias; + + $SyncLogTable(this.attachedDatabase, [this._alias]); + + static const VerificationMeta _idMeta = const VerificationMeta('id'); + @override + late final GeneratedColumn id = GeneratedColumn( + 'id', + aliasedName, + false, + hasAutoIncrement: true, + type: DriftSqlType.int, + requiredDuringInsert: false, + defaultConstraints: GeneratedColumn.constraintIsAlways( + 'PRIMARY KEY AUTOINCREMENT', + ), + ); + @override + late final GeneratedColumnWithTypeConverter type = + GeneratedColumn( + 'type', + aliasedName, + false, + type: DriftSqlType.int, + requiredDuringInsert: true, + ).withConverter($SyncLogTable.$convertertype); + static const VerificationMeta _descriptionMeta = const VerificationMeta( + 'description', + ); + @override + late final GeneratedColumn description = GeneratedColumn( + 'description', + aliasedName, + false, + type: DriftSqlType.string, + requiredDuringInsert: false, + defaultValue: const Constant(''), + ); + static const VerificationMeta _updatedAtMeta = const VerificationMeta( + 'updatedAt', + ); + @override + late final GeneratedColumn updatedAt = GeneratedColumn( + 'updated_at', + aliasedName, + false, + type: DriftSqlType.dateTime, + requiredDuringInsert: false, + defaultValue: currentDateAndTime, + ); + + @override + List get $columns => [id, type, description, updatedAt]; + + @override + String get aliasedName => _alias ?? actualTableName; + + @override + String get actualTableName => $name; + static const String $name = 'sync_log'; + + @override + VerificationContext validateIntegrity(Insertable 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('description')) { + context.handle( + _descriptionMeta, + description.isAcceptableOrUnknown( + data['description']!, + _descriptionMeta, + ), + ); + } + if (data.containsKey('updated_at')) { + context.handle( + _updatedAtMeta, + updatedAt.isAcceptableOrUnknown(data['updated_at']!, _updatedAtMeta), + ); + } + return context; + } + + @override + Set get $primaryKey => {id}; + + @override + SyncLogData map(Map data, {String? tablePrefix}) { + final effectivePrefix = tablePrefix != null ? '$tablePrefix.' : ''; + return SyncLogData( + id: attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}id'], + )!, + type: $SyncLogTable.$convertertype.fromSql( + attachedDatabase.typeMapping.read( + DriftSqlType.int, + data['${effectivePrefix}type'], + )!, + ), + description: attachedDatabase.typeMapping.read( + DriftSqlType.string, + data['${effectivePrefix}description'], + )!, + updatedAt: attachedDatabase.typeMapping.read( + DriftSqlType.dateTime, + data['${effectivePrefix}updated_at'], + )!, + ); + } + + @override + $SyncLogTable createAlias(String alias) { + return $SyncLogTable(attachedDatabase, alias); + } + + static JsonTypeConverter2 $convertertype = + const EnumIndexConverter(SyncLogTypeEnum.values); +} + +class SyncLogData extends DataClass implements Insertable { + /// Eindeutige ID des SyncLogs + final int id; + + /// Der Typ des SyncLogs + final SyncLogTypeEnum type; + + /// Die Beschreibung der Eintragung des SyncLogs + final String description; + + /// Wann dieser SyncLog das letzte mal geupdated wurde + final DateTime updatedAt; + + const SyncLogData({ + required this.id, + required this.type, + required this.description, + required this.updatedAt, + }); + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + map['id'] = Variable(id); + { + map['type'] = Variable($SyncLogTable.$convertertype.toSql(type)); + } + map['description'] = Variable(description); + map['updated_at'] = Variable(updatedAt); + return map; + } + + SyncLogCompanion toCompanion(bool nullToAbsent) { + return SyncLogCompanion( + id: Value(id), + type: Value(type), + description: Value(description), + updatedAt: Value(updatedAt), + ); + } + + factory SyncLogData.fromJson(Map json, { + ValueSerializer? serializer, + }) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return SyncLogData( + id: serializer.fromJson(json['id']), + type: $SyncLogTable.$convertertype.fromJson( + serializer.fromJson(json['type']), + ), + description: serializer.fromJson(json['description']), + updatedAt: serializer.fromJson(json['updatedAt']), + ); + } + + @override + Map toJson({ValueSerializer? serializer}) { + serializer ??= driftRuntimeOptions.defaultSerializer; + return { + 'id': serializer.toJson(id), + 'type': serializer.toJson($SyncLogTable.$convertertype.toJson(type)), + 'description': serializer.toJson(description), + 'updatedAt': serializer.toJson(updatedAt), + }; + } + + SyncLogData copyWith({ + int? id, + SyncLogTypeEnum? type, + String? description, + DateTime? updatedAt, + }) => + SyncLogData( + id: id ?? this.id, + type: type ?? this.type, + description: description ?? this.description, + updatedAt: updatedAt ?? this.updatedAt, + ); + + SyncLogData copyWithCompanion(SyncLogCompanion data) { + return SyncLogData( + id: data.id.present ? data.id.value : this.id, + type: data.type.present ? data.type.value : this.type, + description: data.description.present + ? data.description.value + : this.description, + updatedAt: data.updatedAt.present ? data.updatedAt.value : this.updatedAt, + ); + } + + @override + String toString() { + return (StringBuffer('SyncLogData(') + ..write('id: $id, ')..write('type: $type, ')..write( + 'description: $description, ')..write('updatedAt: $updatedAt')..write( + ')')) + .toString(); + } + + @override + int get hashCode => Object.hash(id, type, description, updatedAt); + + @override + bool operator ==(Object other) => + identical(this, other) || + (other is SyncLogData && + other.id == this.id && + other.type == this.type && + other.description == this.description && + other.updatedAt == this.updatedAt); +} + +class SyncLogCompanion extends UpdateCompanion { + final Value id; + final Value type; + final Value description; + final Value updatedAt; + + const SyncLogCompanion({ + this.id = const Value.absent(), + this.type = const Value.absent(), + this.description = const Value.absent(), + this.updatedAt = const Value.absent(), + }); + + SyncLogCompanion.insert({ + this.id = const Value.absent(), + required SyncLogTypeEnum type, + this.description = const Value.absent(), + this.updatedAt = const Value.absent(), + }) : type = Value(type); + + static Insertable custom({ + Expression? id, + Expression? type, + Expression? description, + Expression? updatedAt, + }) { + return RawValuesInsertable({ + if (id != null) 'id': id, + if (type != null) 'type': type, + if (description != null) 'description': description, + if (updatedAt != null) 'updated_at': updatedAt, + }); + } + + SyncLogCompanion copyWith({ + Value? id, + Value? type, + Value? description, + Value? updatedAt, + }) { + return SyncLogCompanion( + id: id ?? this.id, + type: type ?? this.type, + description: description ?? this.description, + updatedAt: updatedAt ?? this.updatedAt, + ); + } + + @override + Map toColumns(bool nullToAbsent) { + final map = {}; + if (id.present) { + map['id'] = Variable(id.value); + } + if (type.present) { + map['type'] = Variable( + $SyncLogTable.$convertertype.toSql(type.value), + ); + } + if (description.present) { + map['description'] = Variable(description.value); + } + if (updatedAt.present) { + map['updated_at'] = Variable(updatedAt.value); + } + return map; + } + + @override + String toString() { + return (StringBuffer('SyncLogCompanion(') + ..write('id: $id, ')..write('type: $type, ')..write( + 'description: $description, ')..write('updatedAt: $updatedAt') ..write(')')) .toString(); } @@ -1239,6 +1554,7 @@ abstract class _$AppDatabase extends GeneratedDatabase { late final $RecurringTransactionsTable recurringTransactions = $RecurringTransactionsTable(this); late final $TransactionsTable transactions = $TransactionsTable(this); + late final $SyncLogTable syncLog = $SyncLogTable(this); @override Iterable> get allTables => allSchemaEntities.whereType>(); @@ -1247,6 +1563,7 @@ abstract class _$AppDatabase extends GeneratedDatabase { accounts, recurringTransactions, transactions, + syncLog, ]; } @@ -2564,6 +2881,184 @@ typedef $$TransactionsTableProcessedTableManager = Transaction, PrefetchHooks Function({bool accountId, bool recurringTransactionId}) >; +typedef $$SyncLogTableCreateCompanionBuilder = + SyncLogCompanion Function({ + Value id, + required SyncLogTypeEnum type, + Value description, + Value updatedAt, + }); +typedef $$SyncLogTableUpdateCompanionBuilder = + SyncLogCompanion Function({ + Value id, + Value type, + Value description, + Value updatedAt, + }); + +class $$SyncLogTableFilterComposer + extends Composer<_$AppDatabase, $SyncLogTable> { + $$SyncLogTableFilterComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + + ColumnFilters get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnFilters(column), + ); + + ColumnWithTypeConverterFilters + get type => $composableBuilder( + column: $table.type, + builder: (column) => ColumnWithTypeConverterFilters(column), + ); + + ColumnFilters get description => $composableBuilder( + column: $table.description, + builder: (column) => ColumnFilters(column), + ); + + ColumnFilters get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => ColumnFilters(column), + ); +} + +class $$SyncLogTableOrderingComposer + extends Composer<_$AppDatabase, $SyncLogTable> { + $$SyncLogTableOrderingComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + + ColumnOrderings get id => $composableBuilder( + column: $table.id, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get type => $composableBuilder( + column: $table.type, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get description => $composableBuilder( + column: $table.description, + builder: (column) => ColumnOrderings(column), + ); + + ColumnOrderings get updatedAt => $composableBuilder( + column: $table.updatedAt, + builder: (column) => ColumnOrderings(column), + ); +} + +class $$SyncLogTableAnnotationComposer + extends Composer<_$AppDatabase, $SyncLogTable> { + $$SyncLogTableAnnotationComposer({ + required super.$db, + required super.$table, + super.joinBuilder, + super.$addJoinBuilderToRootComposer, + super.$removeJoinBuilderFromRootComposer, + }); + + GeneratedColumn get id => + $composableBuilder(column: $table.id, builder: (column) => column); + + GeneratedColumnWithTypeConverter get type => + $composableBuilder(column: $table.type, builder: (column) => column); + + GeneratedColumn get description => $composableBuilder( + column: $table.description, + builder: (column) => column, + ); + + GeneratedColumn get updatedAt => + $composableBuilder(column: $table.updatedAt, builder: (column) => column); +} + +class $$SyncLogTableTableManager + extends + RootTableManager< + _$AppDatabase, + $SyncLogTable, + SyncLogData, + $$SyncLogTableFilterComposer, + $$SyncLogTableOrderingComposer, + $$SyncLogTableAnnotationComposer, + $$SyncLogTableCreateCompanionBuilder, + $$SyncLogTableUpdateCompanionBuilder, + ( + SyncLogData, + BaseReferences<_$AppDatabase, $SyncLogTable, SyncLogData>, + ), + SyncLogData, + PrefetchHooks Function() + > { + $$SyncLogTableTableManager(_$AppDatabase db, $SyncLogTable table) + : super( + TableManagerState( + db: db, + table: table, + createFilteringComposer: () => + $$SyncLogTableFilterComposer($db: db, $table: table), + createOrderingComposer: () => + $$SyncLogTableOrderingComposer($db: db, $table: table), + createComputedFieldComposer: () => + $$SyncLogTableAnnotationComposer($db: db, $table: table), + updateCompanionCallback: + ({ + Value id = const Value.absent(), + Value type = const Value.absent(), + Value description = const Value.absent(), + Value updatedAt = const Value.absent(), + }) => SyncLogCompanion( + id: id, + type: type, + description: description, + updatedAt: updatedAt, + ), + createCompanionCallback: + ({ + Value id = const Value.absent(), + required SyncLogTypeEnum type, + Value description = const Value.absent(), + Value updatedAt = const Value.absent(), + }) => SyncLogCompanion.insert( + id: id, + type: type, + description: description, + updatedAt: updatedAt, + ), + withReferenceMapper: (p0) => p0 + .map((e) => (e.readTable(table), BaseReferences(db, table, e))) + .toList(), + prefetchHooksCallback: null, + ), + ); +} + +typedef $$SyncLogTableProcessedTableManager = + ProcessedTableManager< + _$AppDatabase, + $SyncLogTable, + SyncLogData, + $$SyncLogTableFilterComposer, + $$SyncLogTableOrderingComposer, + $$SyncLogTableAnnotationComposer, + $$SyncLogTableCreateCompanionBuilder, + $$SyncLogTableUpdateCompanionBuilder, + (SyncLogData, BaseReferences<_$AppDatabase, $SyncLogTable, SyncLogData>), + SyncLogData, + PrefetchHooks Function() + >; class $AppDatabaseManager { final _$AppDatabase _db; @@ -2574,4 +3069,7 @@ class $AppDatabaseManager { $$RecurringTransactionsTableTableManager(_db, _db.recurringTransactions); $$TransactionsTableTableManager get transactions => $$TransactionsTableTableManager(_db, _db.transactions); + + $$SyncLogTableTableManager get syncLog => + $$SyncLogTableTableManager(_db, _db.syncLog); }