@redocly/replay 0.20.1 → 0.21.0-custom.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -0
- package/dist/replay-index-BnyCUxkf.js +94 -0
- package/dist/{replay-index-CgcOYHQ9.js → replay-index-By22gr5t.js} +1 -1
- package/dist/{replay-index-CNA8w-F_.js → replay-index-DJkzB5e_.js} +9217 -4902
- package/dist/{replay-index-BG7maSLC.js → replay-index-DSsG8WsX.js} +1 -1
- package/dist/replay-index-OsYOLFjW.js +139606 -0
- package/dist/{replay-index-BwN-9Tk1.js → replay-index-QUwfb7et.js} +1 -1
- package/dist/replay-index-QrPMcrlH.js +7 -0
- package/dist/replay-index-qNrVQE9x.js +6301 -0
- package/dist/{replay-tauri-path-mPN7LCO-.js → replay-tauri-path-DoTdEpCx.js} +1 -1
- package/dist/{replay-tauri-path-DuSGakRX.js → replay-tauri-path-Hx9UNQhu.js} +2 -2
- package/dist/replay.cjs +1 -1
- package/dist/replay.d.ts +13 -0
- package/dist/replay.js +3 -3
- package/package.json +13 -11
- package/dist/replay-index-CYbvYpkU.js +0 -108149
- package/dist/replay-index-Czio0neV.js +0 -7
- package/dist/replay-index-DZKeaJ8u.js +0 -87
- package/dist/replay-index-UU9ttWIq.js +0 -5667
package/README.md
CHANGED
|
@@ -1 +1,68 @@
|
|
|
1
1
|
# Replay
|
|
2
|
+
|
|
3
|
+
## Database Migrations
|
|
4
|
+
|
|
5
|
+
The Replay app uses different database backends depending on the platform:
|
|
6
|
+
- **Tauri (desktop)**: SQLite with Drizzle ORM
|
|
7
|
+
- **Web**: IndexedDB with the `idb` library
|
|
8
|
+
|
|
9
|
+
### SQLite Migrations (Tauri)
|
|
10
|
+
|
|
11
|
+
SQLite schema is defined in `src/db/schema/` using Drizzle ORM. Migrations are auto-generated.
|
|
12
|
+
|
|
13
|
+
**To add a migration:**
|
|
14
|
+
|
|
15
|
+
1. Update the schema in `src/db/schema/` (e.g., `history.schema.ts`)
|
|
16
|
+
2. Generate the migration from the `apps/replay-app` directory:
|
|
17
|
+
```bash
|
|
18
|
+
pnpm db:generate
|
|
19
|
+
```
|
|
20
|
+
3. This creates a new `.sql` file in `apps/replay-app/src-tauri/migrations/` with a unique name
|
|
21
|
+
4. Migrations run automatically on app startup via the Rust backend
|
|
22
|
+
5. Alternatively, manually create a new migration file in `apps/replay-app/src-tauri/migrations/`:
|
|
23
|
+
```bash
|
|
24
|
+
# Format: YYYYMMDDHHMMSS_description.sql
|
|
25
|
+
src-tauri/migrations/20241224120000_add_user_settings.sql
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```sql
|
|
29
|
+
-- Add new table
|
|
30
|
+
CREATE TABLE IF NOT EXISTS user_settings (
|
|
31
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
32
|
+
key TEXT NOT NULL UNIQUE,
|
|
33
|
+
value TEXT NOT NULL
|
|
34
|
+
);
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### IndexedDB Migrations (Web)
|
|
38
|
+
|
|
39
|
+
IndexedDB uses version-based migrations.
|
|
40
|
+
|
|
41
|
+
**To add a migration:**
|
|
42
|
+
|
|
43
|
+
1. Increment the version constant in the storage class (e.g., `HISTORY_DB_VERSION` in `HistoryIndexedDBStorage.ts`)
|
|
44
|
+
2. Update the `setupDatabase()` method to handle both initial creation and upgrades:
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
const HISTORY_DB_VERSION = 2; // Increment for new migration
|
|
48
|
+
|
|
49
|
+
private static setupDatabase(db: IDBPDatabase<unknown>): void {
|
|
50
|
+
// Initial setup (runs for new databases)
|
|
51
|
+
if (!db.objectStoreNames.contains('history')) {
|
|
52
|
+
const store = db.createObjectStore('history', { keyPath: 'id' });
|
|
53
|
+
store.createIndex('by-date', 'date');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Version 2: Add new index (runs on upgrade from v1)
|
|
57
|
+
const tx = db.transaction('history', 'readwrite');
|
|
58
|
+
const store = tx.objectStore('history');
|
|
59
|
+
if (!store.indexNames.contains('by-new-field')) {
|
|
60
|
+
store.createIndex('by-new-field', 'newField');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Best practices:**
|
|
66
|
+
- Always check if stores/indexes exist before creating
|
|
67
|
+
- Keep schema definitions in sync between SQLite and IndexedDB
|
|
68
|
+
- Test migrations with existing data before release
|