diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml
index f56db31..6460c18 100644
--- a/.github/workflows/macos.yml
+++ b/.github/workflows/macos.yml
@@ -21,7 +21,7 @@ jobs:
build_macOS_x64:
name: Building macOS x64
- runs-on: macos-12
+ runs-on: macos-14
steps:
- uses: actions/checkout@v3
with:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index c0d70ef..4d19330 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -244,7 +244,7 @@ jobs:
publish_macOS_x64:
name: Publish macOS x64
needs: [draft_release]
- runs-on: macos-12
+ runs-on: macos-14
steps:
- uses: actions/checkout@v3
with:
diff --git a/Cargo.lock b/Cargo.lock
index e3a96c5..f938be8 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -205,7 +205,7 @@ checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "powersync_core"
-version = "0.3.6"
+version = "0.3.7"
dependencies = [
"bytes",
"num-derive",
@@ -218,7 +218,7 @@ dependencies = [
[[package]]
name = "powersync_loadable"
-version = "0.3.6"
+version = "0.3.7"
dependencies = [
"powersync_core",
"sqlite_nostd",
@@ -226,7 +226,7 @@ dependencies = [
[[package]]
name = "powersync_sqlite"
-version = "0.3.6"
+version = "0.3.7"
dependencies = [
"cc",
"powersync_core",
@@ -331,7 +331,7 @@ checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "sqlite3"
-version = "0.3.6"
+version = "0.3.7"
dependencies = [
"cc",
]
diff --git a/Cargo.toml b/Cargo.toml
index f8f698c..669657c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,7 +24,7 @@ inherits = "release"
inherits = "wasm"
[workspace.package]
-version = "0.3.6"
+version = "0.3.7"
edition = "2021"
authors = ["JourneyApps"]
keywords = ["sqlite", "powersync"]
diff --git a/android/build.gradle.kts b/android/build.gradle.kts
index c31267c..e46132a 100644
--- a/android/build.gradle.kts
+++ b/android/build.gradle.kts
@@ -6,7 +6,7 @@ plugins {
}
group = "co.powersync"
-version = "0.3.6"
+version = "0.3.7"
description = "PowerSync Core SQLite Extension"
repositories {
diff --git a/android/src/prefab/prefab.json b/android/src/prefab/prefab.json
index de33c5c..be8f6f1 100644
--- a/android/src/prefab/prefab.json
+++ b/android/src/prefab/prefab.json
@@ -2,5 +2,5 @@
"name": "powersync_sqlite_core",
"schema_version": 2,
"dependencies": [],
- "version": "0.3.6"
+ "version": "0.3.7"
}
diff --git a/crates/core/src/migrations.rs b/crates/core/src/migrations.rs
index 802313a..bd999cd 100644
--- a/crates/core/src/migrations.rs
+++ b/crates/core/src/migrations.rs
@@ -172,21 +172,28 @@ VALUES(4,
}
if current_version < 5 && target_version >= 5 {
- // Start by dropping all existing views and triggers (but not tables).
+ // Start by dropping all triggers on views (but not views tables).
// This is because the triggers are restructured in this version, and
// need to be re-created from scratch. Not dropping them can make it
// refer to tables or columns not existing anymore, which can case
// issues later on.
- // The same applies for the down migration.
+ //
+ // Similarly, dropping the views themselves can cause issues with
+ // user-defined triggers that refer to them.
+ //
+ // The same applies for the down migration, except there we do drop
+ // the views, since we cannot use the `powersync_views` view.
+ // Down migrations are less common, so we're okay about that breaking
+ // in some cases.
// language=SQLite
local_db
.exec_safe(
"\
-SELECT powersync_drop_view(view.name)
-FROM sqlite_master view
-WHERE view.type = 'view'
- AND view.sql GLOB '*-- powersync-auto-generated';
+UPDATE powersync_views SET
+ delete_trigger_sql = '',
+ update_trigger_sql = '',
+ insert_trigger_sql = '';
ALTER TABLE ps_buckets RENAME TO ps_buckets_old;
ALTER TABLE ps_oplog RENAME TO ps_oplog_old;
diff --git a/dart/test/migration_test.dart b/dart/test/migration_test.dart
index 61340da..b50af97 100644
--- a/dart/test/migration_test.dart
+++ b/dart/test/migration_test.dart
@@ -211,5 +211,40 @@ void main() {
final data2 = getData(db);
expect(data2, equals(fix035.dataFixed.trim()));
});
+
+ /// Here we start with a schema from fixtures on db version 3
+ test('schema 3 -> 5 with custom triggers', () async {
+ db.execute(fixtures.expectedState[3]!);
+ db.execute(fixtures.schema3);
+ // This is a contrived example, but gives us a trigger
+ // that references the "lists" view, affecting migrations.
+ db.execute('''
+create trigger t1 after delete on ps_data__lists begin
+ insert into lists(id, description) values(OLD.id, 'deleted');
+end''');
+
+ var tableSchema = {
+ 'tables': [
+ {
+ 'name': 'lists',
+ 'columns': [
+ {'name': 'description', 'type': 'TEXT'}
+ ]
+ }
+ ]
+ };
+ db.select('select powersync_init()');
+ db.select(
+ 'select powersync_replace_schema(?)', [jsonEncode(tableSchema)]);
+
+ final schema = getSchema(db);
+ final expected =
+ '''${fixtures.finalState.replaceAll(RegExp(r';INSERT INTO ps_migration.*'), '').trim()}
+${fixtures.schema5.trim()}
+;CREATE TRIGGER t1 after delete on ps_data__lists begin
+ insert into lists(id, description) values(OLD.id, \'deleted\');
+end''';
+ expect(schema, equals(expected));
+ });
});
}
diff --git a/powersync-sqlite-core.podspec b/powersync-sqlite-core.podspec
index ad1844f..fe15be6 100644
--- a/powersync-sqlite-core.podspec
+++ b/powersync-sqlite-core.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'powersync-sqlite-core'
- s.version = '0.3.6'
+ s.version = '0.3.7'
s.summary = 'PowerSync SQLite Extension'
s.description = <<-DESC
PowerSync extension for SQLite.
diff --git a/tool/build_xcframework.sh b/tool/build_xcframework.sh
index 3cd0d58..4b6331c 100755
--- a/tool/build_xcframework.sh
+++ b/tool/build_xcframework.sh
@@ -28,9 +28,9 @@ function createXcframework() {
MinimumOSVersion
11.0
CFBundleVersion
- 0.3.6
+ 0.3.7
CFBundleShortVersionString
- 0.3.6
+ 0.3.7
EOF