Skip to content

Custom sqlite migration tooling for cloud-sync-ready#5049

Merged
yujonglee merged 6 commits intomainfrom
custom-sqlite-migrate
Apr 15, 2026
Merged

Custom sqlite migration tooling for cloud-sync-ready#5049
yujonglee merged 6 commits intomainfrom
custom-sqlite-migrate

Conversation

@yujonglee
Copy link
Copy Markdown
Contributor

@yujonglee yujonglee commented Apr 15, 2026

Apparently we need custom migration tooling if we want to enable syncing — CloudSync tracks row-level changes for replication, so schema DDL must be wrapped in begin_alter/commit_alter on the same connection, and sqlx's built-in migrator doesn't expose a hook to inject those calls.

Signed-off-by: Yujong Lee <yujonglee.dev@gmail.com>
Signed-off-by: Yujong Lee <yujonglee.dev@gmail.com>
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 15, 2026

Deploy Preview for char-cli-web canceled.

Name Link
🔨 Latest commit 50b6931
🔍 Latest deploy log https://app.netlify.com/projects/char-cli-web/deploys/69df20b9b7636d0008b9f982

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 15, 2026

Deploy Preview for hyprnote canceled.

Name Link
🔨 Latest commit 50b6931
🔍 Latest deploy log https://app.netlify.com/projects/hyprnote/deploys/69df20b90981a000082a44ea

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 15, 2026

Deploy Preview for unsigned-char ready!

Name Link
🔨 Latest commit 50b6931
🔍 Latest deploy log https://app.netlify.com/projects/unsigned-char/deploys/69df20b93106db00084266e6
😎 Deploy Preview https://deploy-preview-5049--unsigned-char.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread crates/db-migrate/src/lib.rs Outdated
Signed-off-by: Yujong Lee <yujonglee.dev@gmail.com>
Comment thread crates/db-migrate/src/migrate.rs
Signed-off-by: Yujong Lee <yujonglee.dev@gmail.com>
Comment thread crates/db-migrate/src/migrate.rs
Signed-off-by: Yujong Lee <yujonglee.dev@gmail.com>
Signed-off-by: Yujong Lee <yujonglee.dev@gmail.com>
@yujonglee yujonglee merged commit fab651c into main Apr 15, 2026
19 of 22 checks passed
@yujonglee yujonglee deleted the custom-sqlite-migrate branch April 15, 2026 05:24
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 50b6931. Configure here.

Comment thread crates/db-app/src/lib.rs
.unwrap();

assert!(tables.contains(&"templates".to_string()));
assert!(tables.contains(&"_char_migrations".to_string()));
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests assert nonexistent _char_migrations table exists

High Severity

Two tests assert that a _char_migrations table exists, but nothing in the codebase creates it. The migration SQL files only create templates, calendars, and events. The migration infrastructure creates _sqlx_migrations (filtered out by NOT LIKE '_sqlx%'). The _char_migrations table appears nowhere else in the repo — both schema_declares_legacy_migrations_and_cloudsync_registry and migrations_apply_cleanly will fail.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 50b6931. Configure here.


hypr_db_core2::cloudsync_commit_alter_on(&mut *self.conn, table_name)
.await
.map_err(cloudsync_error)?;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CloudSync alter records success before commit completes

Medium Severity

In the CloudsyncAlter apply path, execute_migration inserts into _sqlx_migrations with success = TRUE before cloudsync_commit_alter_on is called. If commit_alter fails, the migration is permanently recorded as successful, so subsequent runs skip it — leaving CloudSync's alter protocol incomplete and unrecoverable. The success record needs to be finalized only after commit_alter succeeds.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 50b6931. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant