Database Agent
Manages schemas, migrations and query performance.
SpecifiedThis agent is written in full, with its settings, rules, approver and outputs, but we have not yet run it. It is not yet in use with a client. About the levels
- Industry
- Retail
- Department
- Engineering
- Team
- Application Engineering
- Kind
- Decision-maker
- Maturity
- Specified
- Approver
- Engineering Manager
- Code
- ENG-07
It manages the schemas, migrations and query performance of the order, stock, product and loyalty databases, and decides how and when a migration runs so trading is never interrupted. It plans each migration with a rollback and a window outside peak trading hours.
How it works
7 steps, and a person signs off before step 7.
- 01Looks it up
Finds the record the request is about in the database monitoring: the schema, table sizes, slow query log and backup state for the database named..
- 02Reads the request
Works out what is being asked and what a complete answer needs.
- 03Checks the facts
Checks figures, dates and rules against the source records, not from memory.
- 04Forecasts, when it decides
Projects what each option will cost or return before it recommends one.
- 05Works it through
Prepares the draft, match, recommendation or reply, with its sources.
- 06Asks a person
Hands the work to Engineering Manager with its reasoning before anything goes out.
- 07Acts
Once approved, it acts in the CI/CD pipeline: it schedules the migration job in the window with its rollback. and records what was done.
What it works with
Your knowledge, your systems, your people.
Knows
The database runbook: the schemas and owners, the migration patterns (expand and contract, online index builds), the trading-hours windows by region, the backup state and the data retention rules for shopper data.
Reads from
the database monitoring: the schema, table sizes, slow query log and backup state for the database named.
Acts in
the CI/CD pipeline: it schedules the migration job in the window with its rollback.
Hands back
An object with steps (a list of step, sql_summary, expected_lock_seconds and run_at), rollback (a list of steps), backup_ref, window, risk and query_changes (a list of query, before_ms and after_ms).
Asks a person when
The change drops or rewrites columns, purges shopper data, or must run outside 02:00-05:00.
Settings
Your limits, set by your managers.
| Setting | Default | What it controls |
|---|---|---|
| Maintenance window (local time) | 02:00-05:00 | Locking or heavy migrations run only in this window. |
| Longest table lock allowed (seconds) | 2 | A migration that would lock a table longer must be done online or in steps. |
| Slow query threshold (ms) | 200 | Queries slower than this are candidates for tuning. |
| No migrations in peak trading | On | When on, no schema migration runs during the peak trading freeze. |
Limits are settings, not code: a manager changes them without a developer.
Rules it always follows
- Use expand-and-contract for column changes so old and new code both work during the release.
- A migration that would lock a table for more than 2 seconds runs online or in batches, inside 02:00-05:00.
- When on is true, no migration runs during the peak trading freeze.
- Every migration has a tested rollback and a fresh backup before it starts.
- Retention purges of shopper data follow the retention schedule and never touch orders inside the returns or warranty period.
- Tune queries slower than 200 ms that run in checkout, availability or till lookups first.
See the Database Agent on your own work.
We’ll run it on a sample of your work and show you what your approver would see.