pipekit/config/modules/oid.sql
Paul Trowbridge dd9f89f4b5 feat: version-control pipeline definitions via export/apply
Add `pipekit export` / `pipekit apply` (pipekit/config_io.py) to serialise the
DB's config — drivers, connections, modules (+ columns, watermarks, hooks),
groups, schedules — to a git-trackable text tree under config/, and rehydrate
it. SQLite stays runtime state; definitions become diffable/reviewable/
revertible.

- config only: run_log/group_run/settings and per-run state columns excluded
- name-keyed refs (portable across databases); source_query in .sql sidecars;
  columns as real JSON arrays for line-by-line diffs
- newline-normalised so CRLF-vs-LF is never a spurious change
- apply is create/update by name; child collections fully synced; top-level
  deletes gated behind --prune; --dry-run prints the plan
- round-trip is identity (export -> apply --dry-run == nothing to do)

Commits the current config/ as the first baseline, capturing the freshly
populated columns_json for rm00101/rm00301/iv00101. Documented in SPEC.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-22 10:56:55 -04:00

96 lines
2.5 KiB
SQL

WITH changed AS (
SELECT "DHINV#" FROM lgdat.oih WHERE DHIDAT BETWEEN '{oid_wm}' AND CURRENT_DATE
UNION SELECT "DHINV#" FROM lgdat.oih WHERE DHPDAT BETWEEN '{oid_wm}' AND CURRENT_DATE
UNION SELECT "DHINV#" FROM lgdat.oih WHERE DHPOST <> 'Y'
)
SELECT
"DIINV#" AS "diinv#",
"DILIN#" AS "dilin#",
"DIORD#" AS "diord#",
"DIITM#" AS "diitm#",
DIQTBO AS diqtbo,
DIQTSH AS diqtsh,
RTRIM(DIUNIT) AS diunit,
DIPRIC AS dipric,
RTRIM(DIPRUN) AS diprun,
DIRETP AS diretp,
RTRIM(DIRETU) AS diretu,
DIEXT AS diext,
RTRIM(DIPSTX) AS dipstx,
RTRIM(DIFTXC) AS diftxc,
RTRIM(DITXGR) AS ditxgr,
RTRIM(DITXRT) AS ditxrt,
RTRIM(DIDESC) AS didesc,
RTRIM(DIMAJR) AS dimajr,
RTRIM(DIMINR) AS diminr,
RTRIM(DIPART) AS dipart,
RTRIM(DIPREP) AS diprep,
RTRIM(DIRELN) AS direln,
RTRIM(DIGLCD) AS diglcd,
RTRIM(DIREAS) AS direas,
RTRIM(DISLMN) AS dislmn,
DICPCT AS dicpct,
DICRAT AS dicrat,
DICOST AS dicost,
DICTEX AS dictex,
DIQTSO AS diqtso,
RTRIM(DIORUN) AS diorun,
DIQTSP AS diqtsp,
DIEXTN AS diextn,
DITDIS AS ditdis,
DIPSTA AS dipsta,
DIFSTA AS difsta,
DITAXA AS ditaxa,
DIFTAM AS diftam,
RTRIM(DISTKL) AS distkl,
DILBCT AS dilbct,
DIBRCT AS dibrct,
DIMLCT AS dimlct,
DIOTCT AS diotct,
RTRIM(DIRAN) AS diran,
DIOLST AS diolst,
RTRIM(DIFUT1) AS difut1,
RTRIM(DIFUT2) AS difut2,
RTRIM(DIFUT3) AS difut3,
RTRIM(DIFUT4) AS difut4,
RTRIM(DIFUT5) AS difut5,
RTRIM(DIFUT6) AS difut6,
DIBRFC AS dibrfc,
DIBRVC AS dibrvc,
DIFUT7 AS difut7,
DIFUT8 AS difut8,
RTRIM(DIBLHL) AS diblhl,
DIIRNK AS diirnk,
DISTPR AS distpr,
RTRIM(DIPJCD) AS dipjcd,
DIWCN AS diwcn,
DIWCDN AS diwcdn,
RTRIM(DIADAL) AS diadal,
DIACRN AS diacrn,
DIACRL AS diacrl,
RTRIM(DIVSXF) AS divsxf,
RTRIM(DISRVC) AS disrvc,
DIEXCR AS diexcr,
CASE WHEN DIFDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE DIFDAT END AS difdat,
CASE WHEN DITDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE DITDAT END AS ditdat,
DIRBIV AS dirbiv,
DIRBIL AS dirbil,
RTRIM(DISONM) AS disonm,
DISOLN AS disoln,
RTRIM(DIMMEL) AS dimmel,
DIOITM AS dioitm,
RTRIM(DIFUT9) AS difut9,
RTRIM(DIFUT10) AS difut10,
RTRIM(DIFUT11) AS difut11,
RTRIM(DIFUT12) AS difut12,
RTRIM(DIFUT13) AS difut13,
RTRIM(DIFUT14) AS difut14,
RTRIM(DIFUT15) AS difut15,
RTRIM(DIFUT16) AS difut16,
RTRIM(DIFUT17) AS difut17,
DIFUT18 AS difut18,
DIFUT19 AS difut19,
DIFUT20 AS difut20
FROM LGDAT.OID
WHERE "DIINV#" IN (SELECT "DHINV#" FROM changed)