@@ -2,19 +2,19 @@ import 'package:powersync/powersync.dart';
22import 'package:powersync_flutter_local_only_demo/models/sync_mode.dart' ;
33
44/// This schema design supports a local-only to sync workflow by managing data
5- /// across two versions of each table: one for local/offline use and one for
6- /// online/synced use. This approach simplifies the handling of data in different
7- /// connectivity states.
5+ /// across two versions of each table: one for local-only use without syncing before a user registers,
6+ /// the other for sync-enabled use after the user registers/signs in.
87///
98/// See the README for details.
109///
11- /// For an offline-to-online transition [switchToSyncedSchema] copies data so that it ends up in the upload queue.
10+ /// [switchToSyncedSchema] copies data from the local-only tables to the sync-enabled tables
11+ /// so that it ends up in the upload queue.
1212
1313const todosTable = 'todos' ;
1414const listsTable = 'lists' ;
1515
1616Schema makeSchema ({synced = bool }) {
17- String onlineName (String table) {
17+ String syncedName (String table) {
1818 if (synced) {
1919 return table;
2020 } else {
@@ -53,7 +53,7 @@ Schema makeSchema({synced = bool}) {
5353 return Schema ([
5454 for (var table in tables)
5555 Table (table.name, table.columns,
56- indexes: table.indexes, viewName: onlineName (table.name)),
56+ indexes: table.indexes, viewName: syncedName (table.name)),
5757 for (var table in tables)
5858 Table .localOnly ('local_${table .name }' , table.columns,
5959 indexes: table.indexes, viewName: localName (table.name))
@@ -68,8 +68,8 @@ switchToSyncedSchema(PowerSyncDatabase db, String userId) async {
6868 await setSyncEnabled (true );
6969
7070 await db.writeTransaction ((tx) async {
71- // Copy local-only data to the "online" views.
72- // This records each operation to the crud queue.
71+ // Copy local-only data to the sync-enabled tables/ views.
72+ // This records each operation in the upload queue.
7373 await tx.execute (
7474 'INSERT INTO lists(id, name, created_at, owner_id) SELECT id, name, created_at, ? FROM inactive_local_lists' ,
7575 [userId]);
0 commit comments