Skip to content

feat(project): unique COMPOSE_PROJECT_NAME in .env for Docker volumes#1252

Open
RoboShyim (roboshyim) wants to merge 1 commit into
shopware:mainfrom
roboshyim:feat/unique-compose-project-name
Open

feat(project): unique COMPOSE_PROJECT_NAME in .env for Docker volumes#1252
RoboShyim (roboshyim) wants to merge 1 commit into
shopware:mainfrom
roboshyim:feat/unique-compose-project-name

Conversation

@roboshyim

Copy link
Copy Markdown
Contributor

Summary

Implements #1251.

Docker Compose was using the directory basename as the project name, so named volumes (db-data, …) collided when a project folder was deleted and recreated with the same name (or two trees shared a basename). That made system:is-installed succeed against stale DB data and skip the install wizard.

Changes

Area Behaviour
project create --docker Writes COMPOSE_PROJECT_NAME=sw-<basename>-<6hex> to host .env (not .env.local)
Non-docker create .env stays empty
Existing projects Unset → basename behaviour (backward compatible); already set → left alone
flexmigrator.MigrateEnv Keeps COMPOSE_PROJECT_NAME in the new empty .env when splitting flex env
Migration wizard → Docker EnsureComposeProjectName if missing

Compose still runs with Dir = projectRoot (devtui/compose.go) and picks up .env automatically — no -p / compose name: key required.

Tests

  • go test ./internal/shop/ ./internal/flexmigrator/ ./internal/devtui/ -run Migration…
  • Scaffold docker vs non-docker, uniqueness of same basename, flex preserve, Ensure* preserve/append

Checklist

  • project create --docker writes unique name to .env
  • Two creates with same folder name get different names
  • Non-docker does not require a project name
  • Tests for scaffold docker vs non-docker
  • Migration wizard path sets name if missing

Docker Compose was deriving the project name from the directory basename,
so deleting and recreating a same-named folder (or two projects sharing a
basename) reused stale named volumes and skipped the install wizard.

- Scaffold --docker writes COMPOSE_PROJECT_NAME=sw-<basename>-<hex> to host .env
- Non-docker create still leaves .env empty
- flexmigrator.MigrateEnv preserves COMPOSE_PROJECT_NAME in the new .env
- Migration wizard ensuring Docker sets the variable when missing
- Existing stacks with a name already set are left untouched

Closes shopware#1251
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 79.16667% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.71%. Comparing base (3340b47) to head (083ad74).

Files with missing lines Patch % Lines
internal/shop/compose_project_name.go 82.00% 9 Missing ⚠️
internal/devtui/model_update.go 20.00% 4 Missing ⚠️
internal/flexmigrator/env.go 92.30% 1 Missing ⚠️
internal/shop/project_scaffold.go 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1252      +/-   ##
==========================================
+ Coverage   53.63%   53.71%   +0.07%     
==========================================
  Files         303      304       +1     
  Lines       23325    23392      +67     
==========================================
+ Hits        12511    12564      +53     
- Misses      10787    10801      +14     
  Partials       27       27              
Flag Coverage Δ
go-test 53.71% <79.16%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

3 participants