@@ -149,6 +149,12 @@ CREATE TABLE IF NOT EXISTS ps_migration(id INTEGER PRIMARY KEY, down_migrations
149
149
if current_version == 5 {
150
150
down_sql. push (
151
151
"\
152
+ -- Drop all existing views (and triggers)
153
+ SELECT powersync_drop_view(view.name)
154
+ FROM sqlite_master view
155
+ WHERE view.type = 'view'
156
+ AND view.sql GLOB '*-- powersync-auto-generated';
157
+
152
158
ALTER TABLE ps_buckets RENAME TO ps_buckets_5;
153
159
ALTER TABLE ps_oplog RENAME TO ps_oplog_5;
154
160
@@ -326,6 +332,12 @@ INSERT INTO ps_migration(id, down_migrations)
326
332
local_db
327
333
. exec_safe (
328
334
"\
335
+ -- Drop all existing views (and triggers)
336
+ SELECT powersync_drop_view(view.name)
337
+ FROM sqlite_master view
338
+ WHERE view.type = 'view'
339
+ AND view.sql GLOB '*-- powersync-auto-generated';
340
+
329
341
ALTER TABLE ps_buckets RENAME TO ps_buckets_old;
330
342
ALTER TABLE ps_oplog RENAME TO ps_oplog_old;
331
343
@@ -414,10 +426,10 @@ fn powersync_init_impl(
414
426
) -> Result < String , SQLiteError > {
415
427
let local_db = ctx. db_handle ( ) ;
416
428
417
- powersync_migrate ( ctx, 5 ) ?;
418
-
419
429
setup_internal_views ( local_db) ?;
420
430
431
+ powersync_migrate ( ctx, 5 ) ?;
432
+
421
433
Ok ( String :: from ( "" ) )
422
434
}
423
435
0 commit comments