Migration from gh-stars
Background
Section titled “Background”The stars.nu module (v3.0.0) replaced the earlier gh-stars module. The database location changed:
| Version | Database path |
|---|---|
Legacy (gh-stars) | $XDG_DATA_HOME/gh-stars/stars.db |
Current (stars.nu v3) | $XDG_DATA_HOME/.stars/stars.db |
Automatic migration
Section titled “Automatic migration”On first use, the stars command checks for the legacy database and migrates it automatically. This happens in the check-migration function called at the start of the main command.
What happens
Section titled “What happens”- Checks if the new database (
$XDG_DATA_HOME/.stars/stars.db) already exists — if so, skips migration - Checks if the old database (
$XDG_DATA_HOME/gh-stars/stars.db) exists — if not, nothing to migrate - Creates the new storage directory structure
- Loads all records from the old database
- Adds
source: "github"column if missing - Adds
synced_atcolumn with current timestamp if missing - Writes to the new database location
- Preserves the old database — it is NOT deleted
Output
Section titled “Output”Migrating from /home/user/.local/share/gh-stars/stars.db to /home/user/.local/share/.stars/stars.db...Successfully migrated 1247 stars to new locationOld database preserved at: /home/user/.local/share/gh-stars/stars.dbManual migration
Section titled “Manual migration”If automatic migration doesn’t trigger (e.g., both databases exist), you can migrate manually:
let old_db = ($env.XDG_DATA_HOME | default "~/.local/share" | path join gh-stars stars.db)let new_db = ($env.XDG_DATA_HOME | default "~/.local/share" | path join .stars stars.db)
# Copy the databasecp $old_db $new_db
# Add missing columnsopen $new_db | query db "ALTER TABLE stars ADD COLUMN source TEXT DEFAULT 'github'"open $new_db | query db "ALTER TABLE stars ADD COLUMN synced_at TEXT"open $new_db | query db "ALTER TABLE stars ADD COLUMN starred_at TEXT"Then run a fresh sync to populate the new columns:
stars sync --fullSchema changes from gh-stars
Section titled “Schema changes from gh-stars”The v3 schema adds several columns that didn’t exist in the legacy format:
| Column | Added in v3 | Description |
|---|---|---|
source | Yes | Data source identifier ("github", etc.) |
synced_at | Yes | When the record was last synced |
starred_at | Yes | When the user starred the repo (from GitHub API) |
The starred_at column is also added via ALTER TABLE in ensure-storage for databases created before incremental sync was implemented.
Post-migration sync
Section titled “Post-migration sync”After migration, run a full sync to populate starred_at timestamps (which weren’t captured by the legacy module):
stars sync --fullThis replaces all records with fresh data from GitHub, including starred_at timestamps needed for incremental sync.