Handling Local Database Migrations (CLI)
When using the DataChain CLI, datasets are stored in a local SQLite database located at:
Unlike the SaaS version (Studio), the CLI does not support automatic database migrations. This means that after upgrading the DataChain CLI, the local database schema may become incompatible with the updated codebase.
Schema Mismatch Detection
The CLI automatically checks for schema compatibility. If a mismatch is detected, you’ll see an error like:
This typically happens after upgrading the CLI to a newer version.
How to Fix It
The recommended fix is to delete the local database and let the CLI recreate it. To avoid losing datasets, you should export them before removing the database.
Before deleting the file, we strongly recommend making a backup of your current database:
This allows you to recover data manually if needed later.
Exporting and Re-Importing All Local Datasets
Important: Exporting datasets must be done before upgrading to a new DataChain version. Export with the old version to avoid the OutdatedDatabaseSchemaError during export. After deleting the database file, upgrade/install the new DataChain version.
Step 1: Export All Datasets to Parquet
Export all datasets into a folder named exported_datasets (created if it doesn't exist). Each dataset will be saved to a file in the format:
Example: metrics.1.0.1.parquet
Step 2: Delete Local Database
Make sure you've backed it up (see above), then:
Step 3: Re-import All Datasets from Parquet (In Correct Version Order)
To avoid import errors due to semantic versioning constraints, datasets must be imported in ascending order by version for each dataset name.
Note: While exporting and importing datasets to Parquet files preserves the datasets and their data, some metadata - such as dataset dependencies - will not be preserved. This information will be lost during this process.
Notes
- This limitation only applies to the CLI, which uses a local SQLite database.
- The Studio (SaaS) version handles all schema migrations automatically - no manual steps are required.
- The CLI only supports the default namespace/project:
local.local.
This export/import workflow is the recommended way to preserve your datasets during local CLI upgrades that involve database schema changes.