import 'package:drift/drift.dart'; /// Common columns on every *mutable* row (data-model §1). Carries the metadata /// needed to merge across devices later (CRDT), even before sync exists. /// /// `updatedAt` stores a packed [Hlc] string; `isDeleted` is a tombstone — /// rows are never physically deleted, so they can merge correctly. mixin SyncColumns on Table { TextColumn get id => text()(); IntColumn get createdAt => integer()(); TextColumn get updatedAt => text()(); // packed HLC TextColumn get lastAuthor => text()(); // public key / device id BoolColumn get isDeleted => boolean().withDefault(const Constant(false))(); IntColumn get schemaRowVersion => integer().withDefault(const Constant(1))(); @override Set get primaryKey => {id}; } /// Common columns on *append-only* rows (only `Movement` for now). Immutable /// events: no `updatedAt`/`isDeleted` — a correction is a new compensating row. mixin AppendOnlyColumns on Table { TextColumn get id => text()(); IntColumn get createdAt => integer()(); TextColumn get lastAuthor => text()(); IntColumn get schemaRowVersion => integer().withDefault(const Constant(1))(); @override Set get primaryKey => {id}; }