Skip to content

PowerSync storage is not initialized automatically on startup #162

Description

@armandoschianodicola

Bug description

The startup procedure introduced in commit 8f105d9 requires users to run two separate commands:

docker compose up -d
docker compose exec web ./manage.py setup-powersync-storage

However, the first command starts PowerSync before its required PostgreSQL role and schema have been created. As a result, PowerSync can initially fail, after which the user must run the second command to initialize its storage.

This could look like a not clear or reliable setup procedure: an error during the first documented step appears to indicate that the deployment failed, even though the user is expected to continue with the next step.

The numbered bullet points in the README are also misleading because they suggest a straightforward sequence of successful setup steps. They do not explain that PowerSync may fail during the first step or that the second command is required to recover from that state.

Steps to reproduce

  1. Set up a fresh wger Docker installation.

  2. Run:

    docker compose up -d
  3. Check the PowerSync service and its logs.

  4. Observe that PowerSync can fail because its database role and schema do not exist.

  5. Run the separately documented initialization command:

    docker compose exec web ./manage.py setup-powersync-storage
  6. Restart or wait for the affected service to recover.

Expected behavior

A fresh installation should have a clear, reliable startup procedure that requires only:

docker compose up -d

The required PowerSync database role and schema should be initialized automatically before PowerSync starts. Users should not encounter an expected error as part of the documented setup process.

Actual behavior

The documented procedure requires two commands.

The first command starts PowerSync before its storage has been initialized, so the service can fail. The user must then run a second command to create the required database objects.

The README presents these commands as ordinary sequential steps without making the intermediate failure clear, resulting in a confusing and misleading setup experience.

Proposed fix

Add a one-shot powersync_init service that:

  • Waits for PostgreSQL to become healthy.
  • Runs ./manage.py setup-powersync-storage.
  • Completes successfully before the powersync service starts.

Update the README to:

  • Document docker compose up -d as the complete startup procedure.
  • Remove the separate manual initialization step.
  • Remove the misleading numbered bullet points.
  • Explain that the powersync_init service initializes the required database role and schema automatically.

Acceptance criteria

  • A fresh deployment requires only docker compose up -d.
  • A fresh deployment requires no manual PowerSync initialization.
  • powersync_init waits for a healthy PostgreSQL service.
  • PowerSync starts only after initialization succeeds.
  • Users do not encounter an expected PowerSync failure during the documented startup procedure.
  • Re-running the initialization is safe for existing deployments.
  • docker compose config --quiet succeeds.
  • The README no longer presents the manual initialization as a separate numbered step.
  • The README clearly explains that PowerSync storage is initialized automatically.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions