Fix: Fügt die SyncLog-Tabelle zur Datenbank hinzu

This commit is contained in:
2026-01-02 01:05:50 +01:00
parent 24a9e3d027
commit 8d291a0d39
2 changed files with 512 additions and 14 deletions

View File

@@ -87,7 +87,7 @@ class SyncLog extends Table {
} }
/// Hauptklasse für die Drift-Datenbank der Anwendung. /// Hauptklasse für die Drift-Datenbank der Anwendung.
@DriftDatabase(tables: [Accounts, Transactions, RecurringTransactions]) @DriftDatabase(tables: [Accounts, Transactions, RecurringTransactions, SyncLog])
class AppDatabase extends _$AppDatabase { class AppDatabase extends _$AppDatabase {
/// Erstellt eine neue Datenbankinstanz /// Erstellt eine neue Datenbankinstanz
AppDatabase() : super(_openConnection()); AppDatabase() : super(_openConnection());

View File

@@ -578,8 +578,8 @@ class RecurringTransaction extends DataClass
return (StringBuffer('RecurringTransaction(') return (StringBuffer('RecurringTransaction(')
..write('id: $id, ') ..write('id: $id, ')
..write('name: $name, ') ..write('name: $name, ')
..write('startDate: $startDate, ') ..write('startDate: $startDate, ')..write(
..write('timeFrame: $timeFrame, ')..write('amount: $amount, ')..write( 'timeFrame: $timeFrame, ')..write('amount: $amount, ')..write(
'accountId: $accountId, ')..write('updatedAt: $updatedAt') 'accountId: $accountId, ')..write('updatedAt: $updatedAt')
..write(')')) ..write(')'))
.toString(); .toString();
@@ -703,8 +703,8 @@ class RecurringTransactionsCompanion
return (StringBuffer('RecurringTransactionsCompanion(') return (StringBuffer('RecurringTransactionsCompanion(')
..write('id: $id, ') ..write('id: $id, ')
..write('name: $name, ') ..write('name: $name, ')
..write('startDate: $startDate, ') ..write('startDate: $startDate, ')..write(
..write('timeFrame: $timeFrame, ')..write('amount: $amount, ')..write( 'timeFrame: $timeFrame, ')..write('amount: $amount, ')..write(
'accountId: $accountId, ')..write('updatedAt: $updatedAt') 'accountId: $accountId, ')..write('updatedAt: $updatedAt')
..write(')')) ..write(')'))
.toString(); .toString();
@@ -1076,10 +1076,9 @@ class Transaction extends DataClass implements Insertable<Transaction> {
@override @override
String toString() { String toString() {
return (StringBuffer('Transaction(') return (StringBuffer('Transaction(')
..write('id: $id, ') ..write('id: $id, ')..write('name: $name, ')..write(
..write('name: $name, ')..write('date: $date, ')..write( 'date: $date, ')..write('amount: $amount, ')..write(
'amount: $amount, ')..write('checked: $checked, ')..write( 'checked: $checked, ')..write('accountId: $accountId, ')..write(
'accountId: $accountId, ')..write(
'recurringTransactionId: $recurringTransactionId, ')..write( 'recurringTransactionId: $recurringTransactionId, ')..write(
'updatedAt: $updatedAt') 'updatedAt: $updatedAt')
..write(')')) ..write(')'))
@@ -1221,12 +1220,328 @@ class TransactionsCompanion extends UpdateCompanion<Transaction> {
@override @override
String toString() { String toString() {
return (StringBuffer('TransactionsCompanion(') return (StringBuffer('TransactionsCompanion(')
..write('id: $id, ') ..write('id: $id, ')..write('name: $name, ')..write(
..write('name: $name, ')..write('date: $date, ')..write( 'date: $date, ')..write('amount: $amount, ')..write(
'amount: $amount, ')..write('checked: $checked, ')..write( 'checked: $checked, ')..write('accountId: $accountId, ')..write(
'accountId: $accountId, ')..write(
'recurringTransactionId: $recurringTransactionId, ')..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<int> id = GeneratedColumn<int>(
'id',
aliasedName,
false,
hasAutoIncrement: true,
type: DriftSqlType.int,
requiredDuringInsert: false,
defaultConstraints: GeneratedColumn.constraintIsAlways(
'PRIMARY KEY AUTOINCREMENT',
),
);
@override
late final GeneratedColumnWithTypeConverter<SyncLogTypeEnum, int> type =
GeneratedColumn<int>(
'type',
aliasedName,
false,
type: DriftSqlType.int,
requiredDuringInsert: true,
).withConverter<SyncLogTypeEnum>($SyncLogTable.$convertertype);
static const VerificationMeta _descriptionMeta = const VerificationMeta(
'description',
);
@override
late final GeneratedColumn<String> description = GeneratedColumn<String>(
'description',
aliasedName,
false,
type: DriftSqlType.string,
requiredDuringInsert: false,
defaultValue: const Constant(''),
);
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, type, description, updatedAt];
@override
String get aliasedName => _alias ?? actualTableName;
@override
String get actualTableName => $name;
static const String $name = 'sync_log';
@override
VerificationContext validateIntegrity(Insertable<SyncLogData> 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<GeneratedColumn> get $primaryKey => {id};
@override
SyncLogData map(Map<String, dynamic> 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<SyncLogTypeEnum, int, int> $convertertype =
const EnumIndexConverter<SyncLogTypeEnum>(SyncLogTypeEnum.values);
}
class SyncLogData extends DataClass implements Insertable<SyncLogData> {
/// 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<String, Expression> toColumns(bool nullToAbsent) {
final map = <String, Expression>{};
map['id'] = Variable<int>(id);
{
map['type'] = Variable<int>($SyncLogTable.$convertertype.toSql(type));
}
map['description'] = Variable<String>(description);
map['updated_at'] = Variable<DateTime>(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<String, dynamic> json, {
ValueSerializer? serializer,
}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return SyncLogData(
id: serializer.fromJson<int>(json['id']),
type: $SyncLogTable.$convertertype.fromJson(
serializer.fromJson<int>(json['type']),
),
description: serializer.fromJson<String>(json['description']),
updatedAt: serializer.fromJson<DateTime>(json['updatedAt']),
);
}
@override
Map<String, dynamic> toJson({ValueSerializer? serializer}) {
serializer ??= driftRuntimeOptions.defaultSerializer;
return <String, dynamic>{
'id': serializer.toJson<int>(id),
'type': serializer.toJson<int>($SyncLogTable.$convertertype.toJson(type)),
'description': serializer.toJson<String>(description),
'updatedAt': serializer.toJson<DateTime>(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<SyncLogData> {
final Value<int> id;
final Value<SyncLogTypeEnum> type;
final Value<String> description;
final Value<DateTime> 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<SyncLogData> custom({
Expression<int>? id,
Expression<int>? type,
Expression<String>? description,
Expression<DateTime>? 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<int>? id,
Value<SyncLogTypeEnum>? type,
Value<String>? description,
Value<DateTime>? updatedAt,
}) {
return SyncLogCompanion(
id: id ?? this.id,
type: type ?? this.type,
description: description ?? this.description,
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 (type.present) {
map['type'] = Variable<int>(
$SyncLogTable.$convertertype.toSql(type.value),
);
}
if (description.present) {
map['description'] = Variable<String>(description.value);
}
if (updatedAt.present) {
map['updated_at'] = Variable<DateTime>(updatedAt.value);
}
return map;
}
@override
String toString() {
return (StringBuffer('SyncLogCompanion(')
..write('id: $id, ')..write('type: $type, ')..write(
'description: $description, ')..write('updatedAt: $updatedAt')
..write(')')) ..write(')'))
.toString(); .toString();
} }
@@ -1239,6 +1554,7 @@ abstract class _$AppDatabase extends GeneratedDatabase {
late final $RecurringTransactionsTable recurringTransactions = late final $RecurringTransactionsTable recurringTransactions =
$RecurringTransactionsTable(this); $RecurringTransactionsTable(this);
late final $TransactionsTable transactions = $TransactionsTable(this); late final $TransactionsTable transactions = $TransactionsTable(this);
late final $SyncLogTable syncLog = $SyncLogTable(this);
@override @override
Iterable<TableInfo<Table, Object?>> get allTables => Iterable<TableInfo<Table, Object?>> get allTables =>
allSchemaEntities.whereType<TableInfo<Table, Object?>>(); allSchemaEntities.whereType<TableInfo<Table, Object?>>();
@@ -1247,6 +1563,7 @@ abstract class _$AppDatabase extends GeneratedDatabase {
accounts, accounts,
recurringTransactions, recurringTransactions,
transactions, transactions,
syncLog,
]; ];
} }
@@ -2564,6 +2881,184 @@ typedef $$TransactionsTableProcessedTableManager =
Transaction, Transaction,
PrefetchHooks Function({bool accountId, bool recurringTransactionId}) PrefetchHooks Function({bool accountId, bool recurringTransactionId})
>; >;
typedef $$SyncLogTableCreateCompanionBuilder =
SyncLogCompanion Function({
Value<int> id,
required SyncLogTypeEnum type,
Value<String> description,
Value<DateTime> updatedAt,
});
typedef $$SyncLogTableUpdateCompanionBuilder =
SyncLogCompanion Function({
Value<int> id,
Value<SyncLogTypeEnum> type,
Value<String> description,
Value<DateTime> updatedAt,
});
class $$SyncLogTableFilterComposer
extends Composer<_$AppDatabase, $SyncLogTable> {
$$SyncLogTableFilterComposer({
required super.$db,
required super.$table,
super.joinBuilder,
super.$addJoinBuilderToRootComposer,
super.$removeJoinBuilderFromRootComposer,
});
ColumnFilters<int> get id => $composableBuilder(
column: $table.id,
builder: (column) => ColumnFilters(column),
);
ColumnWithTypeConverterFilters<SyncLogTypeEnum, SyncLogTypeEnum, int>
get type => $composableBuilder(
column: $table.type,
builder: (column) => ColumnWithTypeConverterFilters(column),
);
ColumnFilters<String> get description => $composableBuilder(
column: $table.description,
builder: (column) => ColumnFilters(column),
);
ColumnFilters<DateTime> 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<int> get id => $composableBuilder(
column: $table.id,
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<int> get type => $composableBuilder(
column: $table.type,
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<String> get description => $composableBuilder(
column: $table.description,
builder: (column) => ColumnOrderings(column),
);
ColumnOrderings<DateTime> 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<int> get id =>
$composableBuilder(column: $table.id, builder: (column) => column);
GeneratedColumnWithTypeConverter<SyncLogTypeEnum, int> get type =>
$composableBuilder(column: $table.type, builder: (column) => column);
GeneratedColumn<String> get description => $composableBuilder(
column: $table.description,
builder: (column) => column,
);
GeneratedColumn<DateTime> 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<int> id = const Value.absent(),
Value<SyncLogTypeEnum> type = const Value.absent(),
Value<String> description = const Value.absent(),
Value<DateTime> updatedAt = const Value.absent(),
}) => SyncLogCompanion(
id: id,
type: type,
description: description,
updatedAt: updatedAt,
),
createCompanionCallback:
({
Value<int> id = const Value.absent(),
required SyncLogTypeEnum type,
Value<String> description = const Value.absent(),
Value<DateTime> 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 { class $AppDatabaseManager {
final _$AppDatabase _db; final _$AppDatabase _db;
@@ -2574,4 +3069,7 @@ class $AppDatabaseManager {
$$RecurringTransactionsTableTableManager(_db, _db.recurringTransactions); $$RecurringTransactionsTableTableManager(_db, _db.recurringTransactions);
$$TransactionsTableTableManager get transactions => $$TransactionsTableTableManager get transactions =>
$$TransactionsTableTableManager(_db, _db.transactions); $$TransactionsTableTableManager(_db, _db.transactions);
$$SyncLogTableTableManager get syncLog =>
$$SyncLogTableTableManager(_db, _db.syncLog);
} }