tauri-apps / tauri-apps/plugins-workspace

[SQL] Optional migrations applying

Open
#3,465 3 comments 0 reactions 0 assignees View on GitHub
plugin: sql type: feature request
Dominant language
Rust
Stars
1.8k
Forks
602
Avg merge
4d 14h
Merged PRs (30d)
9

Description

### Describe the problem

Currently, the client side `load()` runs migrations in a "forced" way. There is no way to skip the process.
I think there are cases where the feature can be useful:
- The original migration script is lost and checksum is wrong. In this case there is no way to establish the connection with the database to fix the migrations table.
- Changing from inline SQL in the migrations to a separate .sql files.
- Fix SQL formatting in the migrations.
- Skip migrations applying if you know they are applied.

### Describe the solution you'd like

A solution could be a bool parameter for `load()` method:
```ts
import Database from '@tauri-apps/plugin-sql';
const db = await Database.load('sqlite:mydatabase.db', false);
```
parameter name: `applyMigrations`
default value: `true`

### Alternatives considered

Also can be added to the plugin builder:
```rs
.plugin(
tauri_plugin_sql::Builder::new()
.add_migrations(
config
.get_string("database.connection-string")
.expect("'database.connection-string' not found in config")
.as_str(),
migrations::migrations(),
)
.applyMigrations(false) // <-- new feature
.build(),
)
```

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the client-side `load()` API and the Rust plugin builder path using `add_migrations()` described in the issue. Trace where migrations are currently forced, then determine how the default behavior and an opt-out configuration should work; done means callers can skip migration application while existing callers still apply migrations by default.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sqlite, tauri, typescript
Domain
api, database
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.