deleteCachedData method

Future<void> deleteCachedData()

Clears all cached data while preserving user identity.

Deletes all rows from every table except Users, and resets the cache timestamps on Users so data is re-fetched on next access.

Implementation

Future<void> deleteCachedData() async {
  await transaction(() async {
    for (final entity in allSchemaEntities.toList().reversed) {
      if (entity is TableInfo && entity != users) {
        await delete(entity).go();
      }
    }

    await update(users).write(
      const UsersCompanion(
        fetchedAt: Value(null),
        semestersFetchedAt: Value(null),
        scoreDataFetchedAt: Value(null),
      ),
    );
  });
}