Move .env ownership to this repo and default CDC to pgoutput - #74
Open
DmitriiAn wants to merge 3 commits into
Open
Move .env ownership to this repo and default CDC to pgoutput#74DmitriiAn wants to merge 3 commits into
DmitriiAn wants to merge 3 commits into
Conversation
Add pgcopydb-helpers/env-template as the reference ~/.env. The user copies it to ~/.env on the migration instance. The provisioning templates no longer create that file. The file cannot be named .env here: .gitignore blocks the name to keep credentials out of git, and the templates deploy with "cp -r pgcopydb-helpers/* /home/ubuntu/", where the shell glob does not match dotfiles. Move the remaining hardcoded tunables into ~/.env: - OUTPUT_PLUGIN, new, default pgoutput. planetscale/pgcopydb#58 adds the pgoutput plugin and makes it the pgcopydb default. It is part of PostgreSQL core, so the source server needs no extension. Set OUTPUT_PLUGIN=wal2json to keep the previous plugin. - SPLIT_TABLES_LARGER_THAN, default 50GB, was a literal in three scripts. - FILTER_FILE, default ~/filters.ini, was a literal in five scripts. run-migration.sh, resume-migration.sh and resume-cdc.sh now log the effective plugin, jobs, split size and filter path to migration.log. drop-replication-slots.sh also drops the source publication. pgcopydb creates one named after the replication slot for pgoutput, so without this it is left behind on the source after every migration. The drop needs ownership of the publication, so the script warns and continues on failure. Every script that sources ~/.env now checks the file exists first and prints the cp command if it does not. Without a guard the scripts failed with a raw "No such file or directory" from the shell, which is reachable now that no template creates the file. Checked with bash -n and shellcheck on the helper scripts and the terraform templates, and cfn-lint on the CloudFormation template.
teknogeek0
marked this pull request as ready for review
August 27, 2026 19:48
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.
Summary
~/.envis now owned by this repo instead of the provisioning templates, and every remaining hardcoded tunable moves into it. CDC defaults to thepgoutputplugin.env-templateNew file
pgcopydb-helpers/env-templateis the reference~/.env. On the instance:It cannot be named
.envin the repo..gitignoreblocks that name to keep credentials out of git, and the templates deploy withcp -r pgcopydb-helpers/* /home/ubuntu/, where the shell glob does not match dotfiles. Naming itenv-templatemeans it deploys with the scripts and needs no template change.Tunables moved into
~/.envTABLE_JOBSINDEX_JOBSSPLIT_TABLES_LARGER_THANOUTPUT_PLUGINwal2jsonin 3 scriptsFILTER_FILE~/filters.inirun-migration.sh,resume-migration.shandresume-cdc.shnow log the effective plugin, jobs, split size and filter path tomigration.log.pgoutput
planetscale/pgcopydb#58 adds the
pgoutputplugin and makes it the pgcopydb default. This PR follows it.pgoutputis part of PostgreSQL core, so the source server needs no extension, and it sends about 4.5x less network volume thanwal2json. SetOUTPUT_PLUGIN=wal2jsonto keep the previous plugin.drop-replication-slots.shalso drops the source publication now. pgcopydb creates one named after the replication slot forpgoutput, so without this it is left behind on the source after every migration. The drop needs ownership of the publication, so the script warns and continues on failure.Templates
The three templates no longer create
~/.env.pgcopydb-templates/README.mdnow gives thecp ~/env-template ~/.envsteps.Missing
.envguardNo template creates
~/.envany more, so a fresh instance has none. Every script that sources it failed with a raw shell error:verify-migration.shalready guarded this. The same check is now in the other 13 scripts:Docs
pgcopydb-helpers/README.mdandAGENTS.mdare rewritten around theenv-templateflow, each with a single configuration table and an output-plugin section.Tests
No automated suite in this repo. Checked manually:
bash -non all helper scripts and both terraform templates: pass.shellcheck -S erroron all helper scripts: clean, apart from the pre-existingSC2148infilters-lib.sh.cfn-linton the CloudFormation template: exit 0, no output.FILTER_FILE=~/filters.iniexpands correctly throughset -a; source, and defaults apply with an empty.env..envguard: exits 1 with the message above.