This guide explains how to set up the local database for the vlt serverless registry.
For a fresh installation, run:
vlr db:setupThis command will:
- Create the initial database tables (
packages,tokens,versions) - Apply all necessary schema migrations
- Insert a default admin token
If you need to set up the database manually:
# Create initial tables
vlx wrangler d1 execute vsr-local-database --file=src/db/migrations/0000_initial.sql --local --persist-to=local-store --no-remote
# Apply schema updates (adds columns: last_updated, origin, upstream, cached_at)
vlx wrangler d1 execute vsr-local-database --file=src/db/migrations/0001_wealthy_magdalene.sql --local --persist-to=local-store --no-remoteThe database includes three main tables:
name(TEXT, PRIMARY KEY) - Package name (e.g., "lodash", "@types/node")tags(TEXT) - JSON string of dist-tags (e.g.,{"latest": "1.0.0"})last_updated(TEXT) - ISO timestamp of last updateorigin(TEXT) - Either "local" or "upstream"upstream(TEXT) - Name of upstream registry (for cached packages)cached_at(TEXT) - ISO timestamp when cached from upstream
token(TEXT, PRIMARY KEY) - Authentication tokenuuid(TEXT) - User identifierscope(TEXT) - JSON string of token permissions
spec(TEXT, PRIMARY KEY) - Package version spec (e.g., "lodash@4.17.21")manifest(TEXT) - JSON string of package.json manifestpublished_at(TEXT) - ISO timestamp when version was publishedorigin(TEXT) - Either "local" or "upstream"upstream(TEXT) - Name of upstream registry (for cached versions)cached_at(TEXT) - ISO timestamp when cached from upstream
This error means the database hasn't been initialized. Run:
vlr db:setupThis means the initial migration ran but the schema update didn't. Run:
vlx wrangler d1 execute vsr-local-database --file=src/db/migrations/0001_wealthy_magdalene.sql --local --persist-to=local-store --no-remoteTo completely reset the database:
vlr db:drop
vlr db:setupThe local database is stored in:
./local-store/v3/d1/miniflare-D1DatabaseObject/
The setup creates a default admin token:
- Token:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx - UUID:
admin - Permissions: Full read/write access to all packages and users