@@ -172,28 +172,21 @@ VALUES(4,
172172 }
173173
174174 if current_version < 5 && target_version >= 5 {
175- // Start by dropping all triggers on views (but not views tables).
175+ // Start by dropping all existing views and triggers (but not tables).
176176 // This is because the triggers are restructured in this version, and
177177 // need to be re-created from scratch. Not dropping them can make it
178178 // refer to tables or columns not existing anymore, which can case
179179 // issues later on.
180- //
181- // Similarly, dropping the views themselves can cause issues with
182- // user-defined triggers that refer to them.
183- //
184- // The same applies for the down migration, except there we do drop
185- // the views, since we cannot use the `powersync_views` view.
186- // Down migrations are less common, so we're okay about that breaking
187- // in some cases.
180+ // The same applies for the down migration.
188181
189182 // language=SQLite
190183 local_db
191184 . exec_safe (
192185 "\
193- UPDATE powersync_views SET
194- delete_trigger_sql = '',
195- update_trigger_sql = '',
196- insert_trigger_sql = ' ';
186+ SELECT powersync_drop_view(view.name)
187+ FROM sqlite_master view
188+ WHERE view.type = 'view'
189+ AND view.sql GLOB '*-- powersync-auto-generated ';
197190
198191ALTER TABLE ps_buckets RENAME TO ps_buckets_old;
199192ALTER TABLE ps_oplog RENAME TO ps_oplog_old;
0 commit comments