duckpack 0.2.3__tar.gz → 0.3.0__tar.gz
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.
- {duckpack-0.2.3 → duckpack-0.3.0}/.github/workflows/release.yml +10 -2
- {duckpack-0.2.3 → duckpack-0.3.0}/Cargo.lock +1 -1
- {duckpack-0.2.3 → duckpack-0.3.0}/Cargo.toml +1 -1
- duckpack-0.2.3/README.md → duckpack-0.3.0/PKG-INFO +44 -16
- duckpack-0.2.3/PKG-INFO → duckpack-0.3.0/README.md +23 -37
- {duckpack-0.2.3 → duckpack-0.3.0}/pyproject.toml +1 -1
- {duckpack-0.2.3 → duckpack-0.3.0}/src/catalog.rs +132 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/src/diff.rs +17 -2
- {duckpack-0.2.3 → duckpack-0.3.0}/src/engine.rs +201 -2
- {duckpack-0.2.3 → duckpack-0.3.0}/src/ide/explorer.rs +119 -2
- {duckpack-0.2.3 → duckpack-0.3.0}/src/ide/mod.rs +169 -2060
- duckpack-0.2.3/src/ide/modals.rs → duckpack-0.3.0/src/ide/modals/attach.rs +5 -2144
- duckpack-0.3.0/src/ide/modals/dialogs.rs +508 -0
- duckpack-0.3.0/src/ide/modals/input.rs +96 -0
- duckpack-0.3.0/src/ide/modals/mod.rs +25 -0
- duckpack-0.3.0/src/ide/modals/project_modals.rs +680 -0
- duckpack-0.3.0/src/ide/modals/secrets.rs +930 -0
- duckpack-0.3.0/src/ide/modals/time_travel.rs +718 -0
- duckpack-0.3.0/src/ide/tests.rs +2219 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/src/main.rs +223 -22
- {duckpack-0.2.3 → duckpack-0.3.0}/src/python.rs +7 -1
- {duckpack-0.2.3 → duckpack-0.3.0}/tests/test_python_api.py +1 -1
- {duckpack-0.2.3 → duckpack-0.3.0}/.cargo/config.toml +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/.gitignore +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/LICENSE +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/duckpack_logo.png +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/python/duckpack/__init__.py +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/python/duckpack/__main__.py +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/python/duckpack/_duckpack.pyi +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/python/duckpack/cli.py +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/python/duckpack/notebook.py +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/python/duckpack/py.typed +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/python/duckpack/runner.py +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/python/duckpack/terminal.py +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/scripts/scaffold_demo_project.sh +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/src/ide/editor.rs +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/src/lib.rs +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/src/query.rs +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/src/syntax.rs +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/src/tui.rs +0 -0
- {duckpack-0.2.3 → duckpack-0.3.0}/tests/v2_compat_test.rs +0 -0
|
@@ -4,6 +4,8 @@ on:
|
|
|
4
4
|
push:
|
|
5
5
|
tags:
|
|
6
6
|
- "v*.*.*"
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
7
9
|
workflow_dispatch:
|
|
8
10
|
|
|
9
11
|
jobs:
|
|
@@ -87,10 +89,15 @@ jobs:
|
|
|
87
89
|
fail-fast: false
|
|
88
90
|
matrix:
|
|
89
91
|
include:
|
|
90
|
-
- os: ubuntu-
|
|
92
|
+
- os: ubuntu-22.04
|
|
91
93
|
target: x86_64-unknown-linux-gnu
|
|
94
|
+
manylinux: "2_28"
|
|
92
95
|
- os: ubuntu-24.04-arm
|
|
93
96
|
target: aarch64-unknown-linux-gnu
|
|
97
|
+
manylinux: "2_28"
|
|
98
|
+
- os: ubuntu-22.04
|
|
99
|
+
target: x86_64-unknown-linux-musl
|
|
100
|
+
manylinux: "musllinux_1_2"
|
|
94
101
|
- os: macos-latest
|
|
95
102
|
target: aarch64-apple-darwin
|
|
96
103
|
deployment_target: "10.15"
|
|
@@ -107,7 +114,8 @@ jobs:
|
|
|
107
114
|
uses: PyO3/maturin-action@v1
|
|
108
115
|
with:
|
|
109
116
|
target: ${{ matrix.target }}
|
|
110
|
-
|
|
117
|
+
manylinux: ${{ matrix.manylinux || 'auto' }}
|
|
118
|
+
args: --release --out dist --strip
|
|
111
119
|
env:
|
|
112
120
|
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deployment_target || '' }}
|
|
113
121
|
|
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: duckpack
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: Programming Language :: Python :: 3
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
12
|
+
Classifier: Topic :: Database
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Summary: Declarative schema management, interactive terminal IDE, and in-memory inspection for DuckDB
|
|
15
|
+
Keywords: duckdb,schema,migrations,tui,ide,database,sql
|
|
16
|
+
Author-email: Benjamen Terry <benjamenjterry@gmail.com>
|
|
17
|
+
License: MIT
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
20
|
+
|
|
1
21
|
<p align="center">
|
|
2
22
|
<img src="https://raw.githubusercontent.com/Benjas86/duckpack/main/duckpack_logo.png" width="400" alt="DuckPack Logo" />
|
|
3
23
|
</p>
|
|
@@ -73,7 +93,7 @@ DuckPack includes a **rich terminal IDE** for live database exploration and firs
|
|
|
73
93
|
- **First-Class Sequences & Dependency-Safe Compilation:** Native support for DuckDB `sequences/` compiled in topological order (`schemas` $\rightarrow$ `types` $\rightarrow$ `sequences` $\rightarrow$ `macros` $\rightarrow$ `tables` $\rightarrow$ `views` $\rightarrow$ `triggers`), ensuring tables with surrogate keys (`DEFAULT nextval('...')`) compile and apply seamlessly.
|
|
74
94
|
- **Table Constraint Diffing & Copy-and-Swap Migrations:** Automatically introspects `PRIMARY KEY`, `UNIQUE`, `FOREIGN KEY`, and `CHECK` constraints. Generates in-place `ALTER TABLE` statements for safe additions and transactional copy-and-swap (`__duckpack_swap`) staging tables for complex constraint modifications.
|
|
75
95
|
- **Catalog-Aware Multi-Database Targeting:** Seamlessly target specific attached databases (via `--database <name>`, `duckpack.toml [target] database = "..."`, or Python `duckpack.apply(con, database="analytics")`) with strict catalog isolation.
|
|
76
|
-
- **Clear Engine Boundary (SSDT vs Federation):** Full declarative DDL lifecycle management specifically engineered for DuckDB, Quack, and MotherDuck. External attached engines (MSSQL, PostgreSQL, MySQL, SQLite) are first-class citizens in Explore for ad-hoc querying, cross-DB joins, and DML (`INSERT INTO`, `UPDATE`), with schema DDL safely managed by external native tools.
|
|
96
|
+
- **Clear Engine Boundary (SSDT vs Federation):** Full declarative DDL lifecycle management specifically engineered for DuckDB, DuckLake, Quack, and MotherDuck (with a physical copy-and-swap Parquet rewrite guard `--allow-lake-rewrite` and automatic `set_commit_message` snapshot tagging for DuckLake). External attached engines (MSSQL, PostgreSQL, MySQL, SQLite) are first-class citizens in Explore for ad-hoc querying, cross-DB joins, and DML (`INSERT INTO`, `UPDATE`), with schema DDL safely managed by external native tools.
|
|
77
97
|
- **Interactive Apply Parity (CLI & Notebook):** Review visual colored diffs and apply migrations interactively with live confirmation prompts in terminal, Python scripts, or Jupyter notebooks (with automated external terminal pop-out).
|
|
78
98
|
- **Schema Drift Detection (`duckpack diff`):** Instant dry-run inspection to detect divergence between your declarative codebase and live databases without mutating state.
|
|
79
99
|
- **Git-Style Smart Renames:** Uses Jaro-Winkler similarity matching (>80%) to detect renamed tables or columns, issuing non-destructive `ALTER TABLE RENAME` statements instead of dropping and recreating data.
|
|
@@ -82,7 +102,7 @@ DuckPack includes a **rich terminal IDE** for live database exploration and firs
|
|
|
82
102
|
- **Visual Primary Key & Foreign Key Indicators:** Inspect table structures in the Explorer tree with visual icons (`🔑` for Primary Keys, `🔗` for Foreign Keys with reference targets `[FK -> table.col]`, and composite `🔑🔗` badges).
|
|
83
103
|
- **Dynamic Explorer Width Resizing & Snappy Scrolling:** Adjust sidebar width on the fly via `W` (cycling 25%/35%/50% presets) or `+`/`-` and `[`/`]` (5% increments from 15% to 60%). Navigate wide schemas quickly with 4-char arrow scrolling, `Shift+Arrow` 10-char jumps, and `Home` margin snap.
|
|
84
104
|
- **Catalog-Aware Multi-Database Exploration:** Inspect multiple attached catalogs (local DuckDB, in-memory `memory` scratchpad, DuckLake lakehouses `🌊`, attached SQLite/Postgres/MySQL/MSSQL `🔌`, and remote Quack `target_db` instances) in a unified hierarchical tree with catalog-qualified query generation, cross-database joins, and live external catalog cache invalidation (`r`).
|
|
85
|
-
- **Live Catalog Attach with Provider Presets & DuckLake Triad (`Ctrl+A` / `d` / `b`):** Dynamically attach DuckLake lakehouses (with `DuckDB File`, `PostgreSQL`, `SQLite`, or `Quack` metadata backends + `DATA_PATH` + S3 secret auto-binding), third-party databases (including MSSQL Windows Auth / `Trusted_Connection`), DuckDB files, MotherDuck, or remote Quack instances directly inside the IDE with full cursor-navigable modal inputs
|
|
105
|
+
- **Live Catalog Attach with Provider Presets & DuckLake Triad (`Ctrl+A` / `d` / `b` / `t`):** Dynamically attach DuckLake lakehouses (with `DuckDB File`, `PostgreSQL`, `SQLite`, or `Quack` metadata backends + `DATA_PATH` + S3 secret auto-binding), inspect versioned commits under `📸 Snapshots (N)`, and launch the interactive **Time-Travel & Snapshot Diff Modal (`t`)** (`AT (VERSION => N)`, `AT (TIMESTAMP => '...')`, `ducklake_table_changes(...)`); also attach third-party databases (including MSSQL Windows Auth / `Trusted_Connection`), DuckDB files, MotherDuck, or remote Quack instances directly inside the IDE with full cursor-navigable modal inputs.
|
|
86
106
|
- **Cloud Secrets Management & S3 Bucket Explorer (`Ctrl+K`):** Visually configure cloud storage credentials (AWS S3, Cloudflare R2, MinIO, Wasabi, Custom S3) with masked inputs (`*`) and dual-persistence (`CREATE PERSISTENT SECRET` + `.env`). Live-explore remote S3 buckets (`glob()`) and sample remote files (`read_parquet`, `read_csv`) with a single keypress.
|
|
87
107
|
- **Temporary Table Discovery & Python Two-Way Sync:** Temporary tables and views (`CREATE TEMP TABLE ...`) appear seamlessly in the active database's Explorer tree with a distinct `[temp]` badge. Instant DDL auto-refresh updates the sidebar on `CREATE`/`DROP`/`ALTER`, and interactive Python exploration (`duckpack.explore(con)`) performs safe two-way session synchronization across the Quack bridge.
|
|
88
108
|
- **Python Integration with Jupyter / VS Code Support:** Import `duckpack` into Python pipelines, pytest fixtures, or Jupyter notebooks (`duckpack.explore(con)`). Automatically spawns a connected native terminal window in non-interactive notebook environments.
|
|
@@ -172,12 +192,12 @@ cargo install duckpack
|
|
|
172
192
|
| `duckpack init` | Scaffold a new declarative database project | `-p, --project-dir <DIR>` | `.` |
|
|
173
193
|
| `duckpack build` | Validate SQL syntax against an in-memory Shadow DB | `-p, --project-dir <DIR>` | `.` |
|
|
174
194
|
| `duckpack diff` | Compare declarative project state against target database without applying changes | `-p, --project-dir <DIR>`<br>`-d, --db <URI>`<br>`--database, --catalog <NAME>`<br>`--quack-token <TOKEN>`<br>`--insecure` | `.`<br>`local.duckdb`<br>`None`<br>`None`<br>`false` |
|
|
175
|
-
| `duckpack apply` | Compute diff and apply migrations to target database | `-p, --project-dir <DIR>`<br>`-d, --db <URI>`<br>`--database, --catalog <NAME>`<br>`--auto-approve`<br>`--interactive`<br>`--force-drop`<br>`--out <FILE>`<br>`--quack-token <TOKEN>`<br>`--insecure` | `.`<br>`local.duckdb`<br>`None`<br>`false`<br>`false`<br>`false`<br>`None`<br>`None`<br>`false` |
|
|
195
|
+
| `duckpack apply` | Compute diff and apply migrations to target database | `-p, --project-dir <DIR>`<br>`-d, --db <URI>`<br>`--database, --catalog <NAME>`<br>`--auto-approve`<br>`--interactive`<br>`--force-drop`<br>`--allow-lake-rewrite`<br>`--out <FILE>`<br>`--quack-token <TOKEN>`<br>`--insecure` | `.`<br>`local.duckdb`<br>`None`<br>`false`<br>`false`<br>`false`<br>`false`<br>`None`<br>`None`<br>`false` |
|
|
176
196
|
| `duckpack explore` | Open the interactive terminal IDE / query editor | `-p, --project-dir <DIR>`<br>`-d, --db <URI>`<br>`--database, --catalog <NAME>`<br>`--remote <SSH_TARGET>`<br>`-P, --port <PORT>`<br>`--auto-install`<br>`--quack-token <TOKEN>`<br>`--insecure` | `.`<br>`local.duckdb`<br>`None`<br>`None`<br>`22`<br>`false`<br>`None`<br>`false` |
|
|
177
197
|
| `duckpack compile` | Package project into an immutable `.duckpack` snapshot | `-p, --project-dir <DIR>`<br>`-o, --out <FILE>` | `.`<br>*(Required)* |
|
|
178
198
|
| `duckpack deploy` | Deploy compiled project to a remote server over SSH | `-p, --project-dir <DIR>`<br>`-r, --remote <HOST>`<br>`-d, --db <URI>`<br>`-P, --port <PORT>`<br>`--auto-install` | `.`<br>*(Required)*<br>`local.duckdb`<br>`22`<br>`false` |
|
|
179
|
-
| `duckpack python status` | Check
|
|
180
|
-
| `duckpack python install` | Install/upgrade `duckpack` Python package
|
|
199
|
+
| `duckpack python status` | Check active Python environment (`$VIRTUAL_ENV`, `./.venv`, or `python3`), detected installer (`uv` / `pip`), and installed versions | — | — |
|
|
200
|
+
| `duckpack python install` | Install/upgrade `duckpack` Python package in active environment (auto-detects `uv` or `pip`) | `-U, --upgrade`<br>`--installer, --method <auto\|uv\|pip>`<br>`--uv`<br>`--pip` | `false`<br>`auto`<br>`false`<br>`false` |
|
|
181
201
|
|
|
182
202
|
---
|
|
183
203
|
|
|
@@ -287,13 +307,13 @@ DuckPack embeds DuckDB directly as an in-process engine:
|
|
|
287
307
|
- **Engine Transparency:** Check the exact embedded DuckDB engine version anytime via:
|
|
288
308
|
```bash
|
|
289
309
|
duckpack --version
|
|
290
|
-
# DuckPack v0.
|
|
310
|
+
# DuckPack v0.3.0 (embedded DuckDB v2.0.0)
|
|
291
311
|
```
|
|
292
312
|
Or in Python:
|
|
293
313
|
```python
|
|
294
314
|
import duckpack
|
|
295
315
|
|
|
296
|
-
print(duckpack.__version__) # e.g. "0.
|
|
316
|
+
print(duckpack.__version__) # e.g. "0.3.0"
|
|
297
317
|
print(duckpack.__duckdb_version__) # e.g. "2.0.0"
|
|
298
318
|
```
|
|
299
319
|
- **Proactive Storage Diagnostics:** If an older database file with an incompatible legacy storage format is encountered, DuckPack catches the internal engine error and prints clear migration guidance rather than an unhelpful internal crash dump.
|
|
@@ -372,14 +392,16 @@ Or transition instantly from `duckpack apply` by pressing **`e`**.
|
|
|
372
392
|
| | `Left` / `Right` / `h` / `l` | **Scroll horizontally** by 4 characters |
|
|
373
393
|
| | `Shift + Left` / `Right` | **Fast horizontal scroll** by 10 characters |
|
|
374
394
|
| | `Home` | **Snap horizontal scroll** back to left margin |
|
|
375
|
-
| | `q` / `s` | **Query table/view** (generates catalog-qualified SQL into editor) |
|
|
376
|
-
| | `
|
|
395
|
+
| | `q` / `s` | **Query table/view/snapshot** (generates catalog-qualified SQL or `ducklake_snapshots()` into editor) |
|
|
396
|
+
| | `t` | **DuckLake Time-Travel & Snapshot Diff Modal:** Interactive picker for `AT (VERSION => N)`, `AT (TIMESTAMP => '...')`, and `ducklake_table_changes(...)` |
|
|
397
|
+
| | `Ctrl+A` | **Attach Database** dialog with Provider Presets (DuckDB, DuckLake, SQLite, Postgres, MySQL, MSSQL, MotherDuck, Quack) |
|
|
377
398
|
| | `Ctrl+K` | **Cloud Secrets & S3 Buckets:** Add S3/R2/MinIO credentials with masking, `.env` persistence, and bucket exploration |
|
|
378
399
|
| | `d` | **Detach Database** from current session |
|
|
379
400
|
| | `b` | **Cycle Target Catalog** for diff/apply operations |
|
|
380
401
|
| | `r` / `R` | **Refresh Explorer:** re-scans live database (in DB mode) or disk & git status (in Project mode) |
|
|
381
402
|
| **In-IDE Diff & Apply** | `Space` | **Toggle selection** `[x]` / `[ ]` of highlighted migration with dependency locking `[L]` |
|
|
382
403
|
| | `a` | **Toggle All:** select or deselect all eligible migrations |
|
|
404
|
+
| | `w` | **Toggle Allow Lake Rewrite (`[OFF/ON]`):** permit physical copy-and-swap table rewrites on DuckLake catalogs |
|
|
383
405
|
| | `Enter` | **Apply selected changes** directly to target database catalog |
|
|
384
406
|
| | `Esc` | **Close** diff review dialog without applying changes |
|
|
385
407
|
| **Apply Review Screen** | `y` | **Confirm and apply** all pending declarative migrations |
|
|
@@ -677,7 +699,7 @@ import duckpack
|
|
|
677
699
|
```
|
|
678
700
|
|
|
679
701
|
#### Engine Version Properties
|
|
680
|
-
- **`duckpack.__version__: str`**: The version of DuckPack (e.g. `"0.
|
|
702
|
+
- **`duckpack.__version__: str`**: The version of DuckPack (e.g. `"0.3.0"`).
|
|
681
703
|
- **`duckpack.__duckdb_version__: str`**: The embedded DuckDB engine version (e.g. `"2.0.0"`).
|
|
682
704
|
|
|
683
705
|
#### Functions
|
|
@@ -688,8 +710,8 @@ import duckpack
|
|
|
688
710
|
- **`duckpack.stop_server() -> bool`**
|
|
689
711
|
Stops any active background Quack session bridge started by `duckpack.explore(con)` in a notebook.
|
|
690
712
|
|
|
691
|
-
- **`duckpack.apply(target=None, project_dir=".", auto_approve=True, force_drop=False, interactive=False, database=None, catalog=None, env=None) -> ApplyResult`**
|
|
692
|
-
Computes schema diffs and applies declarative migrations. In interactive mode (`auto_approve=False` or `interactive=True`), opens the visual review TUI. When `target=None`, auto-resolves database targets from `duckpack.toml`. Returns an `ApplyResult`.
|
|
713
|
+
- **`duckpack.apply(target=None, project_dir=".", auto_approve=True, force_drop=False, allow_lake_rewrite=False, interactive=False, database=None, catalog=None, env=None) -> ApplyResult`**
|
|
714
|
+
Computes schema diffs and applies declarative migrations. In interactive mode (`auto_approve=False` or `interactive=True`), opens the visual review TUI. When targeting a DuckLake catalog, physical copy-and-swap table rewrites (`RecreateTable`) are blocked unless `allow_lake_rewrite=True` is passed, and applied migrations automatically tag the DuckLake snapshot via `set_commit_message`. When `target=None`, auto-resolves database targets from `duckpack.toml`. Returns an `ApplyResult`.
|
|
693
715
|
|
|
694
716
|
- **`duckpack.diff(target=None, project_dir=".", database=None, catalog=None, env=None) -> DiffSummary`**
|
|
695
717
|
Compares declarative project state against target database or attached catalog without mutating data. When `target=None`, auto-resolves from `duckpack.toml`. Returns a `DiffSummary`.
|
|
@@ -713,14 +735,19 @@ import duckpack
|
|
|
713
735
|
|
|
714
736
|
### CLI Python Management
|
|
715
737
|
|
|
716
|
-
Check and install the Python bindings directly from the standalone DuckPack CLI
|
|
738
|
+
Check and install the Python bindings directly from the standalone DuckPack CLI. `duckpack python` automatically detects `$VIRTUAL_ENV`, `./.venv`, and whether your environment is managed by **`uv`** (`uv.lock` / `pyvenv.cfg` / missing `pip`) or **`pip`**:
|
|
717
739
|
|
|
718
740
|
```bash
|
|
719
|
-
# Verify Python
|
|
741
|
+
# Verify Python interpreter, detected installer (uv or pip), and installed package versions
|
|
720
742
|
duckpack python status
|
|
721
743
|
|
|
722
|
-
# Install or upgrade duckpack in active environment
|
|
744
|
+
# Install or upgrade duckpack in the active environment (auto-detects uv vs pip)
|
|
723
745
|
duckpack python install --upgrade
|
|
746
|
+
|
|
747
|
+
# Or explicitly select uv or pip:
|
|
748
|
+
duckpack python install --uv -U
|
|
749
|
+
duckpack python install --pip -U
|
|
750
|
+
duckpack python install --installer uv
|
|
724
751
|
```
|
|
725
752
|
|
|
726
753
|
---
|
|
@@ -856,7 +883,7 @@ Define connection targets, remote Quack instances, and environment profiles with
|
|
|
856
883
|
```toml
|
|
857
884
|
[project]
|
|
858
885
|
name = "analytics_warehouse"
|
|
859
|
-
version = "0.
|
|
886
|
+
version = "0.3.0"
|
|
860
887
|
|
|
861
888
|
[target]
|
|
862
889
|
default_db = "dev.duckdb"
|
|
@@ -987,3 +1014,4 @@ I know this may contain 'sub-optimal' or 'vibe code' solutions and code that cou
|
|
|
987
1014
|
|
|
988
1015
|
Thanks,
|
|
989
1016
|
**Ben**
|
|
1017
|
+
|
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: duckpack
|
|
3
|
-
Version: 0.2.3
|
|
4
|
-
Classifier: Programming Language :: Rust
|
|
5
|
-
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
-
Classifier: Programming Language :: Python :: 3
|
|
7
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
8
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
9
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
12
|
-
Classifier: Topic :: Database
|
|
13
|
-
License-File: LICENSE
|
|
14
|
-
Summary: Declarative schema management, interactive terminal IDE, and in-memory inspection for DuckDB
|
|
15
|
-
Keywords: duckdb,schema,migrations,tui,ide,database,sql
|
|
16
|
-
Author-email: Benjamen Terry <benjamenjterry@gmail.com>
|
|
17
|
-
License: MIT
|
|
18
|
-
Requires-Python: >=3.10
|
|
19
|
-
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
20
|
-
|
|
21
1
|
<p align="center">
|
|
22
2
|
<img src="https://raw.githubusercontent.com/Benjas86/duckpack/main/duckpack_logo.png" width="400" alt="DuckPack Logo" />
|
|
23
3
|
</p>
|
|
@@ -93,7 +73,7 @@ DuckPack includes a **rich terminal IDE** for live database exploration and firs
|
|
|
93
73
|
- **First-Class Sequences & Dependency-Safe Compilation:** Native support for DuckDB `sequences/` compiled in topological order (`schemas` $\rightarrow$ `types` $\rightarrow$ `sequences` $\rightarrow$ `macros` $\rightarrow$ `tables` $\rightarrow$ `views` $\rightarrow$ `triggers`), ensuring tables with surrogate keys (`DEFAULT nextval('...')`) compile and apply seamlessly.
|
|
94
74
|
- **Table Constraint Diffing & Copy-and-Swap Migrations:** Automatically introspects `PRIMARY KEY`, `UNIQUE`, `FOREIGN KEY`, and `CHECK` constraints. Generates in-place `ALTER TABLE` statements for safe additions and transactional copy-and-swap (`__duckpack_swap`) staging tables for complex constraint modifications.
|
|
95
75
|
- **Catalog-Aware Multi-Database Targeting:** Seamlessly target specific attached databases (via `--database <name>`, `duckpack.toml [target] database = "..."`, or Python `duckpack.apply(con, database="analytics")`) with strict catalog isolation.
|
|
96
|
-
- **Clear Engine Boundary (SSDT vs Federation):** Full declarative DDL lifecycle management specifically engineered for DuckDB, Quack, and MotherDuck. External attached engines (MSSQL, PostgreSQL, MySQL, SQLite) are first-class citizens in Explore for ad-hoc querying, cross-DB joins, and DML (`INSERT INTO`, `UPDATE`), with schema DDL safely managed by external native tools.
|
|
76
|
+
- **Clear Engine Boundary (SSDT vs Federation):** Full declarative DDL lifecycle management specifically engineered for DuckDB, DuckLake, Quack, and MotherDuck (with a physical copy-and-swap Parquet rewrite guard `--allow-lake-rewrite` and automatic `set_commit_message` snapshot tagging for DuckLake). External attached engines (MSSQL, PostgreSQL, MySQL, SQLite) are first-class citizens in Explore for ad-hoc querying, cross-DB joins, and DML (`INSERT INTO`, `UPDATE`), with schema DDL safely managed by external native tools.
|
|
97
77
|
- **Interactive Apply Parity (CLI & Notebook):** Review visual colored diffs and apply migrations interactively with live confirmation prompts in terminal, Python scripts, or Jupyter notebooks (with automated external terminal pop-out).
|
|
98
78
|
- **Schema Drift Detection (`duckpack diff`):** Instant dry-run inspection to detect divergence between your declarative codebase and live databases without mutating state.
|
|
99
79
|
- **Git-Style Smart Renames:** Uses Jaro-Winkler similarity matching (>80%) to detect renamed tables or columns, issuing non-destructive `ALTER TABLE RENAME` statements instead of dropping and recreating data.
|
|
@@ -102,7 +82,7 @@ DuckPack includes a **rich terminal IDE** for live database exploration and firs
|
|
|
102
82
|
- **Visual Primary Key & Foreign Key Indicators:** Inspect table structures in the Explorer tree with visual icons (`🔑` for Primary Keys, `🔗` for Foreign Keys with reference targets `[FK -> table.col]`, and composite `🔑🔗` badges).
|
|
103
83
|
- **Dynamic Explorer Width Resizing & Snappy Scrolling:** Adjust sidebar width on the fly via `W` (cycling 25%/35%/50% presets) or `+`/`-` and `[`/`]` (5% increments from 15% to 60%). Navigate wide schemas quickly with 4-char arrow scrolling, `Shift+Arrow` 10-char jumps, and `Home` margin snap.
|
|
104
84
|
- **Catalog-Aware Multi-Database Exploration:** Inspect multiple attached catalogs (local DuckDB, in-memory `memory` scratchpad, DuckLake lakehouses `🌊`, attached SQLite/Postgres/MySQL/MSSQL `🔌`, and remote Quack `target_db` instances) in a unified hierarchical tree with catalog-qualified query generation, cross-database joins, and live external catalog cache invalidation (`r`).
|
|
105
|
-
- **Live Catalog Attach with Provider Presets & DuckLake Triad (`Ctrl+A` / `d` / `b`):** Dynamically attach DuckLake lakehouses (with `DuckDB File`, `PostgreSQL`, `SQLite`, or `Quack` metadata backends + `DATA_PATH` + S3 secret auto-binding), third-party databases (including MSSQL Windows Auth / `Trusted_Connection`), DuckDB files, MotherDuck, or remote Quack instances directly inside the IDE with full cursor-navigable modal inputs
|
|
85
|
+
- **Live Catalog Attach with Provider Presets & DuckLake Triad (`Ctrl+A` / `d` / `b` / `t`):** Dynamically attach DuckLake lakehouses (with `DuckDB File`, `PostgreSQL`, `SQLite`, or `Quack` metadata backends + `DATA_PATH` + S3 secret auto-binding), inspect versioned commits under `📸 Snapshots (N)`, and launch the interactive **Time-Travel & Snapshot Diff Modal (`t`)** (`AT (VERSION => N)`, `AT (TIMESTAMP => '...')`, `ducklake_table_changes(...)`); also attach third-party databases (including MSSQL Windows Auth / `Trusted_Connection`), DuckDB files, MotherDuck, or remote Quack instances directly inside the IDE with full cursor-navigable modal inputs.
|
|
106
86
|
- **Cloud Secrets Management & S3 Bucket Explorer (`Ctrl+K`):** Visually configure cloud storage credentials (AWS S3, Cloudflare R2, MinIO, Wasabi, Custom S3) with masked inputs (`*`) and dual-persistence (`CREATE PERSISTENT SECRET` + `.env`). Live-explore remote S3 buckets (`glob()`) and sample remote files (`read_parquet`, `read_csv`) with a single keypress.
|
|
107
87
|
- **Temporary Table Discovery & Python Two-Way Sync:** Temporary tables and views (`CREATE TEMP TABLE ...`) appear seamlessly in the active database's Explorer tree with a distinct `[temp]` badge. Instant DDL auto-refresh updates the sidebar on `CREATE`/`DROP`/`ALTER`, and interactive Python exploration (`duckpack.explore(con)`) performs safe two-way session synchronization across the Quack bridge.
|
|
108
88
|
- **Python Integration with Jupyter / VS Code Support:** Import `duckpack` into Python pipelines, pytest fixtures, or Jupyter notebooks (`duckpack.explore(con)`). Automatically spawns a connected native terminal window in non-interactive notebook environments.
|
|
@@ -192,12 +172,12 @@ cargo install duckpack
|
|
|
192
172
|
| `duckpack init` | Scaffold a new declarative database project | `-p, --project-dir <DIR>` | `.` |
|
|
193
173
|
| `duckpack build` | Validate SQL syntax against an in-memory Shadow DB | `-p, --project-dir <DIR>` | `.` |
|
|
194
174
|
| `duckpack diff` | Compare declarative project state against target database without applying changes | `-p, --project-dir <DIR>`<br>`-d, --db <URI>`<br>`--database, --catalog <NAME>`<br>`--quack-token <TOKEN>`<br>`--insecure` | `.`<br>`local.duckdb`<br>`None`<br>`None`<br>`false` |
|
|
195
|
-
| `duckpack apply` | Compute diff and apply migrations to target database | `-p, --project-dir <DIR>`<br>`-d, --db <URI>`<br>`--database, --catalog <NAME>`<br>`--auto-approve`<br>`--interactive`<br>`--force-drop`<br>`--out <FILE>`<br>`--quack-token <TOKEN>`<br>`--insecure` | `.`<br>`local.duckdb`<br>`None`<br>`false`<br>`false`<br>`false`<br>`None`<br>`None`<br>`false` |
|
|
175
|
+
| `duckpack apply` | Compute diff and apply migrations to target database | `-p, --project-dir <DIR>`<br>`-d, --db <URI>`<br>`--database, --catalog <NAME>`<br>`--auto-approve`<br>`--interactive`<br>`--force-drop`<br>`--allow-lake-rewrite`<br>`--out <FILE>`<br>`--quack-token <TOKEN>`<br>`--insecure` | `.`<br>`local.duckdb`<br>`None`<br>`false`<br>`false`<br>`false`<br>`false`<br>`None`<br>`None`<br>`false` |
|
|
196
176
|
| `duckpack explore` | Open the interactive terminal IDE / query editor | `-p, --project-dir <DIR>`<br>`-d, --db <URI>`<br>`--database, --catalog <NAME>`<br>`--remote <SSH_TARGET>`<br>`-P, --port <PORT>`<br>`--auto-install`<br>`--quack-token <TOKEN>`<br>`--insecure` | `.`<br>`local.duckdb`<br>`None`<br>`None`<br>`22`<br>`false`<br>`None`<br>`false` |
|
|
197
177
|
| `duckpack compile` | Package project into an immutable `.duckpack` snapshot | `-p, --project-dir <DIR>`<br>`-o, --out <FILE>` | `.`<br>*(Required)* |
|
|
198
178
|
| `duckpack deploy` | Deploy compiled project to a remote server over SSH | `-p, --project-dir <DIR>`<br>`-r, --remote <HOST>`<br>`-d, --db <URI>`<br>`-P, --port <PORT>`<br>`--auto-install` | `.`<br>*(Required)*<br>`local.duckdb`<br>`22`<br>`false` |
|
|
199
|
-
| `duckpack python status` | Check
|
|
200
|
-
| `duckpack python install` | Install/upgrade `duckpack` Python package
|
|
179
|
+
| `duckpack python status` | Check active Python environment (`$VIRTUAL_ENV`, `./.venv`, or `python3`), detected installer (`uv` / `pip`), and installed versions | — | — |
|
|
180
|
+
| `duckpack python install` | Install/upgrade `duckpack` Python package in active environment (auto-detects `uv` or `pip`) | `-U, --upgrade`<br>`--installer, --method <auto\|uv\|pip>`<br>`--uv`<br>`--pip` | `false`<br>`auto`<br>`false`<br>`false` |
|
|
201
181
|
|
|
202
182
|
---
|
|
203
183
|
|
|
@@ -307,13 +287,13 @@ DuckPack embeds DuckDB directly as an in-process engine:
|
|
|
307
287
|
- **Engine Transparency:** Check the exact embedded DuckDB engine version anytime via:
|
|
308
288
|
```bash
|
|
309
289
|
duckpack --version
|
|
310
|
-
# DuckPack v0.
|
|
290
|
+
# DuckPack v0.3.0 (embedded DuckDB v2.0.0)
|
|
311
291
|
```
|
|
312
292
|
Or in Python:
|
|
313
293
|
```python
|
|
314
294
|
import duckpack
|
|
315
295
|
|
|
316
|
-
print(duckpack.__version__) # e.g. "0.
|
|
296
|
+
print(duckpack.__version__) # e.g. "0.3.0"
|
|
317
297
|
print(duckpack.__duckdb_version__) # e.g. "2.0.0"
|
|
318
298
|
```
|
|
319
299
|
- **Proactive Storage Diagnostics:** If an older database file with an incompatible legacy storage format is encountered, DuckPack catches the internal engine error and prints clear migration guidance rather than an unhelpful internal crash dump.
|
|
@@ -392,14 +372,16 @@ Or transition instantly from `duckpack apply` by pressing **`e`**.
|
|
|
392
372
|
| | `Left` / `Right` / `h` / `l` | **Scroll horizontally** by 4 characters |
|
|
393
373
|
| | `Shift + Left` / `Right` | **Fast horizontal scroll** by 10 characters |
|
|
394
374
|
| | `Home` | **Snap horizontal scroll** back to left margin |
|
|
395
|
-
| | `q` / `s` | **Query table/view** (generates catalog-qualified SQL into editor) |
|
|
396
|
-
| | `
|
|
375
|
+
| | `q` / `s` | **Query table/view/snapshot** (generates catalog-qualified SQL or `ducklake_snapshots()` into editor) |
|
|
376
|
+
| | `t` | **DuckLake Time-Travel & Snapshot Diff Modal:** Interactive picker for `AT (VERSION => N)`, `AT (TIMESTAMP => '...')`, and `ducklake_table_changes(...)` |
|
|
377
|
+
| | `Ctrl+A` | **Attach Database** dialog with Provider Presets (DuckDB, DuckLake, SQLite, Postgres, MySQL, MSSQL, MotherDuck, Quack) |
|
|
397
378
|
| | `Ctrl+K` | **Cloud Secrets & S3 Buckets:** Add S3/R2/MinIO credentials with masking, `.env` persistence, and bucket exploration |
|
|
398
379
|
| | `d` | **Detach Database** from current session |
|
|
399
380
|
| | `b` | **Cycle Target Catalog** for diff/apply operations |
|
|
400
381
|
| | `r` / `R` | **Refresh Explorer:** re-scans live database (in DB mode) or disk & git status (in Project mode) |
|
|
401
382
|
| **In-IDE Diff & Apply** | `Space` | **Toggle selection** `[x]` / `[ ]` of highlighted migration with dependency locking `[L]` |
|
|
402
383
|
| | `a` | **Toggle All:** select or deselect all eligible migrations |
|
|
384
|
+
| | `w` | **Toggle Allow Lake Rewrite (`[OFF/ON]`):** permit physical copy-and-swap table rewrites on DuckLake catalogs |
|
|
403
385
|
| | `Enter` | **Apply selected changes** directly to target database catalog |
|
|
404
386
|
| | `Esc` | **Close** diff review dialog without applying changes |
|
|
405
387
|
| **Apply Review Screen** | `y` | **Confirm and apply** all pending declarative migrations |
|
|
@@ -697,7 +679,7 @@ import duckpack
|
|
|
697
679
|
```
|
|
698
680
|
|
|
699
681
|
#### Engine Version Properties
|
|
700
|
-
- **`duckpack.__version__: str`**: The version of DuckPack (e.g. `"0.
|
|
682
|
+
- **`duckpack.__version__: str`**: The version of DuckPack (e.g. `"0.3.0"`).
|
|
701
683
|
- **`duckpack.__duckdb_version__: str`**: The embedded DuckDB engine version (e.g. `"2.0.0"`).
|
|
702
684
|
|
|
703
685
|
#### Functions
|
|
@@ -708,8 +690,8 @@ import duckpack
|
|
|
708
690
|
- **`duckpack.stop_server() -> bool`**
|
|
709
691
|
Stops any active background Quack session bridge started by `duckpack.explore(con)` in a notebook.
|
|
710
692
|
|
|
711
|
-
- **`duckpack.apply(target=None, project_dir=".", auto_approve=True, force_drop=False, interactive=False, database=None, catalog=None, env=None) -> ApplyResult`**
|
|
712
|
-
Computes schema diffs and applies declarative migrations. In interactive mode (`auto_approve=False` or `interactive=True`), opens the visual review TUI. When `target=None`, auto-resolves database targets from `duckpack.toml`. Returns an `ApplyResult`.
|
|
693
|
+
- **`duckpack.apply(target=None, project_dir=".", auto_approve=True, force_drop=False, allow_lake_rewrite=False, interactive=False, database=None, catalog=None, env=None) -> ApplyResult`**
|
|
694
|
+
Computes schema diffs and applies declarative migrations. In interactive mode (`auto_approve=False` or `interactive=True`), opens the visual review TUI. When targeting a DuckLake catalog, physical copy-and-swap table rewrites (`RecreateTable`) are blocked unless `allow_lake_rewrite=True` is passed, and applied migrations automatically tag the DuckLake snapshot via `set_commit_message`. When `target=None`, auto-resolves database targets from `duckpack.toml`. Returns an `ApplyResult`.
|
|
713
695
|
|
|
714
696
|
- **`duckpack.diff(target=None, project_dir=".", database=None, catalog=None, env=None) -> DiffSummary`**
|
|
715
697
|
Compares declarative project state against target database or attached catalog without mutating data. When `target=None`, auto-resolves from `duckpack.toml`. Returns a `DiffSummary`.
|
|
@@ -733,14 +715,19 @@ import duckpack
|
|
|
733
715
|
|
|
734
716
|
### CLI Python Management
|
|
735
717
|
|
|
736
|
-
Check and install the Python bindings directly from the standalone DuckPack CLI
|
|
718
|
+
Check and install the Python bindings directly from the standalone DuckPack CLI. `duckpack python` automatically detects `$VIRTUAL_ENV`, `./.venv`, and whether your environment is managed by **`uv`** (`uv.lock` / `pyvenv.cfg` / missing `pip`) or **`pip`**:
|
|
737
719
|
|
|
738
720
|
```bash
|
|
739
|
-
# Verify Python
|
|
721
|
+
# Verify Python interpreter, detected installer (uv or pip), and installed package versions
|
|
740
722
|
duckpack python status
|
|
741
723
|
|
|
742
|
-
# Install or upgrade duckpack in active environment
|
|
724
|
+
# Install or upgrade duckpack in the active environment (auto-detects uv vs pip)
|
|
743
725
|
duckpack python install --upgrade
|
|
726
|
+
|
|
727
|
+
# Or explicitly select uv or pip:
|
|
728
|
+
duckpack python install --uv -U
|
|
729
|
+
duckpack python install --pip -U
|
|
730
|
+
duckpack python install --installer uv
|
|
744
731
|
```
|
|
745
732
|
|
|
746
733
|
---
|
|
@@ -876,7 +863,7 @@ Define connection targets, remote Quack instances, and environment profiles with
|
|
|
876
863
|
```toml
|
|
877
864
|
[project]
|
|
878
865
|
name = "analytics_warehouse"
|
|
879
|
-
version = "0.
|
|
866
|
+
version = "0.3.0"
|
|
880
867
|
|
|
881
868
|
[target]
|
|
882
869
|
default_db = "dev.duckdb"
|
|
@@ -1007,4 +994,3 @@ I know this may contain 'sub-optimal' or 'vibe code' solutions and code that cou
|
|
|
1007
994
|
|
|
1008
995
|
Thanks,
|
|
1009
996
|
**Ben**
|
|
1010
|
-
|
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "duckpack"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Declarative schema management, interactive terminal IDE, and in-memory inspection for DuckDB"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "Benjamen Terry", email = "benjamenjterry@gmail.com" }]
|
|
@@ -73,6 +73,127 @@ impl TriggerEntry {
|
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/// Represents an immutable commit snapshot in a DuckLake catalog (`ducklake_snapshots('<alias>')`).
|
|
77
|
+
#[derive(Clone, Debug, PartialEq)]
|
|
78
|
+
pub struct SnapshotEntry {
|
|
79
|
+
pub database: String,
|
|
80
|
+
pub snapshot_id: i64,
|
|
81
|
+
pub snapshot_time: String,
|
|
82
|
+
pub schema_version: Option<i64>,
|
|
83
|
+
pub changes: String,
|
|
84
|
+
pub commit_message: Option<String>,
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
impl SnapshotEntry {
|
|
88
|
+
/// Formats a concise one-line summary for the Explorer tree and Time-Travel modal picker.
|
|
89
|
+
pub fn display_summary(&self) -> String {
|
|
90
|
+
let ver_tag = self
|
|
91
|
+
.schema_version
|
|
92
|
+
.map(|v| format!(" [schema v{}]", v))
|
|
93
|
+
.unwrap_or_default();
|
|
94
|
+
let mut details = String::new();
|
|
95
|
+
if let Some(ref msg) = self.commit_message {
|
|
96
|
+
if !msg.trim().is_empty() {
|
|
97
|
+
details.push_str(&format!(" \"{}\"", msg.trim()));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if !self.changes.trim().is_empty() && self.changes.trim() != "{}" {
|
|
101
|
+
details.push_str(&format!(" {}", self.changes.trim()));
|
|
102
|
+
}
|
|
103
|
+
format!(
|
|
104
|
+
"v{} — {}{}{}",
|
|
105
|
+
self.snapshot_id, self.snapshot_time, ver_tag, details
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/// Loads up to 50 recent snapshots from `ducklake_snapshots('<db_name>')` (ordered newest-first).
|
|
111
|
+
/// Supports both local DuckLake attachments and remote Quack-attached DuckLakes.
|
|
112
|
+
pub fn load_ducklake_snapshots(
|
|
113
|
+
conn: &Connection,
|
|
114
|
+
db_name: &str,
|
|
115
|
+
is_quack: bool,
|
|
116
|
+
) -> Vec<SnapshotEntry> {
|
|
117
|
+
let safe_db = db_name.replace('\'', "''");
|
|
118
|
+
let mut snapshots = Vec::new();
|
|
119
|
+
|
|
120
|
+
let parse_rows = |sql: &str, include_commit_msg: bool, out: &mut Vec<SnapshotEntry>| -> bool {
|
|
121
|
+
if let Ok(mut stmt) = conn.prepare(sql) {
|
|
122
|
+
if let Ok(mut rows) = stmt.query([]) {
|
|
123
|
+
while let Ok(Some(row)) = rows.next() {
|
|
124
|
+
if let (Ok(snap_id), Ok(snap_time)) =
|
|
125
|
+
(row.get::<_, i64>(0), row.get::<_, String>(1))
|
|
126
|
+
{
|
|
127
|
+
let schema_version: Option<i64> = row.get(2).ok();
|
|
128
|
+
let changes: String = row.get(3).unwrap_or_default();
|
|
129
|
+
let commit_message: Option<String> = if include_commit_msg {
|
|
130
|
+
row.get::<_, String>(4)
|
|
131
|
+
.ok()
|
|
132
|
+
.filter(|s| !s.trim().is_empty())
|
|
133
|
+
} else {
|
|
134
|
+
None
|
|
135
|
+
};
|
|
136
|
+
out.push(SnapshotEntry {
|
|
137
|
+
database: db_name.to_string(),
|
|
138
|
+
snapshot_id: snap_id,
|
|
139
|
+
snapshot_time: snap_time,
|
|
140
|
+
schema_version,
|
|
141
|
+
changes,
|
|
142
|
+
commit_message,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
false
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
let sql_with_msg = format!(
|
|
153
|
+
"SELECT snapshot_id, CAST(snapshot_time AS VARCHAR), CAST(schema_version AS BIGINT), COALESCE(CAST(changes AS VARCHAR), ''), COALESCE(CAST(commit_message AS VARCHAR), '') FROM ducklake_snapshots('{}') ORDER BY snapshot_id DESC LIMIT 50",
|
|
154
|
+
safe_db
|
|
155
|
+
);
|
|
156
|
+
let sql_basic = format!(
|
|
157
|
+
"SELECT snapshot_id, CAST(snapshot_time AS VARCHAR), CAST(schema_version AS BIGINT), COALESCE(CAST(changes AS VARCHAR), '') FROM ducklake_snapshots('{}') ORDER BY snapshot_id DESC LIMIT 50",
|
|
158
|
+
safe_db
|
|
159
|
+
);
|
|
160
|
+
|
|
161
|
+
if !parse_rows(&sql_with_msg, true, &mut snapshots) {
|
|
162
|
+
let _ = parse_rows(&sql_basic, false, &mut snapshots);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if snapshots.is_empty() {
|
|
166
|
+
let quoted_db = format!("\"{}\"", db_name.replace('"', "\"\""));
|
|
167
|
+
let method_with_msg = format!(
|
|
168
|
+
"SELECT snapshot_id, CAST(snapshot_time AS VARCHAR), CAST(schema_version AS BIGINT), COALESCE(CAST(changes AS VARCHAR), ''), COALESCE(CAST(commit_message AS VARCHAR), '') FROM {}.snapshots() ORDER BY snapshot_id DESC LIMIT 50",
|
|
169
|
+
quoted_db
|
|
170
|
+
);
|
|
171
|
+
let method_basic = format!(
|
|
172
|
+
"SELECT snapshot_id, CAST(snapshot_time AS VARCHAR), CAST(schema_version AS BIGINT), COALESCE(CAST(changes AS VARCHAR), '') FROM {}.snapshots() ORDER BY snapshot_id DESC LIMIT 50",
|
|
173
|
+
quoted_db
|
|
174
|
+
);
|
|
175
|
+
if !parse_rows(&method_with_msg, true, &mut snapshots) {
|
|
176
|
+
let _ = parse_rows(&method_basic, false, &mut snapshots);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if snapshots.is_empty() && is_quack {
|
|
181
|
+
let remote_with_msg = format!(
|
|
182
|
+
"SELECT * FROM target_db.query('SELECT snapshot_id, CAST(snapshot_time AS VARCHAR) AS snapshot_time, CAST(schema_version AS BIGINT) AS schema_version, COALESCE(CAST(changes AS VARCHAR), '''') AS changes, COALESCE(CAST(commit_message AS VARCHAR), '''') AS commit_message FROM ducklake_snapshots(''{}'') ORDER BY snapshot_id DESC LIMIT 50')",
|
|
183
|
+
safe_db
|
|
184
|
+
);
|
|
185
|
+
let remote_basic = format!(
|
|
186
|
+
"SELECT * FROM target_db.query('SELECT snapshot_id, CAST(snapshot_time AS VARCHAR) AS snapshot_time, CAST(schema_version AS BIGINT) AS schema_version, COALESCE(CAST(changes AS VARCHAR), '''') AS changes FROM ducklake_snapshots(''{}'') ORDER BY snapshot_id DESC LIMIT 50')",
|
|
187
|
+
safe_db
|
|
188
|
+
);
|
|
189
|
+
if !parse_rows(&remote_with_msg, true, &mut snapshots) {
|
|
190
|
+
let _ = parse_rows(&remote_basic, false, &mut snapshots);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
snapshots
|
|
195
|
+
}
|
|
196
|
+
|
|
76
197
|
/// Metadata holding info on an attached database catalog.
|
|
77
198
|
#[derive(Clone, Debug, PartialEq)]
|
|
78
199
|
pub struct DatabaseInfo {
|
|
@@ -84,6 +205,7 @@ pub struct DatabaseInfo {
|
|
|
84
205
|
pub tables: Vec<TableEntry>,
|
|
85
206
|
pub views: Vec<ViewEntry>,
|
|
86
207
|
pub triggers: Vec<TriggerEntry>,
|
|
208
|
+
pub snapshots: Vec<SnapshotEntry>,
|
|
87
209
|
}
|
|
88
210
|
|
|
89
211
|
/// Metadata holding all discoverable entities in the database and project.
|
|
@@ -98,6 +220,7 @@ pub struct ExplorerMetadata {
|
|
|
98
220
|
pub temp_views: HashSet<String>,
|
|
99
221
|
pub macros: Vec<String>,
|
|
100
222
|
pub triggers: Vec<String>,
|
|
223
|
+
pub snapshots: Vec<SnapshotEntry>,
|
|
101
224
|
pub queries: Vec<String>,
|
|
102
225
|
pub dictionary: Vec<String>,
|
|
103
226
|
pub secrets: Vec<(String, String)>,
|
|
@@ -907,6 +1030,11 @@ pub fn load_explorer_metadata(
|
|
|
907
1030
|
}
|
|
908
1031
|
|
|
909
1032
|
let is_active = name == &active_database;
|
|
1033
|
+
let db_snapshots = if db_type.eq_ignore_ascii_case("ducklake") {
|
|
1034
|
+
load_ducklake_snapshots(conn, name, is_quack)
|
|
1035
|
+
} else {
|
|
1036
|
+
Vec::new()
|
|
1037
|
+
};
|
|
910
1038
|
databases.push(DatabaseInfo {
|
|
911
1039
|
name: name.clone(),
|
|
912
1040
|
db_type: db_type.clone(),
|
|
@@ -916,6 +1044,7 @@ pub fn load_explorer_metadata(
|
|
|
916
1044
|
tables: db_tables,
|
|
917
1045
|
views: db_views,
|
|
918
1046
|
triggers: db_triggers,
|
|
1047
|
+
snapshots: db_snapshots,
|
|
919
1048
|
});
|
|
920
1049
|
}
|
|
921
1050
|
|
|
@@ -935,6 +1064,7 @@ pub fn load_explorer_metadata(
|
|
|
935
1064
|
let mut table_counts: HashMap<String, i64> = HashMap::new();
|
|
936
1065
|
let mut views: Vec<String> = Vec::new();
|
|
937
1066
|
let mut triggers: Vec<String> = Vec::new();
|
|
1067
|
+
let mut snapshots: Vec<SnapshotEntry> = Vec::new();
|
|
938
1068
|
let mut temp_tables: HashSet<String> = HashSet::new();
|
|
939
1069
|
let mut temp_views: HashSet<String> = HashSet::new();
|
|
940
1070
|
|
|
@@ -965,6 +1095,7 @@ pub fn load_explorer_metadata(
|
|
|
965
1095
|
for trg in &active_info.triggers {
|
|
966
1096
|
triggers.push(format!("{} (on {})", trg.display_name(), trg.table_name));
|
|
967
1097
|
}
|
|
1098
|
+
snapshots = active_info.snapshots.clone();
|
|
968
1099
|
}
|
|
969
1100
|
|
|
970
1101
|
let mut macros: Vec<String> = Vec::new();
|
|
@@ -1121,6 +1252,7 @@ pub fn load_explorer_metadata(
|
|
|
1121
1252
|
temp_views,
|
|
1122
1253
|
macros,
|
|
1123
1254
|
triggers,
|
|
1255
|
+
snapshots,
|
|
1124
1256
|
queries,
|
|
1125
1257
|
dictionary,
|
|
1126
1258
|
secrets,
|
|
@@ -446,10 +446,10 @@ pub fn validate_target_catalog_exec(
|
|
|
446
446
|
);
|
|
447
447
|
}
|
|
448
448
|
let typ = db_info.db_type.to_lowercase();
|
|
449
|
-
if typ != "duckdb" && typ != "quack" {
|
|
449
|
+
if typ != "duckdb" && typ != "quack" && typ != "ducklake" {
|
|
450
450
|
anyhow::bail!(
|
|
451
451
|
"Cannot apply declarative schema migrations to '{}' (engine type: {}). \
|
|
452
|
-
DuckPack declarative schema management is designed specifically for DuckDB catalogs. \
|
|
452
|
+
DuckPack declarative schema management is designed specifically for DuckDB and DuckLake catalogs. \
|
|
453
453
|
External attached engines are supported for querying and DML, but schema DDL is managed externally.",
|
|
454
454
|
db_info.name,
|
|
455
455
|
db_info.db_type
|
|
@@ -469,6 +469,21 @@ pub fn validate_target_catalog_exec(
|
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
|
|
472
|
+
/// Returns `Some(AttachedDatabase)` if the specified (or active) target catalog is an attached `ducklake` catalog.
|
|
473
|
+
pub fn get_ducklake_catalog_info_exec(
|
|
474
|
+
exec: &mut dyn crate::engine::DbExecutor,
|
|
475
|
+
catalog: Option<&str>,
|
|
476
|
+
) -> Option<AttachedDatabase> {
|
|
477
|
+
let attached = list_attached_databases_exec(exec).unwrap_or_default();
|
|
478
|
+
let target = match catalog {
|
|
479
|
+
Some(c) if !c.is_empty() => c.to_string(),
|
|
480
|
+
_ => current_database_exec(exec),
|
|
481
|
+
};
|
|
482
|
+
attached.into_iter().find(|d| {
|
|
483
|
+
d.name.eq_ignore_ascii_case(&target) && d.db_type.eq_ignore_ascii_case("ducklake")
|
|
484
|
+
})
|
|
485
|
+
}
|
|
486
|
+
|
|
472
487
|
/// Common Table Expression for DuckDB 2.0 to resolve fully qualified nested schemas hierarchically.
|
|
473
488
|
pub const FULL_SCHEMAS_CTE: &str = "\
|
|
474
489
|
WITH RECURSIVE full_schemas AS ( \
|