Skip to content

fix: Remove accounts table check from migration detection logic - #25

Closed
upmcplanetracker wants to merge 9 commits into
cgnl:mainfrom
upmcplanetracker:main
Closed

upmcplanetracker wants to merge 9 commits into
cgnl:mainfrom
upmcplanetracker:main

Conversation

@upmcplanetracker

Copy link
Copy Markdown

re issue #24

The Problem

When the PostgreSQL schema is first initialized, the container creates a default Administrator account (and a preferences row) as bootstrap data. The migration detection logic in migrate_lib.sh currently checks three tables:

  • metadata_items
  • library_sections
  • accounts

If any of these tables contain rows, the migration is skipped. This is incorrect, because the accounts table always contains a row even before any user data has been migrated.

As a result, users with an existing SQLite database see:

PostgreSQL already has data (metadata_items=0, library_sections=0, accounts=1).
Non-interactive mode: skipping migration (PostgreSQL has data)

… and the migration never runs, despite having an empty library.

The Fix

We remove the accounts check entirely. The migration is skipped only if there is actual library content, i.e. rows in metadata_items or library_sections. The default administrator account is bootstrap data and should not block the migration.

Code change (in scripts/migrate_lib.sh)

 local pg_count=$(psql -t -c "SELECT COUNT(*) FROM $PG_SCHEMA.metadata_items;" 2>/dev/null | tr -d ' ' || echo "0")
 local pg_sections=$(psql -t -c "SELECT COUNT(*) FROM $PG_SCHEMA.library_sections;" 2>/dev/null | tr -d ' ' || echo "0")
- local pg_accounts=$(psql -t -c "SELECT COUNT(*) FROM $PG_SCHEMA.accounts;" 2>/dev/null | tr -d ' ' || echo "0")
 local pg_has_data=0
- if [[ "$pg_count" -gt 0 ]] || [[ "$pg_sections" -gt 0 ]] || [[ "$pg_accounts" -gt 0 ]]; then
+ if [[ "$pg_count" -gt 0 ]] || [[ "$pg_sections" -gt 0 ]]; then
     pg_has_data=1
 fi

The corresponding log message is also updated to avoid mentioning accounts:

- echo -e "${YELLOW}PostgreSQL already has data (metadata_items=$pg_count, library_sections=$pg_sections, accounts=$pg_accounts).${NC}"
+ echo -e "${YELLOW}PostgreSQL already has library data (metadata_items=$pg_count, library_sections=$pg_sections).${NC}"

Testing

  • Tested with a fresh PostgreSQL instance (only schema + default admin account) and an existing SQLite database containing ~5,700 media items.
  • The migration now runs as expected; check_and_migrate detects that metadata_items=0 and library_sections=0 and proceeds.
  • Verified that when a PostgreSQL database already contains library rows, the migration is still correctly skipped.
  • Non‑interactive mode (MIGRATION_INTERACTIVE=0) now also works correctly.

Additional Notes

  • This change does not address the SIGSEGV crash reported in the original issue – that is a separate bug in the Rust shim and will be handled in a different PR.
  • The accounts table is still present and functional; we simply no longer use it to decide whether to skip migration.

upmcplanetracker and others added 9 commits August 28, 2026 17:26
Removed accounts check from PostgreSQL data migration script.
This workflow builds and pushes a debug image with optional sanitizer types and creates a multi-architecture manifest.
Removed ARM64 build configuration from the workflow.
Add conditional installation of sanitizer libraries for GCC based on build argument.
Refactor sanitizer library installation and update runtime libraries for PostgreSQL client.
Updated Dockerfile to clarify comments and modify sanitizer installation.
Removed unnecessary sanitizer libraries from build dependencies.
@upmcplanetracker

Copy link
Copy Markdown
Author

closing, project doesn't seem actively maintained.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant