Repository navigation
Conversation
Adds a development container stack so the web app, background jobs, the Tailwind watcher, and PostgreSQL run together with the database surviving restarts and recreates. The data volume is mounted at /var/lib/postgresql rather than the older /var/lib/postgresql/data, because Postgres 18 sets PGDATA to /var/lib/postgresql/18/docker: mounting the old path leaves the data in the container layer, where it is silently lost on every recreate. config/database.yml now reads PGHOST/PGPORT/PGUSER/PGPASSWORD. They are unset by default, so local development keeps using the unix socket. Plain PG* variables are not enough on their own, because Rails always passes a host of nil and libpq then ignores PGHOST. Seeds accept SEED_ADMIN_EMAIL and SEED_ADMIN_PASSWORD in every environment so a container can be given a known login. Docs in docs/DOCKER.md, linked from the README and SETUP.md.
Moving a tag to a different id needs the referencing rows updated too, and plain update_column fails: the child rows cannot point at the new id before it exists, and the parent cannot move while children still point at the old one. Tags::RenumberId discovers every foreign key that references tags.id, then drops those constraints, remaps the rows, moves the primary key, and restores the constraints inside a single transaction. Usage: bin/rails tags:renumber_id OLD_ID=9 NEW_ID=14
The task has no coverage outside its own spec, and it is the kind of operation someone only reaches for when ids have already drifted, so documenting the accepted arguments, the cases that write nothing, and the foreign key ordering problem it works around matters more here than usual.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Runs the web app, background jobs, the Tailwind watcher, and PostgreSQL as a Docker Compose stack, with the database surviving restarts and container recreates.
The app comes up on http://localhost:3000, and the first boot prints the seeded admin login. See docs/DOCKER.md.
Persistence
The database lives in the named volume
macronx_pg_data, mounted at/var/lib/postgresqland not the older/var/lib/postgresql/data: Postgres 18 setsPGDATAto/var/lib/postgresql/18/docker, so mounting the old path leaves the data in the container layer where it is silently lost on every recreate. Onlydocker compose down -vdestroys it. Uploaded files persist through the working tree bind mount.Changes
Dockerfile.dev(new) — development image with the full bundle, plus ffmpeg for the audio pipeline and ImageMagick with libheif forImage::ConvertHeicToJpegJob, which mini_magick needs for itsconvertbinary. LeavesRAILS_ENVunset on purpose: baking indevelopmentwould defeatENV['RAILS_ENV'] ||= 'test'inspec/rails_helper.rband run the suite againstmacron_x_development.compose.yaml(new) —db,web,jobs, andcssservices.websetsBINDING=0.0.0.0because Rails binds to localhost in development, which is unreachable from outside a container.jobswaits on the web health check so the two never race to create the same database.config/database.yml— readsPGHOST/PGPORT/PGUSER/PGPASSWORD, all unset by default, so local development keeps using the unix socket. PlainPG*variables are not sufficient on their own: Rails always passes a nilhost, and libpq then ignoresPGHOST.*_DATABASE_URLwas avoided deliberately, since it also overrides the test database.db/seeds.rb—SEED_ADMIN_EMAILandSEED_ADMIN_PASSWORDnow work in every environment, so a container can be given a known login. Still idempotent.docs/DOCKER.md, linked from the README andSETUP.md, which now reflects the seed variables.Also in this branch:
tags:renumber_idUnrelated to Docker, but pushed to this branch rather than a PR of its own: a rake task for changing a tag's id.
update_column(:id, ...)on its own cannot work:inboxesandworkflowsboth hold foreign keys totags.id, so the children cannot point at the new id before it exists, and the parent cannot move while children still point at the old one — Postgres raisesForeignKeyViolationeither way.Tags::RenumberIdreads the referencing constraints out ofpg_constraintrather than hardcoding a table list, then drops them, remaps the rows, moves the primary key, and restores them inside one transaction. It runs withrequires_new: trueso a mid-flight failure rolls back only the remap. Invalid input aborts before touching anything.docs/MAINTENANCE.mdgains a "Changing a tag's id" section covering the arguments, the cases that write nothing, and the foreign key ordering problem. The motivating case is the inbox filter, which carries a tag id in the URL (/inboxes?tag=9), so a bookmarked filter link breaks once the id means a different tag in a restored or migrated database.Verified
bundle exec rspecin the container)bin/rubocopclean across 129 filesdocker compose downfollowed byup; the second boot'sdb:prepareis a no-optags:renumber_idrun end to end against the test database, plus all five rejected-input paths against development, which write nothingNote
Unrelated to this change but found while testing: the production
Dockerfileinstallslibvipsbut not ImageMagick, soImage::ConvertHeicToJpegJobcannot shell out toconvertthere. Left alone here since the production image is out of scope, but worth a follow-up if IMINT runs in production.