environment_immutable
The update tried to change a project's environment between test and live, and that column is immutable once the project exists.
How to fix it
- Create a second project in the target environment and keep both. This is the intended pattern, not a workaround.
- Swap the credential rather than the project. An efa_test_ key resolves only to test projects and an efa_live_ key only to live ones, so the environment follows the key your deployment is configured with.
- Do not look for a promotion endpoint. There is none, and this is the enforcement that makes that statement true rather than a convention.
Which rule fired
A BEFORE UPDATE trigger on projects compares the new environment with the old one and raises environment_immutable with SQLSTATE restrict_violation if they differ. There is no REST route that attempts this, so you will not meet it by calling the public API. It appears in database errors and in logs when something writes the column directly. The reason for the rule is that environment is load-bearing everywhere else: key prefixes resolve by it, inbox addressing depends on it, and the quota path distinguishes charged from free traffic by it. A project that changed environment would leave rows whose environment no longer matches the project they belong to.
| In the Postgres error | Means |
|---|---|
environment_immutable | An UPDATE on projects where NEW.environment is distinct from OLD.environment. |
Why it works this way: This lives in a trigger because environment is the boundary the entire test and live separation rests on. Enforcing it in one service method would leave every other writer, including a future one, able to break the invariant that every inbox, message and quota row inherits from its project.
Example
ERROR: environment_immutable
SQLSTATE: 23001 (restrict_violation)