diff --git a/.github/workflows/upgrade-source-gate.yml b/.github/workflows/upgrade-source-gate.yml new file mode 100644 index 00000000000..706560b850e --- /dev/null +++ b/.github/workflows/upgrade-source-gate.yml @@ -0,0 +1,152 @@ +# Upgrade-source gate — the v18 → v19 SOURCE upgrade, walked the way a real +# 18.x user walks it, against this checkout's packed tarballs, with no model key. +# +# Every upgrade-path defect found on the GA path passed its own unit tests and +# was caught only by a hand-run acceptance: the migration tool's tests use +# stacks written as literals, while a user's project is the template's +# `exportsOf(…)` wiring over barrels, with a database an 18.x install wrote. +# The two neighbouring gates cover other ground: `scaffold-e2e.yml` builds and +# boots a NEW scaffold, and `upgrade-harness-optin.yml` boots an 18.0 DATABASE +# on main; neither runs the source migration. +# +# The job and its assertions live in `packages/qa/upgrade-source/run.mjs` +# (header: what is walked, and how an assertion that waits on an open card is +# reported); the committed 18.6.0 project and the database the PUBLISHED 18.6.0 +# CLI wrote for it sit beside it, with their provenance. The install step is +# scaffold-e2e.yml's: this checkout's publishable packages packed with +# `scripts/publish-smoke-pack.mjs`, and the project's `@objectstack/*` pins +# moved to that version and resolved through the project's own pnpm overrides. +# +# NOT a required check, and green: no assertion waits on an open card. A red +# reads UNEXPECTED unless its `waitsOn` card is open and the red is that card's +# own failure (run.mjs header). It joins the required set only by a later, +# deliberate edit of `scripts/check-required-contexts.mjs`. +# +# Every step below is part of an install/build/migrate/boot pipeline, not a +# named local verification script a dev pre-runs with `pnpm check:x` — there is +# no check family here to discover, deliberately (the scaffold-e2e.yml shape): +# dispatch-gates: no-check-families -- steps are an e2e pipeline, not named local checks + +name: Upgrade Source Gate + +on: + pull_request: + # Every input the walk runs through, by the step that reads it. A step's + # code missing here lets a PR change what the walk asserts without the walk + # running on it. + paths: + # `os migrate meta` (--write, --stored), `os migrate apply`, `os migrate + # protocol`, the source writer, and the schema migration they share. + - 'packages/cli/**/migrate*' + - 'packages/cli/**/migrate*/**' + - 'packages/cli/src/utils/authored-source-*' + - 'packages/cli/src/utils/schema-migrate.ts' + # `os validate` / `os build`, and the protocol-range check both run. + - 'packages/cli/src/commands/validate.ts' + - 'packages/cli/src/commands/build.ts' + - 'packages/cli/src/commands/compile.ts' + - 'packages/cli/src/utils/protocol-version-gap.ts' + # T2: the dry run's own-field-row list (`ownFieldRowNarrowing`). + - 'packages/cli/src/utils/own-field-row-narrowing.ts' + # The ADR-0087 conversion table (its entries, `conversions/entries/NN/*`) + # and the migration chain and registry that replay it. + - 'packages/spec/src/conversions/**' + - 'packages/spec/src/**/migrations/**' + # The stored-row conversion `--stored` and the boot apply to sys_metadata. + - 'packages/metadata-protocol/src/stored-migration.ts' + - 'packages/metadata-protocol/src/protocol-stored-*' + # B5 and B6: the runtime field axis the boot's reads and writes go through + # (the set's own field row against viewAllFields / Modify All). + - 'packages/plugins/plugin-security/src/permission-evaluator.ts' + - 'packages/plugins/plugin-security/src/field-masker.ts' + - 'packages/plugins/plugin-security/src/security-plugin-authz-middleware.ts' + - 'packages/core/src/security/effective-object-permissions.ts' + # The template a user's project starts from. + - 'packages/cli/src/commands/init.ts' + - 'packages/create-objectstack/**' + # How the walk installs this checkout: the packer and the workspace setup. + - 'scripts/publish-smoke-pack.mjs' + - '.github/actions/setup-workspace/**' + # The gate itself. + - 'packages/qa/upgrade-source/**' + - '.github/workflows/upgrade-source-gate.yml' + schedule: + - cron: '41 4 * * *' + workflow_dispatch: + +permissions: + contents: read + +# A newer run for the same pull request supersedes this one; the schedule and +# dispatch runs share a group keyed on their own event and wait for each other +# (scaffold-e2e.yml's shape). +concurrency: + group: upgrade-source-gate-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.after || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + upgrade-source: + name: v18 → v19 source upgrade + runs-on: ubuntu-latest + timeout-minutes: 45 + steps: + - name: Checkout repository + uses: actions/checkout@v7 + + - name: Setup workspace + uses: ./.github/actions/setup-workspace + + - name: Setup turbo cache + uses: actions/cache@v6 + with: + path: .turbo/cache + key: ${{ runner.os }}-turbo-${{ github.job }}-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-turbo-${{ github.job }}- + ${{ runner.os }}-turbo- + + # The runner's pure judgements, on fixtures, before anything is built. + - name: Self-test the runner + run: node packages/qa/upgrade-source/run.mjs --self-test + + # The build set is read off the fixture's own package.json, never a hand + # list: each `@objectstack/*` dependency it declares, with turbo's + # `^build` bringing that package's workspace dependencies along. + - name: Build the framework the fixture depends on + run: | + FILTERS=$(node -p ' + const pkg = require("./packages/qa/upgrade-source/fixture-18.6.0/package.json"); + const names = [pkg.dependencies, pkg.devDependencies] + .flatMap((deps) => Object.keys(deps ?? {})) + .filter((name) => name.startsWith("@objectstack/")); + if (names.length === 0) throw new Error("the fixture declares no @objectstack/* dependency"); + names.map((name) => "--filter=" + name).join(" "); + ') + echo "turbo run build $FILTERS" + # shellcheck disable=SC2086 # FILTERS is a word list on purpose. + pnpm exec turbo run build $FILTERS + + - name: Pack this checkout's publishable packages + run: node scripts/publish-smoke-pack.mjs "$RUNNER_TEMP/tarballs" + + # Template wiring (migrate meta --write, re-run, range, validate, build), + # the 18.6.0 database (migrate apply, the protocol-19 switch, --stored), + # the boot and its reads, then the helper-built wiring. The summary lists + # every assertion, and names the card each red waits on. + # GITHUB_TOKEN reads (only) the state of each card an expected red waits + # on: a red is excused only while its card reads open. + - name: Walk the v18 → v19 upgrade + env: + GITHUB_TOKEN: ${{ github.token }} + run: node packages/qa/upgrade-source/run.mjs --tarballs "$RUNNER_TEMP/tarballs" --work "$RUNNER_TEMP/upgrade-source" + + - name: Upload the walk's logs + if: always() + uses: actions/upload-artifact@v7 + with: + name: upgrade-source-logs + path: | + ${{ runner.temp }}/upgrade-source/logs + ${{ runner.temp }}/upgrade-source/results.json + if-no-files-found: ignore + retention-days: 14 diff --git a/packages/qa/upgrade-source/README.md b/packages/qa/upgrade-source/README.md new file mode 100644 index 00000000000..675641d6b9d --- /dev/null +++ b/packages/qa/upgrade-source/README.md @@ -0,0 +1,72 @@ +# Upgrade-source gate (v18 → v19) + +The source-upgrade path a real 18.x user takes, walked end to end against this +checkout by `.github/workflows/upgrade-source-gate.yml`. No model key is used +anywhere. + +| Path | What it is | +|---|---| +| `fixture-18.6.0/` | An 18.6.0 project shaped like a user's (see below). Never edited to suit 19: it is the "before". | +| `fixture-db-18.6.0/` | The SQLite database the **published** 18.6.0 CLI wrote for that project, as SQL text, with `manifest.json` (what was put in it, and what 18.6.0 served) and `provenance.json` (the command, the versions, the hashes). | +| `generate-fixture-db.mjs` | The generator behind `fixture-db-18.6.0/`. Run it again rather than editing its output. | +| `helper-wiring/` | The second wiring: the same sources behind `composeStacks(createCrmStack(…))`, the shape a larger app (HotCRM) takes. It is an overlay laid over a copy of the fixture (its `package.json` is the fixture's under another name). | +| `run.mjs` | The walk and its assertions (`--self-test` covers its pure judgements). The header lists every step. | + +## Why here, and why the object files are not named `*.object.ts` + +The fixture's `.ts` files are 18.6.0 sources, and this checkout's 19 spec +refuses them (`view.list.bulkActions`), which is the point. So nothing in this +repository may type-check or import them: + +- `packages/` is outside the root type-check program (`tsconfig.json` excludes + it), and this directory has no `package.json`, so it is not a workspace member. + `fixture-18.6.0/` and `helper-wiring/` each carry a `package.json` (the + helper's is the fixture's under another name): the type-check coverage walk + skips a directory with one as another project's, which is what each of them is. +- Two `platform-objects` sweeps import every `*.object.ts` under `packages/` as + code this repository ships; only the scaffolding templates are excluded, by + name. So the fixture's object files are `src/objects/account.ts`, `contact.ts` + and `note.ts`, and the barrel imports them by those names. `os migrate meta` + never reads a file name: the wiring and every metadata shape are as 18.6.0 + wrote them. ⛔ Do not use a dot-directory instead: `check-affected-docs` pins + that no tracked `.ts` under `packages/**` lives in one. + +`fixture-18.6.0/package.json` pins `18.6.0`, and the runner moves those pins to +the checkout's version, as a user's upgrade does. + +## The fixture + +It was scaffolded with `npx create-objectstack@18.6.0 crm18 --skip-skills`, and +its metadata was written with that install's own `os generate` and then edited +by hand. `os validate` and `os build` pass on 18.6.0. It holds: + +- the blank template's `objectstack.config.ts`, with its `exportsOf(…)` wiring unchanged; +- `crm18_account`, and `crm18_contact` with a master-detail and a lookup to it; +- list views carrying `list.bulkActions`, and three actions; +- `crm18_auditor`: View All and Modify All on contacts, plus its own row hiding `crm18_contact.salary`; +- `crm18_member`, with a field row hiding the account notes; +- a validation rule, a record-triggered flow, a dataset and a dashboard; +- a committed `access-matrix.json` (written by 18.6.0's `os build --update-access-matrix`). + +The sample `note` object from the template stays, because a user's project +usually still has it. The template's Dockerfile, docs and starter test are left +out: the gate does not use them. + +## The database + +`node packages/qa/upgrade-source/generate-fixture-db.mjs` (needs the npm +registry, pnpm and Node 22.13 or later) does the following: + +1. Installs the fixture from the registry at its 18.6.0 pins. +2. Builds it and boots it with that install's own `os start` on a new SQLite file. +3. Signs up the owner. On 18.6.0 self-registration then closes, so the owner + creates the member and the auditor, and each sets their own password. +4. Assigns the two permission sets and creates three accounts and four contacts. +5. Saves the contact list view the way Studio does: GET, drop a column, PUT. The + save is stored as an overlay row that still carries `bulkActions`. +6. Records what 18.6.0 served for the reads the gate asserts on 19, then stops + the server and dumps the database. + +`OS_AUTH_SECRET` and `OS_SECRET_KEY` are fixed, published values (see +`FIXTURE_ENV`). They protect nothing; they let any runner open what 18.6.0 +sealed. diff --git a/packages/qa/upgrade-source/fixture-18.6.0/.gitignore b/packages/qa/upgrade-source/fixture-18.6.0/.gitignore new file mode 100644 index 00000000000..b937aab578c --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/.gitignore @@ -0,0 +1,7 @@ +node_modules +dist +.objectstack/ +*.log +.DS_Store +.env +.env.* diff --git a/packages/qa/upgrade-source/fixture-18.6.0/access-matrix.json b/packages/qa/upgrade-source/fixture-18.6.0/access-matrix.json new file mode 100644 index 00000000000..ac0748b6853 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/access-matrix.json @@ -0,0 +1,51 @@ +{ + "version": 1, + "entries": [ + { + "permissionSet": "crm18_auditor", + "object": "crm18_account", + "create": false, + "read": true, + "edit": false, + "delete": false, + "viewAllRecords": true, + "modifyAllRecords": false, + "sharingModel": "private" + }, + { + "permissionSet": "crm18_auditor", + "object": "crm18_contact", + "create": false, + "read": true, + "edit": true, + "delete": true, + "viewAllRecords": true, + "modifyAllRecords": true, + "sharingModel": "private" + }, + { + "permissionSet": "crm18_member", + "object": "crm18_account", + "create": false, + "read": true, + "edit": false, + "delete": false, + "viewAllRecords": false, + "modifyAllRecords": false, + "readScope": "org", + "sharingModel": "private" + }, + { + "permissionSet": "crm18_member", + "object": "crm18_contact", + "create": true, + "read": true, + "edit": true, + "delete": false, + "viewAllRecords": false, + "modifyAllRecords": false, + "readScope": "own", + "sharingModel": "private" + } + ] +} diff --git a/packages/qa/upgrade-source/fixture-18.6.0/objectstack.config.ts b/packages/qa/upgrade-source/fixture-18.6.0/objectstack.config.ts new file mode 100644 index 00000000000..2376d6bc27e --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/objectstack.config.ts @@ -0,0 +1,85 @@ +import { defineStack } from '@objectstack/spec'; +import { ConnectorRestPlugin } from '@objectstack/connector-rest'; +import { ConnectorOpenApiPlugin } from '@objectstack/connector-openapi'; +import { ConnectorMcpPlugin } from '@objectstack/connector-mcp'; +import * as objects from './src/objects'; +import * as views from './src/views'; +import * as actions from './src/actions'; +import * as flows from './src/flows'; +import * as dashboards from './src/dashboards'; +import * as apps from './src/apps'; +import * as skills from './src/skills'; +import * as picklists from './src/picklists'; +import * as permissions from './src/security'; +import * as datasets from './src/datasets'; + +// Every value a barrel exports, as the list a stack key takes: typed by what +// the barrel exports, and an empty list while it exports nothing yet. +const exportsOf = (barrel: M): M[keyof M][] => Object.values(barrel); + +// This file is a MODULE, and the whole module is the stack: the default +// export below is the base, and every NAMED export is merged onto it as a +// top-level stack key under its own name. A helper exported from here is +// therefore read as a stack key and the build refuses it — keep helpers in a +// sibling module and import them. Only names the stack schema declares +// (onEnable, functions, the collections) belong here as named exports. +export default defineStack({ + manifest: { + id: 'com.example.crm18', + namespace: 'crm18', + version: '0.1.0', + type: 'app', + name: 'Crm18', + // Protocol compatibility range: the metadata-protocol major this app is + // authored against. The runtime checks it before it loads anything, so a + // runtime outside the range refuses this app at the boundary with the exact + // migration command instead of crashing later. Scaffolding stamped it to + // match the ObjectStack version you installed — change it when you + // deliberately move to a new protocol major, not to silence a mismatch. + // Guide: https://objectstack.ai/docs/upgrading + engines: { protocol: '^18' }, + }, + + // `automation` backs flow execution and materializes any declarative + // `connectors:` entry into a live, dispatchable connector at boot. The + // connector executors below register their provider factories with it — + // without `automation` loaded they have nowhere to register and boot fails, + // so keep this capability whenever `plugins:` lists a connector. + // + // `triggers` fires a flow that starts on a record change, the kind + // `objectstack generate flow NAME` writes: without it this config stops + // loading once it holds such a flow. It can go if this project will never + // hold one. + requires: ['automation', 'triggers'], + + // Generic connector executors, default-present so you can add a `connectors:` + // entry naming `provider: 'rest' | 'openapi' | 'mcp'` and have it materialize + // with zero host code. Zero-arg = contribute the provider factory only. Brand + // connectors (Slack, …) stay marketplace/opt-in. + // Security: a declarative `mcp` stdio transport spawns a local process from + // metadata, so it is denied by default — opt in per host with + // `new ConnectorMcpPlugin({ declarativeStdio: [''] })`. + // Authoring guide: https://objectstack.ai/docs/automation/connectors + plugins: [ + new ConnectorRestPlugin(), + new ConnectorOpenApiPlugin(), + new ConnectorMcpPlugin(), + ], + + // Every directory `objectstack generate` writes into is wired here: its + // index.ts exports what the directory holds, and each list below hands + // those exports to the stack. `objectstack generate view NAME` adds a file + // and one export line, and the view is part of this stack with no edit to + // this file. A directory that is not wired here is never loaded, and + // `objectstack validate` neither counts nor checks what it holds. + objects: exportsOf(objects), + views: exportsOf(views), + actions: exportsOf(actions), + flows: exportsOf(flows), + dashboards: exportsOf(dashboards), + apps: exportsOf(apps), + skills: exportsOf(skills), + picklists: exportsOf(picklists), + permissions: exportsOf(permissions), + datasets: exportsOf(datasets), +}); diff --git a/packages/qa/upgrade-source/fixture-18.6.0/objectstack.manifest.json b/packages/qa/upgrade-source/fixture-18.6.0/objectstack.manifest.json new file mode 100644 index 00000000000..1877b8621bd --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/objectstack.manifest.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://schemas.objectstack.dev/template-manifest.json", + "namespace": "crm18", + "displayName": "Crm18", + "readmePath": "README.md" +} diff --git a/packages/qa/upgrade-source/fixture-18.6.0/package.json b/packages/qa/upgrade-source/fixture-18.6.0/package.json new file mode 100644 index 00000000000..2195806bbf4 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/package.json @@ -0,0 +1,38 @@ +{ + "name": "crm18", + "version": "0.1.0", + "private": true, + "type": "module", + "engines": { + "pnpm": ">=10.15" + }, + "scripts": { + "dev": "objectstack dev", + "start": "objectstack start", + "build": "objectstack build", + "deploy": "objectstack deploy", + "validate": "objectstack validate", + "lint": "objectstack lint", + "typecheck": "tsc --noEmit", + "test": "vitest run" + }, + "dependencies": { + "@objectstack/spec": "18.6.0", + "@objectstack/runtime": "18.6.0", + "@objectstack/plugin-hono-server": "18.6.0", + "@objectstack/connector-rest": "18.6.0", + "@objectstack/connector-openapi": "18.6.0", + "@objectstack/connector-mcp": "18.6.0" + }, + "devDependencies": { + "@objectstack/cli": "18.6.0", + "@objectstack/skills": "18.6.0", + "@objectstack/verify": "18.6.0", + "typescript": "^5.3.0", + "vitest": "~4.1.12" + }, + "overrides": { + "vitest": "~4.1.12", + "uuid@<12.0.0": "^11.1.1" + } +} diff --git a/packages/qa/upgrade-source/fixture-18.6.0/pnpm-workspace.yaml b/packages/qa/upgrade-source/fixture-18.6.0/pnpm-workspace.yaml new file mode 100644 index 00000000000..c2e34d1025e --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/pnpm-workspace.yaml @@ -0,0 +1,12 @@ +# Older pnpm needs this key; empty because this project is not a monorepo. +packages: [] + +# Build-script approvals for pnpm 10.0–10.25, which do not read allowBuilds. +onlyBuiltDependencies: + - better-sqlite3 + - esbuild + +# The same approvals for pnpm 10.26 and later; pnpm 11 reads only this key. +allowBuilds: + better-sqlite3: true + esbuild: true diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/actions/close_contact.action.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/actions/close_contact.action.ts new file mode 100644 index 00000000000..bb1978f710a --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/actions/close_contact.action.ts @@ -0,0 +1,16 @@ +import * as UI from '@objectstack/spec/ui'; + +/** + * Close Contact Action — offered on the contact list's selection bar through + * the view's `list.bulkActions` (an 18.x shape). + */ +const closeContactAction: UI.Action = { + name: 'crm18_close_contact', + label: 'Close Contact', + objectName: 'crm18_contact', + operation: 'update', + params: [{ field: 'status' }], + locations: ['record_header'], +}; + +export default closeContactAction; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/actions/flag_contact.action.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/actions/flag_contact.action.ts new file mode 100644 index 00000000000..c0068e5e47e --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/actions/flag_contact.action.ts @@ -0,0 +1,15 @@ +import * as UI from '@objectstack/spec/ui'; + +/** + * Flag Contact Action — a row action and a toolbar action. + */ +const flagContactAction: UI.Action = { + name: 'crm18_flag_contact', + label: 'Flag Contact', + objectName: 'crm18_contact', + operation: 'update', + params: [{ field: 'flagged' }], + locations: ['list_item', 'record_header'], +}; + +export default flagContactAction; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/actions/index.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/actions/index.ts new file mode 100644 index 00000000000..29f8d4f0eb4 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/actions/index.ts @@ -0,0 +1,8 @@ +// The actions in this directory. `objectstack generate action NAME` writes one +// here and adds its export line below. objectstack.config.ts hands every +// export of this file to the stack, so a action exported here is part of it, +// and a action file this index does not export is never loaded. +export {}; +export { default as markActive } from './mark_active.action'; +export { default as closeContact } from './close_contact.action'; +export { default as flagContact } from './flag_contact.action'; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/actions/mark_active.action.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/actions/mark_active.action.ts new file mode 100644 index 00000000000..c643d6bdc13 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/actions/mark_active.action.ts @@ -0,0 +1,16 @@ +import * as UI from '@objectstack/spec/ui'; + +/** + * Mark Active Action — offered on the account list's selection bar through + * the view's `list.bulkActions` (an 18.x shape). + */ +const markActiveAction: UI.Action = { + name: 'crm18_mark_active', + label: 'Mark Active', + objectName: 'crm18_account', + operation: 'update', + params: [{ field: 'status' }], + locations: ['record_header'], +}; + +export default markActiveAction; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/apps/index.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/apps/index.ts new file mode 100644 index 00000000000..5ee7a6bbd4f --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/apps/index.ts @@ -0,0 +1,10 @@ +// The apps in this directory. A package whose manifest type is 'app' +// holds at most one app: `objectstack generate app NAME` writes it here while +// there is none, and adds its export line below. Once there is one, put another +// object in the Console by adding a navigation entry for it to that app (a +// 'group' entry with children nests them) rather than a second app, or replace +// that app. objectstack.config.ts hands every export of this file to the stack, +// so an app exported here is part of it, and an app file this index does not +// export is never loaded. +export {}; +export { default as main } from './main.app'; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/apps/main.app.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/apps/main.app.ts new file mode 100644 index 00000000000..012d5204486 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/apps/main.app.ts @@ -0,0 +1,35 @@ +import * as UI from '@objectstack/spec/ui'; +import { Note } from '../objects/note.js'; + +/** + * Main App + */ +// This project's app: what the Console lists beside the platform's own apps, +// and what puts an object in the Console's navigation. An object no app lists +// is still served over REST and MCP, but the Console has no route to it. +// Written by `objectstack generate app main --object note`. A package whose +// manifest type is 'app' holds at most one app, so this is the one: to put +// another object in the Console, add a navigation entry for it below (a +// 'group' entry with children nests them) rather than a second app, and give +// it a list view — `objectstack generate view OBJECT` writes one. +// +// The sample object is referenced as `Note.name`, never as a typed-out string: +// scaffolding renamed it to carry this project's namespace. When you delete +// the sample `note` object, delete its entry below too. +const mainApp: UI.App = { + name: 'crm18_main_app', + label: 'Main', + navigation: [ + { + id: `${Note.name}_nav`, + type: 'object', + label: 'Notes', + objectName: Note.name, + }, + { id: 'crm18_account_nav', type: 'object', label: 'Accounts', objectName: 'crm18_account' }, + { id: 'crm18_contact_nav', type: 'object', label: 'Contacts', objectName: 'crm18_contact' }, + { id: 'crm18_overview_dashboard_nav', type: 'dashboard', dashboardName: 'crm18_overview_dashboard', label: 'Overview' }, + ], +}; + +export default mainApp; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/dashboards/index.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/dashboards/index.ts new file mode 100644 index 00000000000..438664b5c68 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/dashboards/index.ts @@ -0,0 +1,6 @@ +// The dashboards in this directory. `objectstack generate dashboard NAME` writes one +// here and adds its export line below. objectstack.config.ts hands every +// export of this file to the stack, so a dashboard exported here is part of it, +// and a dashboard file this index does not export is never loaded. +export {}; +export { default as overview } from './overview.dashboard'; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/dashboards/overview.dashboard.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/dashboards/overview.dashboard.ts new file mode 100644 index 00000000000..75a8425871c --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/dashboards/overview.dashboard.ts @@ -0,0 +1,21 @@ +import * as UI from '@objectstack/spec/ui'; + +/** + * Overview Dashboard + */ +const overviewDashboard: UI.Dashboard = { + name: 'crm18_overview_dashboard', + label: 'Overview Dashboard', + widgets: [ + { + id: 'accounts_total', + type: 'metric', + title: 'Accounts', + dataset: 'crm18_accounts_by_industry', + values: ['record_count'], + layout: { x: 0, y: 0, w: 3, h: 2 }, + }, + ], +}; + +export default overviewDashboard; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/datasets/accounts_by_industry.dataset.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/datasets/accounts_by_industry.dataset.ts new file mode 100644 index 00000000000..54c97d752f6 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/datasets/accounts_by_industry.dataset.ts @@ -0,0 +1,20 @@ +import { defineDataset } from '@objectstack/spec/ui'; + +/** + * Accounts by Industry — the numbers the overview dashboard shows. + */ +const accountsByIndustryDataset = defineDataset({ + name: 'crm18_accounts_by_industry', + label: 'Accounts by Industry', + object: 'crm18_account', + + dimensions: [ + { name: 'industry', field: 'industry', synonyms: ['Industry'] }, + ], + + measures: [ + { name: 'record_count', label: 'Records', aggregate: 'count', synonyms: ['Accounts'] }, + ], +}); + +export default accountsByIndustryDataset; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/datasets/index.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/datasets/index.ts new file mode 100644 index 00000000000..f0a7ff2b955 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/datasets/index.ts @@ -0,0 +1,6 @@ +// The datasets in this directory. `objectstack generate dataset NAME` writes one +// here and adds its export line below. objectstack.config.ts hands every +// export of this file to the stack, so a dataset exported here is part of it, +// and a dataset file this index does not export is never loaded. +export {}; +export { default as accountsByIndustry } from './accounts_by_industry.dataset'; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/flows/contact_created.flow.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/flows/contact_created.flow.ts new file mode 100644 index 00000000000..de22ad23716 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/flows/contact_created.flow.ts @@ -0,0 +1,44 @@ +import * as Automation from '@objectstack/spec/automation'; + +/** + * Contact Created Flow + * + * Starts when a record changes, so the stack that carries it must declare + * requires: ['automation', 'triggers']. The 'triggers' capability + * fires the flow and 'automation' runs it: without either one the config does + * not load. + */ +const contactCreatedFlow: Automation.Flow = { + name: 'crm18_contact_created_flow', + label: 'Contact Created Flow', + type: 'record_change', + // Armed: the trigger below fires it. Set 'obsolete' to switch it off. + status: 'active', + nodes: [ + { + id: 'start', + type: 'start', + label: 'Start', + // A record-change flow binds its trigger HERE, on the START node's + // config — there is no top-level `trigger` key. + // objectName the object whose writes fire this flow + // triggerType one record-{before,after}-{create,update,delete,write} + // token ('write' is create OR update, in one flow) + // condition optional bare-CEL gate, e.g. 'record.amount >= 500' + config: { + objectName: 'crm18_contact', + triggerType: 'record-after-write', + }, + }, + { + id: 'end', + type: 'end', + label: 'End', + }, + ], + edges: [ + { id: 'e1', source: 'start', target: 'end', type: 'default' }, + ], +}; + +export default contactCreatedFlow; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/flows/index.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/flows/index.ts new file mode 100644 index 00000000000..d544d1968da --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/flows/index.ts @@ -0,0 +1,6 @@ +// The flows in this directory. `objectstack generate flow NAME` writes one +// here and adds its export line below. objectstack.config.ts hands every +// export of this file to the stack, so a flow exported here is part of it, +// and a flow file this index does not export is never loaded. +export {}; +export { default as contactCreated } from './contact_created.flow'; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/objects/account.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/objects/account.ts new file mode 100644 index 00000000000..add457c2684 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/objects/account.ts @@ -0,0 +1,54 @@ +import { ObjectSchema, Field } from '@objectstack/spec/data'; + +/** + * Account Object — the master side of the contact master-detail. + */ +export const account = ObjectSchema.create({ + name: 'crm18_account', + label: 'Account', + pluralLabel: 'Accounts', + + fieldGroups: [ + { key: 'details', label: 'Details' }, + ], + + fields: { + name: Field.text({ + label: 'Name', + required: true, + maxLength: 255, + group: 'details', + }), + industry: Field.select(['technology', 'finance', 'retail'], { + label: 'Industry', + group: 'details', + }), + status: Field.select(['active', 'inactive'], { + label: 'Status', + defaultValue: 'inactive', + group: 'details', + }), + annual_revenue: Field.number({ + label: 'Annual Revenue', + group: 'details', + }), + notes: Field.textarea({ + label: 'Notes', + group: 'details', + }), + }, + + // A validation rule: TRUE means the record is invalid. + validations: [ + { + name: 'revenue_not_negative', + type: 'script', + condition: 'record.annual_revenue != null && record.annual_revenue < 0', + message: 'Annual revenue cannot be negative', + }, + ], + + sharingModel: 'private', +}); + +export default account; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/objects/contact.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/objects/contact.ts new file mode 100644 index 00000000000..ade63632f7b --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/objects/contact.ts @@ -0,0 +1,56 @@ +import { ObjectSchema, Field } from '@objectstack/spec/data'; + +/** + * Contact Object — the detail side of the account master-detail, with a + * second, plain lookup to the account that referred it. + */ +export const contact = ObjectSchema.create({ + name: 'crm18_contact', + label: 'Contact', + pluralLabel: 'Contacts', + + fieldGroups: [ + { key: 'details', label: 'Details' }, + { key: 'hr', label: 'HR' }, + ], + + fields: { + name: Field.text({ + label: 'Name', + required: true, + maxLength: 255, + group: 'details', + }), + account: Field.masterDetail('crm18_account', { + label: 'Account', + required: true, + group: 'details', + }), + referred_by: Field.lookup('crm18_account', { + label: 'Referred By', + group: 'details', + }), + email: Field.email({ + label: 'Email', + group: 'details', + }), + status: Field.select(['open', 'closed'], { + label: 'Status', + defaultValue: 'open', + group: 'details', + }), + flagged: Field.boolean({ + label: 'Flagged', + defaultValue: false, + group: 'details', + }), + salary: Field.number({ + label: 'Salary', + group: 'hr', + }), + }, + + sharingModel: 'private', +}); + +export default contact; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/objects/index.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/objects/index.ts new file mode 100644 index 00000000000..cad93721dea --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/objects/index.ts @@ -0,0 +1,3 @@ +export { Note } from './note.js'; +export { account } from './account'; +export { contact } from './contact'; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/objects/note.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/objects/note.ts new file mode 100644 index 00000000000..f481b8e2365 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/objects/note.ts @@ -0,0 +1,64 @@ +// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license. + +// SAMPLE OBJECT: delete or replace it once your own objects exist. +// +// `note` is here so a blank project has one object to boot, query and test +// on day one. It is not part of the app you are building: until you remove +// it, it ships in every build, is served over REST and is listed to MCP +// clients like any object of yours. The starter app (`src/apps/main.app.ts`) +// lists it, and `src/views/note.view.ts` draws its list, so the Console shows +// it on day one. To remove it, delete this file and its export line in +// `src/objects/index.ts`, delete `src/views/note.view.ts` and its export line +// in `src/views/index.ts`, and delete the `Notes` entry in +// `src/apps/main.app.ts`; then point `note.test.ts` at one of your own objects. +// All three import `Note` and will not compile until you do. +// The README's "The sample `note` object" section says the same. + +import { ObjectSchema, Field } from '@objectstack/spec/data'; + +export const Note = ObjectSchema.create({ + name: 'crm18_note', + label: 'Note', + pluralLabel: 'Notes', + icon: 'sticky-note', + description: 'A short note — the starter object for a blank environment.', + + // Field groups: the sections a note's form and detail page draw, top to + // bottom in this order. A field joins one by naming its `key` in `group`. + // That placement is what displays `body`. `objectstack validate` and + // `objectstack lint` report a field that nothing displays or reads + // (`field-no-consumers`) once the project holds a view, flow, dashboard or + // anything else that could read it, so give each field you add a `group` + // as well. Field groups versus a view's own form sections: + // https://objectstack.ai/docs/ui/field-grouping-and-order + fieldGroups: [ + { key: 'details', label: 'Details' }, + ], + + fields: { + title: Field.text({ + label: 'Title', + required: true, + searchable: true, + maxLength: 200, + group: 'details', + }), + body: Field.textarea({ + label: 'Body', + group: 'details', + }), + }, + + // Org-wide default (OWD): who can see records they don't own. `private` is + // owner-only until access is widened by a permission grant or a sharing rule. + // Declaring it is required, deliberately: `objectstack build` refuses an + // object that declares no OWD, so the baseline is always an authored decision + // rather than an accident. The other values, and how to widen access safely: + // https://objectstack.ai/docs/permissions/sharing-rules + sharingModel: 'private', + + enable: { + apiEnabled: true, + searchable: true, + }, +}); diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/picklists/index.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/picklists/index.ts new file mode 100644 index 00000000000..346a371a9ee --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/picklists/index.ts @@ -0,0 +1,5 @@ +// The picklists in this directory. `objectstack generate picklist NAME` writes one +// here and adds its export line below. objectstack.config.ts hands every +// export of this file to the stack, so a picklist exported here is part of it, +// and a picklist file this index does not export is never loaded. +export {}; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/security/auditor.permission.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/security/auditor.permission.ts new file mode 100644 index 00000000000..48a1f2aa095 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/security/auditor.permission.ts @@ -0,0 +1,36 @@ +import { definePermissionSet } from '@objectstack/spec/security'; + +/** + * Auditor Permission Set — View All and Modify All on contacts, and the set's + * own field row hiding `salary`. On 18 the two "all" bits re-open the field; + * on 19 the set's own row is its whole say on that field (the ruled + * record-axis / field-axis split). + */ +const auditorPermissionSet = definePermissionSet({ + name: 'crm18_auditor', + label: 'Auditor', + + objects: { + 'crm18_account': { + allowRead: true, + allowCreate: false, + allowEdit: false, + allowDelete: false, + viewAllRecords: true, + }, + 'crm18_contact': { + allowRead: true, + allowCreate: false, + allowEdit: true, + allowDelete: true, + viewAllRecords: true, + modifyAllRecords: true, + }, + }, + + fields: { + 'crm18_contact.salary': { readable: false, editable: false }, + }, +}); + +export default auditorPermissionSet; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/security/index.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/security/index.ts new file mode 100644 index 00000000000..179e1c3332a --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/security/index.ts @@ -0,0 +1,7 @@ +// The permissions in this directory. `objectstack generate permission NAME` writes one +// here and adds its export line below. objectstack.config.ts hands every +// export of this file to the stack, so a permission exported here is part of it, +// and a permission file this index does not export is never loaded. +export {}; +export { default as member } from './member.permission'; +export { default as auditor } from './auditor.permission'; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/security/member.permission.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/security/member.permission.ts new file mode 100644 index 00000000000..48aae8037cb --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/security/member.permission.ts @@ -0,0 +1,32 @@ +import { definePermissionSet } from '@objectstack/spec/security'; + +/** + * Member Permission Set — works its own contacts; the account notes are hidden. + */ +const memberPermissionSet = definePermissionSet({ + name: 'crm18_member', + label: 'Member', + + objects: { + 'crm18_account': { + allowRead: true, + allowCreate: false, + allowEdit: false, + allowDelete: false, + readScope: 'org', + }, + 'crm18_contact': { + allowRead: true, + allowCreate: true, + allowEdit: true, + allowDelete: false, + readScope: 'own', + }, + }, + + fields: { + 'crm18_account.notes': { readable: false, editable: false }, + }, +}); + +export default memberPermissionSet; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/skills/index.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/skills/index.ts new file mode 100644 index 00000000000..013da9c6bf6 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/skills/index.ts @@ -0,0 +1,5 @@ +// The skills in this directory. `objectstack generate skill NAME` writes one +// here and adds its export line below. objectstack.config.ts hands every +// export of this file to the stack, so a skill exported here is part of it, +// and a skill file this index does not export is never loaded. +export {}; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/views/account.view.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/views/account.view.ts new file mode 100644 index 00000000000..df3432edc06 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/views/account.view.ts @@ -0,0 +1,23 @@ +import * as UI from '@objectstack/spec/ui'; + +/** + * Account Views + */ +const accountViews: UI.View = { + object: 'crm18_account', + list: { + label: 'All Accounts', + type: 'grid', + columns: [ + { field: 'name' }, + { field: 'industry' }, + { field: 'status' }, + { field: 'annual_revenue' }, + ], + sort: [{ field: 'name', order: 'asc' }], + pagination: { pageSize: 25 }, + bulkActions: ['crm18_mark_active'], + }, +}; + +export default accountViews; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/views/contact.view.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/views/contact.view.ts new file mode 100644 index 00000000000..7f6cfaabbe5 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/views/contact.view.ts @@ -0,0 +1,24 @@ +import * as UI from '@objectstack/spec/ui'; + +/** + * Contact Views + */ +const contactViews: UI.View = { + object: 'crm18_contact', + list: { + label: 'All Contacts', + type: 'grid', + columns: [ + { field: 'name' }, + { field: 'account' }, + { field: 'email' }, + { field: 'status' }, + { field: 'salary' }, + ], + sort: [{ field: 'name', order: 'asc' }], + pagination: { pageSize: 25 }, + bulkActions: ['crm18_close_contact', 'crm18_flag_contact'], + }, +}; + +export default contactViews; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/views/index.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/views/index.ts new file mode 100644 index 00000000000..9780eab8bff --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/views/index.ts @@ -0,0 +1,8 @@ +// The views in this directory. `objectstack generate view NAME` writes one +// here and adds its export line below. objectstack.config.ts hands every +// export of this file to the stack, so a view exported here is part of it, +// and a view file this index does not export is never loaded. +export {}; +export { default as note } from './note.view'; +export { default as account } from './account.view'; +export { default as contact } from './contact.view'; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/src/views/note.view.ts b/packages/qa/upgrade-source/fixture-18.6.0/src/views/note.view.ts new file mode 100644 index 00000000000..b8abf8b13a7 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/src/views/note.view.ts @@ -0,0 +1,29 @@ +import * as UI from '@objectstack/spec/ui'; +import { Note } from '../objects/note.js'; + +/** + * Note Views + */ +// The list the Console opens when the `Notes` entry of `src/apps/main.app.ts` +// is clicked. Written by `objectstack generate view note`. The sample object +// is referenced as `Note.name`, never as a typed-out string: scaffolding +// renamed it to carry this project's namespace. When you delete the sample +// `note` object, delete this file and its export line in `src/views/index.ts`. +const noteViews: UI.View = { + // A views container is registered under the object it binds to: `object` + // is its identity, so it declares no `name` or `label` of its own. The + // label people see is the list view's, below. + object: Note.name, + list: { + label: 'All Notes', + type: 'grid', + columns: [ + { field: 'title' }, + { field: 'body' }, + ], + sort: [{ field: 'title', order: 'asc' }], + pagination: { pageSize: 25 }, + }, +}; + +export default noteViews; diff --git a/packages/qa/upgrade-source/fixture-18.6.0/tsconfig.json b/packages/qa/upgrade-source/fixture-18.6.0/tsconfig.json new file mode 100644 index 00000000000..f529ef6f765 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-18.6.0/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ESNext", + "moduleResolution": "bundler", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "resolveJsonModule": true, + "allowImportingTsExtensions": false, + "noEmit": true, + "isolatedModules": true + }, + "include": ["*.ts", "src/**/*"] +} diff --git a/packages/qa/upgrade-source/fixture-db-18.6.0/database.sql b/packages/qa/upgrade-source/fixture-db-18.6.0/database.sql new file mode 100644 index 00000000000..9c7142256ec --- /dev/null +++ b/packages/qa/upgrade-source/fixture-db-18.6.0/database.sql @@ -0,0 +1,590 @@ +PRAGMA foreign_keys=OFF; +BEGIN TRANSACTION; +CREATE TABLE `crm18_account` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `owner_id` varchar(255), `owning_business_unit_id` varchar(255), `queue` text, `name` text, `industry` varchar(255), `status` varchar(255) default 'inactive', `annual_revenue` float, `notes` text, primary key (`id`)); +INSERT INTO "crm18_account" ("id","created_at","updated_at","organization_id","created_by","updated_by","owner_id","owning_business_unit_id","queue","name","industry","status","annual_revenue","notes") VALUES('Za0K_bLbuHot3bok','2026-12-02T15:14:35.165Z','2026-12-02T15:14:35.165Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8',NULL,NULL,'Acme','technology','active',1200000,'Key account, renewal in Q1'); +INSERT INTO "crm18_account" ("id","created_at","updated_at","organization_id","created_by","updated_by","owner_id","owning_business_unit_id","queue","name","industry","status","annual_revenue","notes") VALUES('NuOyrbcsb9xZeIr5','2026-12-02T15:14:35.197Z','2026-12-02T15:14:35.197Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8',NULL,NULL,'Globex','finance','inactive',500000,'Paused after the audit'); +INSERT INTO "crm18_account" ("id","created_at","updated_at","organization_id","created_by","updated_by","owner_id","owning_business_unit_id","queue","name","industry","status","annual_revenue","notes") VALUES('cMYxu_0801wJ6HmI','2026-12-02T15:14:35.229Z','2026-12-02T15:14:35.229Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8',NULL,NULL,'Initech','retail','inactive',75000,'Small, steady'); +CREATE TABLE `crm18_contact` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `owner_id` varchar(255), `owning_business_unit_id` varchar(255), `queue` text, `name` text, `account` varchar(255), `referred_by` varchar(255), `email` varchar(255), `status` varchar(255) default 'open', `flagged` boolean default '0', `salary` float, primary key (`id`)); +INSERT INTO "crm18_contact" ("id","created_at","updated_at","organization_id","created_by","updated_by","owner_id","owning_business_unit_id","queue","name","account","referred_by","email","status","flagged","salary") VALUES('P3kqdaCWIjxsAUkq','2026-12-02T15:14:35.261Z','2026-12-02T15:14:35.261Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8',NULL,NULL,'Ada Lovelace','Za0K_bLbuHot3bok',NULL,'ada@acme.test','open',0,150000); +INSERT INTO "crm18_contact" ("id","created_at","updated_at","organization_id","created_by","updated_by","owner_id","owning_business_unit_id","queue","name","account","referred_by","email","status","flagged","salary") VALUES('C7o2WVeswVQxUsXD','2026-12-02T15:14:35.308Z','2026-12-02T15:14:35.308Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8',NULL,NULL,'Grace Hopper','Za0K_bLbuHot3bok','NuOyrbcsb9xZeIr5','grace@acme.test','open',0,140000); +INSERT INTO "crm18_contact" ("id","created_at","updated_at","organization_id","created_by","updated_by","owner_id","owning_business_unit_id","queue","name","account","referred_by","email","status","flagged","salary") VALUES('dFhmYYU80eElB6nd','2026-12-02T15:14:35.345Z','2026-12-02T15:14:35.345Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8',NULL,NULL,'Linus Pauling','NuOyrbcsb9xZeIr5',NULL,'linus@globex.test','open',0,120000); +INSERT INTO "crm18_contact" ("id","created_at","updated_at","organization_id","created_by","updated_by","owner_id","owning_business_unit_id","queue","name","account","referred_by","email","status","flagged","salary") VALUES('4Vo9mRADteWIDPlW','2026-12-02T15:14:35.388Z','2026-12-02T15:14:35.388Z','org_mx69o0q4fm2fxl02','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7',NULL,NULL,'Margaret Hamilton','cMYxu_0801wJ6HmI',NULL,'margaret@initech.test','open',0,90000); +CREATE TABLE `crm18_note` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `owner_id` varchar(255), `owning_business_unit_id` varchar(255), `queue` text, `title` text, `body` text, primary key (`id`)); +CREATE TABLE `sys_account` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `provider_id` varchar(255), `account_id` varchar(256), `user_id` varchar(255), `access_token` text, `refresh_token` text, `id_token` text, `access_token_expires_at` datetime, `refresh_token_expires_at` datetime, `scope` text, `password` text, `previous_password_hashes` text, primary key (`id`)); +INSERT INTO "sys_account" ("id","created_at","updated_at","provider_id","account_id","user_id","access_token","refresh_token","id_token","access_token_expires_at","refresh_token_expires_at","scope","password","previous_password_hashes") VALUES('1Pod1naohEIGM5TKL3uUxsyALYiPIhPR','2026-12-02T15:14:23.062Z','2026-12-02T15:14:23.062Z','credential','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8',NULL,NULL,NULL,NULL,NULL,NULL,'365c3cadd6e0cb317d7d5ad0edcd7918:d138e88fe524941500b1afb4203dfece1d6df472961cd02f630891422a3edf868100759503a59977767e956142c1be6d4e801c55b18f6cd74283c8ecea28b792',NULL); +INSERT INTO "sys_account" ("id","created_at","updated_at","provider_id","account_id","user_id","access_token","refresh_token","id_token","access_token_expires_at","refresh_token_expires_at","scope","password","previous_password_hashes") VALUES('vQ9G4iJbeGvbnJQW7QZv7FCZo0pjlmbE','2026-12-02T15:14:23.327Z','2026-12-02T15:14:23.926Z','credential','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7',NULL,NULL,NULL,NULL,NULL,NULL,'a0871f7666b9a708933b9822807652de:d0eb23da78fbb989269ac09b1ddcec1b73a4caf7a9c18fa670261b5de23a9a98b551720df925e56c2b9b82d551ade9036957d30e78c415c25356c21315e7754b',NULL); +INSERT INTO "sys_account" ("id","created_at","updated_at","provider_id","account_id","user_id","access_token","refresh_token","id_token","access_token_expires_at","refresh_token_expires_at","scope","password","previous_password_hashes") VALUES('Tgk9s4tZT13Yk2jwiUsXEptx1bkfpOPT','2026-12-02T15:14:24.245Z','2026-12-02T15:14:24.839Z','credential','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF',NULL,NULL,NULL,NULL,NULL,NULL,'dc0d78e48835e2786e3e42eebead2fc3:7fcd8af6e24ba32a3efb7e3a6dab99ada1e17fba33c1b3e99c4cf39fda358f6ad461c7971f2743833c07f1162455277382c9506596647df4ef57882c351f3964',NULL); +CREATE TABLE `sys_activity__r20261202` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `timestamp` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `type` varchar(255), `summary` text, `actor_id` varchar(255), `actor_name` text, `actor_avatar_url` varchar(255), `object_name` varchar(255), `record_id` varchar(255), `record_label` text, `source_object` text, `source_id` text, `url` varchar(255), `environment_id` varchar(255), `metadata` text, `origin` text, `changed_fields` text, `milestone_key` text, primary key (`id`)); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('g71flkpp6Y9ms6Gn','2026-12-02T15:14:22.160Z','2026-12-02T15:14:22.160Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:22.154Z','created','Created Platform Setting "api_key_policy_started_at"',NULL,NULL,NULL,'sys_platform_setting','KdXx5J2BTv_SUJM7','api_key_policy_started_at',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"KdXx5J2BTv_SUJM7","created_at":"2026-12-02T15:14:22.148Z","updated_at":"2026-12-02T15:14:22.148Z","created_by":null,"namespace":"auth","key":"api_key_policy_started_at","value":"2026-12-02T15:14:22.123Z","encrypted":false,"locked":false,"locked_reason":null,"updated_by":null},"text_sources":{"summary":["key"],"record_label":["key"]},"summary_message":{"key":"activityCreated","object":"sys_platform_setting","label":"api_key_policy_started_at"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('AqSO7QRra9NRBpMT','2026-12-02T15:14:22.170Z','2026-12-02T15:14:22.170Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:22.167Z','created','Created Platform Setting Audit Entry "rqmDXgbXwyu0yG3S"',NULL,NULL,NULL,'sys_platform_setting_audit','rqmDXgbXwyu0yG3S','rqmDXgbXwyu0yG3S',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"rqmDXgbXwyu0yG3S","created_at":"2026-12-02T15:14:22.166Z","updated_at":"2026-12-02T15:14:22.166Z","created_by":null,"updated_by":null,"namespace":"auth","key":"api_key_policy_started_at","scope":"global","action":"set","actor_id":null,"source":"api","reason":null,"old_hash":null,"new_hash":"sha256:5e48eb605ea9209a85ae6e404d5e01c6705a4004e5f7768d9a7bfa50e06adf46","encrypted":false,"request_id":null},"text_sources":{"summary":[],"record_label":[]},"summary_message":{"key":"activityCreated","object":"sys_platform_setting_audit","label":"rqmDXgbXwyu0yG3S"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('ZFatIRlAPJ1VZNVm','2026-12-02T15:14:23.031Z','2026-12-02T15:14:23.031Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.023Z','created','Created User "Owner"',NULL,NULL,NULL,'sys_user','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","created_at":"2026-12-02T15:14:23.020Z","updated_at":"2026-12-02T15:14:23.020Z","name":"Owner","email":"owner@crm18.test","email_verified":false,"two_factor_enabled":false,"role":"user","banned":false,"ban_reason":null,"ban_expires":null,"failed_login_count":0,"locked_until":null,"password_changed_at":null,"phone_number":null,"phone_number_verified":false,"must_change_password":false,"mfa_required_at":null,"last_login_at":null,"last_login_ip":null,"ai_access":false,"principal_kind":"human","accountable_user_id":null,"image":null,"locale":null,"manager_id":null,"primary_business_unit_id":null,"source":"env_native"},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"sys_user","label":"Owner"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('fYK-2Bo1VHyy05L9','2026-12-02T15:14:23.082Z','2026-12-02T15:14:23.082Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.080Z','created','Created User Permission Set "Owner → admin_full_access"',NULL,NULL,NULL,'sys_user_permission_set','ups_mx69o1y9dsixh1ek','Owner → admin_full_access',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"ups_mx69o1y9dsixh1ek","created_at":"2026-12-02T15:14:23.074Z","updated_at":"2026-12-02T15:14:23.074Z","created_by":null,"updated_by":null,"user_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","permission_set":"admin_full_access","organization_id":"org_mx69o0q4fm2fxl02","permission_set_package":"com.objectstack.plugin-security","granted_by":null,"valid_from":null,"valid_until":null,"reason":null,"last_certified_at":null,"certified_by":null},"text_sources":{"summary":["display_title"],"record_label":["display_title"]},"summary_message":{"key":"activityCreated","object":"sys_user_permission_set","label":"Owner → admin_full_access"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('n7qqMArlXKpB2qFi','2026-12-02T15:14:23.095Z','2026-12-02T15:14:23.095Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.093Z','created','Created Member "Owner (owner)"',NULL,NULL,NULL,'sys_member','mem_mx69o1ypy4ozz8g7','Owner (owner)',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"mem_mx69o1ypy4ozz8g7","created_at":"2026-12-02T15:14:23.090Z","updated_at":"2026-12-02T15:14:23.090Z","organization_id":"org_mx69o0q4fm2fxl02","user_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","role":"owner"},"text_sources":{"summary":["display_title"],"record_label":["display_title"]},"summary_message":{"key":"activityCreated","object":"sys_member","label":"Owner (owner)"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('CfnL8ku2MCWjxaji','2026-12-02T15:14:23.107Z','2026-12-02T15:14:23.107Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.106Z','created','Created User Permission Set "Owner → organization_admin_no_bypass"',NULL,NULL,NULL,'sys_user_permission_set','ups_mx69o1z2cfb821nx','Owner → organization_admin_no_bypass',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"ups_mx69o1z2cfb821nx","created_at":"2026-12-02T15:14:23.102Z","updated_at":"2026-12-02T15:14:23.102Z","created_by":null,"updated_by":null,"user_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","permission_set":"organization_admin_no_bypass","organization_id":"org_mx69o0q4fm2fxl02","permission_set_package":"com.objectstack.plugin-security","granted_by":null,"valid_from":null,"valid_until":null,"reason":"auto-org-admin-grant: granted from membership grade ''owner'' (sys_member mem_mx69o1ypy4ozz8g7) → organization_admin_no_bypass","last_certified_at":null,"certified_by":null},"text_sources":{"summary":["display_title"],"record_label":["display_title"]},"summary_message":{"key":"activityCreated","object":"sys_user_permission_set","label":"Owner → organization_admin_no_bypass"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('Nfk9JjCGGp4UuQKf','2026-12-02T15:14:23.119Z','2026-12-02T15:14:23.119Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.116Z','created','Created Data Migration "adr-0093-default-org-owner-bind"',NULL,NULL,NULL,'sys_migration','adr-0093-default-org-owner-bind','adr-0093-default-org-owner-bind',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"adr-0093-default-org-owner-bind","created_at":"2026-12-02T15:14:23.115Z","updated_at":"2026-12-02T15:14:23.115Z","created_by":null,"updated_by":null,"last_run_at":"2026-12-02T15:14:23.115Z","verified_at":null,"applied_at":"2026-12-02T15:14:23.115Z","blocking":0,"advisory":null,"details":"{\"outcome\":\"bound\",\"organizationId\":\"org_mx69o0q4fm2fxl02\"}","deviation_observed_at":null,"deviation_detail":null,"columns_moved_at":null},"text_sources":{"summary":[],"record_label":[]},"summary_message":{"key":"activityCreated","object":"sys_migration","label":"adr-0093-default-org-owner-bind"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('SQzYyjqcDDjg7o_g','2026-12-02T15:14:23.174Z','2026-12-02T15:14:23.174Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.172Z','updated','Updated User "Owner": Password Changed At',NULL,NULL,NULL,'sys_user','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,NULL,NULL,NULL,'{"old":{"password_changed_at":null},"new":{"password_changed_at":"2026-12-02T15:14:23.164Z"},"text_sources":{"summary":["name","password_changed_at"],"record_label":["name"]},"summary_message":{"key":"activityUpdatedFields","object":"sys_user","label":"Owner","fields":["password_changed_at"],"more":0}}',NULL,'["password_changed_at"]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('p4hjj1kcK3wxOv-p','2026-12-02T15:14:23.208Z','2026-12-02T15:14:23.208Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.206Z','created','Created User "Member"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','Member',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","created_at":"2026-12-02T15:14:23.203Z","updated_at":"2026-12-02T15:14:23.203Z","name":"Member","email":"member@crm18.test","email_verified":false,"two_factor_enabled":false,"role":"user","banned":false,"ban_reason":null,"ban_expires":null,"failed_login_count":0,"locked_until":null,"password_changed_at":null,"phone_number":null,"phone_number_verified":false,"must_change_password":false,"mfa_required_at":null,"last_login_at":null,"last_login_ip":null,"ai_access":false,"principal_kind":"human","accountable_user_id":null,"image":null,"locale":null,"manager_id":null,"primary_business_unit_id":null,"source":"env_native"},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"sys_user","label":"Member"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('HMrnoExmtCqZKeGc','2026-12-02T15:14:23.225Z','2026-12-02T15:14:23.225Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.224Z','created','Created Member "Member (member)"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'sys_member','mem_mx69o22ewrdpthu3','Member (member)',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"mem_mx69o22ewrdpthu3","created_at":"2026-12-02T15:14:23.222Z","updated_at":"2026-12-02T15:14:23.222Z","organization_id":"org_mx69o0q4fm2fxl02","user_id":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","role":"member"},"text_sources":{"summary":["display_title"],"record_label":["display_title"]},"summary_message":{"key":"activityCreated","object":"sys_member","label":"Member (member)"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('YdT7LFIBFTNC6rGP','2026-12-02T15:14:23.341Z','2026-12-02T15:14:23.341Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.339Z','updated','Updated User "Member": Must Change Password','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','Member',NULL,NULL,NULL,NULL,'{"old":{"must_change_password":false},"new":{"must_change_password":true},"text_sources":{"summary":["name","must_change_password"],"record_label":["name"]},"summary_message":{"key":"activityUpdatedFields","object":"sys_user","label":"Member","fields":["must_change_password"],"more":0}}',NULL,'["must_change_password"]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('CKvRtMzySHWi0aDM','2026-12-02T15:14:23.481Z','2026-12-02T15:14:23.481Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.479Z','updated','Updated User "Member": Last Login At and Last Login IP','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','Member',NULL,'sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','Member',NULL,NULL,NULL,NULL,'{"old":{"last_login_at":null,"last_login_ip":null},"new":{"last_login_at":"2026-12-02T15:14:23.474Z","last_login_ip":"127.0.0.1"},"text_sources":{"summary":["name","last_login_at","last_login_ip"],"record_label":["name"]},"summary_message":{"key":"activityUpdatedFields","object":"sys_user","label":"Member","fields":["last_login_at","last_login_ip"],"more":0}}',NULL,'["last_login_at","last_login_ip"]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('5lEED8KyKdHzBp10','2026-12-02T15:14:23.943Z','2026-12-02T15:14:23.943Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:23.931Z','updated','Updated User "Member": Password Changed At and Must Change Password','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','Member',NULL,'sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','Member',NULL,NULL,NULL,NULL,'{"old":{"password_changed_at":null,"must_change_password":true},"new":{"password_changed_at":"2026-12-02T15:14:23.928Z","must_change_password":false},"text_sources":{"summary":["name","password_changed_at","must_change_password"],"record_label":["name"]},"summary_message":{"key":"activityUpdatedFields","object":"sys_user","label":"Member","fields":["password_changed_at","must_change_password"],"more":0}}',NULL,'["must_change_password","password_changed_at"]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('RjwSmBvp5D0RTdFL','2026-12-02T15:14:24.101Z','2026-12-02T15:14:24.101Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:24.098Z','updated','Updated User "Member": Last Login At','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','Member',NULL,'sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','Member',NULL,NULL,NULL,NULL,'{"old":{"last_login_at":"2026-12-02T15:14:23.474Z"},"new":{"last_login_at":"2026-12-02T15:14:24.095Z"},"text_sources":{"summary":["name","last_login_at"],"record_label":["name"]},"summary_message":{"key":"activityUpdatedFields","object":"sys_user","label":"Member","fields":["last_login_at"],"more":0}}',NULL,'["last_login_at"]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('rLagRoAabP05Ndji','2026-12-02T15:14:24.126Z','2026-12-02T15:14:24.126Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:24.123Z','created','Created User "Auditor"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','Auditor',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF","created_at":"2026-12-02T15:14:24.122Z","updated_at":"2026-12-02T15:14:24.122Z","name":"Auditor","email":"auditor@crm18.test","email_verified":false,"two_factor_enabled":false,"role":"user","banned":false,"ban_reason":null,"ban_expires":null,"failed_login_count":0,"locked_until":null,"password_changed_at":null,"phone_number":null,"phone_number_verified":false,"must_change_password":false,"mfa_required_at":null,"last_login_at":null,"last_login_ip":null,"ai_access":false,"principal_kind":"human","accountable_user_id":null,"image":null,"locale":null,"manager_id":null,"primary_business_unit_id":null,"source":"env_native"},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"sys_user","label":"Auditor"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('NAB10raf9sLhYMI3','2026-12-02T15:14:24.149Z','2026-12-02T15:14:24.149Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:24.148Z','created','Created Member "Auditor (member)"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'sys_member','mem_mx69o2s1tlsx8800','Auditor (member)',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"mem_mx69o2s1tlsx8800","created_at":"2026-12-02T15:14:24.146Z","updated_at":"2026-12-02T15:14:24.146Z","organization_id":"org_mx69o0q4fm2fxl02","user_id":"1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF","role":"member"},"text_sources":{"summary":["display_title"],"record_label":["display_title"]},"summary_message":{"key":"activityCreated","object":"sys_member","label":"Auditor (member)"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('rg4Gq8d22bDP-DVY','2026-12-02T15:14:24.257Z','2026-12-02T15:14:24.257Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:24.255Z','updated','Updated User "Auditor": Must Change Password','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','Auditor',NULL,NULL,NULL,NULL,'{"old":{"must_change_password":false},"new":{"must_change_password":true},"text_sources":{"summary":["name","must_change_password"],"record_label":["name"]},"summary_message":{"key":"activityUpdatedFields","object":"sys_user","label":"Auditor","fields":["must_change_password"],"more":0}}',NULL,'["must_change_password"]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('tJZaRZH_WWUJ6bdh','2026-12-02T15:14:24.409Z','2026-12-02T15:14:24.409Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:24.406Z','updated','Updated User "Auditor": Last Login At and Last Login IP','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','Auditor',NULL,'sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','Auditor',NULL,NULL,NULL,NULL,'{"old":{"last_login_at":null,"last_login_ip":null},"new":{"last_login_at":"2026-12-02T15:14:24.404Z","last_login_ip":"127.0.0.1"},"text_sources":{"summary":["name","last_login_at","last_login_ip"],"record_label":["name"]},"summary_message":{"key":"activityUpdatedFields","object":"sys_user","label":"Auditor","fields":["last_login_at","last_login_ip"],"more":0}}',NULL,'["last_login_at","last_login_ip"]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('K0HBfq1pffykoG3c','2026-12-02T15:14:24.846Z','2026-12-02T15:14:24.846Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:24.843Z','updated','Updated User "Auditor": Password Changed At and Must Change Password','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','Auditor',NULL,'sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','Auditor',NULL,NULL,NULL,NULL,'{"old":{"password_changed_at":null,"must_change_password":true},"new":{"password_changed_at":"2026-12-02T15:14:24.841Z","must_change_password":false},"text_sources":{"summary":["name","password_changed_at","must_change_password"],"record_label":["name"]},"summary_message":{"key":"activityUpdatedFields","object":"sys_user","label":"Auditor","fields":["password_changed_at","must_change_password"],"more":0}}',NULL,'["must_change_password","password_changed_at"]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('jYrTS0q4PY2fVjgo','2026-12-02T15:14:35.018Z','2026-12-02T15:14:35.018Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:35.016Z','updated','Updated User "Auditor": Last Login At','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','Auditor',NULL,'sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','Auditor',NULL,NULL,NULL,NULL,'{"old":{"last_login_at":"2026-12-02T15:14:24.404Z"},"new":{"last_login_at":"2026-12-02T15:14:35.014Z"},"text_sources":{"summary":["name","last_login_at"],"record_label":["name"]},"summary_message":{"key":"activityUpdatedFields","object":"sys_user","label":"Auditor","fields":["last_login_at"],"more":0}}',NULL,'["last_login_at"]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('VKHs8grbyGzd8Sey','2026-12-02T15:14:35.093Z','2026-12-02T15:14:35.093Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-02T15:14:35.091Z','created','Created User Permission Set "Member → crm18_member"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'sys_user_permission_set','zPvFJMFMTDciSum6','Member → crm18_member',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"zPvFJMFMTDciSum6","created_at":"2026-12-02T15:14:35.077Z","updated_at":"2026-12-02T15:14:35.077Z","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","user_id":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","permission_set":"crm18_member","organization_id":"org_mx69o0q4fm2fxl02","permission_set_package":"com.example.crm18","granted_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","valid_from":null,"valid_until":null,"reason":null,"last_certified_at":null,"certified_by":null},"text_sources":{"summary":["display_title"],"record_label":["display_title"]},"summary_message":{"key":"activityCreated","object":"sys_user_permission_set","label":"Member → crm18_member"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('AYwRB1iCtEmI3xws','2026-12-02T15:14:35.132Z','2026-12-02T15:14:35.132Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-02T15:14:35.131Z','created','Created User Permission Set "Auditor → crm18_auditor"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'sys_user_permission_set','mqpjWWjiULAXBZs7','Auditor → crm18_auditor',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"mqpjWWjiULAXBZs7","created_at":"2026-12-02T15:14:35.123Z","updated_at":"2026-12-02T15:14:35.123Z","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","user_id":"1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF","permission_set":"crm18_auditor","organization_id":"org_mx69o0q4fm2fxl02","permission_set_package":"com.example.crm18","granted_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","valid_from":null,"valid_until":null,"reason":null,"last_certified_at":null,"certified_by":null},"text_sources":{"summary":["display_title"],"record_label":["display_title"]},"summary_message":{"key":"activityCreated","object":"sys_user_permission_set","label":"Auditor → crm18_auditor"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('XVgGkjuodadFTN21','2026-12-02T15:14:35.168Z','2026-12-02T15:14:35.168Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-02T15:14:35.166Z','created','Created Account "Acme"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'crm18_account','Za0K_bLbuHot3bok','Acme',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"Za0K_bLbuHot3bok","created_at":"2026-12-02T15:14:35.165Z","updated_at":"2026-12-02T15:14:35.165Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Acme","industry":"technology","status":"active","annual_revenue":1200000,"notes":"Key account, renewal in Q1"},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"crm18_account","label":"Acme"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('5v1RNisbsBnRDgVi','2026-12-02T15:14:35.200Z','2026-12-02T15:14:35.200Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-02T15:14:35.198Z','created','Created Account "Globex"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'crm18_account','NuOyrbcsb9xZeIr5','Globex',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"NuOyrbcsb9xZeIr5","created_at":"2026-12-02T15:14:35.197Z","updated_at":"2026-12-02T15:14:35.197Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Globex","industry":"finance","status":"inactive","annual_revenue":500000,"notes":"Paused after the audit"},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"crm18_account","label":"Globex"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('zN-Lb_omfUSnxNqm','2026-12-02T15:14:35.233Z','2026-12-02T15:14:35.233Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-02T15:14:35.231Z','created','Created Account "Initech"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'crm18_account','cMYxu_0801wJ6HmI','Initech',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"cMYxu_0801wJ6HmI","created_at":"2026-12-02T15:14:35.229Z","updated_at":"2026-12-02T15:14:35.229Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Initech","industry":"retail","status":"inactive","annual_revenue":75000,"notes":"Small, steady"},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"crm18_account","label":"Initech"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('-WHzagdjpbEuxzfV','2026-12-02T15:14:35.267Z','2026-12-02T15:14:35.267Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-02T15:14:35.265Z','created','Created Contact "Ada Lovelace"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'crm18_contact','P3kqdaCWIjxsAUkq','Ada Lovelace',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"P3kqdaCWIjxsAUkq","created_at":"2026-12-02T15:14:35.261Z","updated_at":"2026-12-02T15:14:35.261Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Ada Lovelace","account":"Za0K_bLbuHot3bok","referred_by":null,"email":"ada@acme.test","status":"open","flagged":false,"salary":150000},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"crm18_contact","label":"Ada Lovelace"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('bdHukR89U6E_4A5r','2026-12-02T15:14:35.313Z','2026-12-02T15:14:35.313Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-02T15:14:35.312Z','created','Created Contact "Grace Hopper"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'crm18_contact','C7o2WVeswVQxUsXD','Grace Hopper',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"C7o2WVeswVQxUsXD","created_at":"2026-12-02T15:14:35.308Z","updated_at":"2026-12-02T15:14:35.308Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Grace Hopper","account":"Za0K_bLbuHot3bok","referred_by":"NuOyrbcsb9xZeIr5","email":"grace@acme.test","status":"open","flagged":false,"salary":140000},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"crm18_contact","label":"Grace Hopper"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('pLUYbxUcZTs52Ude','2026-12-02T15:14:35.350Z','2026-12-02T15:14:35.350Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-02T15:14:35.348Z','created','Created Contact "Linus Pauling"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'crm18_contact','dFhmYYU80eElB6nd','Linus Pauling',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"dFhmYYU80eElB6nd","created_at":"2026-12-02T15:14:35.345Z","updated_at":"2026-12-02T15:14:35.345Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Linus Pauling","account":"NuOyrbcsb9xZeIr5","referred_by":null,"email":"linus@globex.test","status":"open","flagged":false,"salary":120000},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"crm18_contact","label":"Linus Pauling"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('aOf4ThRFwKqbyeMf','2026-12-02T15:14:35.392Z','2026-12-02T15:14:35.392Z','org_mx69o0q4fm2fxl02','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','2026-12-02T15:14:35.391Z','created','Created Contact "Margaret Hamilton"','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','Member',NULL,'crm18_contact','4Vo9mRADteWIDPlW','Margaret Hamilton',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"4Vo9mRADteWIDPlW","created_at":"2026-12-02T15:14:35.388Z","updated_at":"2026-12-02T15:14:35.388Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","updated_by":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","owner_id":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","owning_business_unit_id":null,"queue":null,"name":"Margaret Hamilton","account":"cMYxu_0801wJ6HmI","referred_by":null,"email":"margaret@initech.test","status":"open","flagged":false,"salary":90000},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"crm18_contact","label":"Margaret Hamilton"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('6ulI7Cc2HdYQSAZX','2026-12-02T15:14:35.605Z','2026-12-02T15:14:35.605Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:35.602Z','created','Created System Metadata "crm18_contact"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'sys_metadata','j0icqd5vvHfbkeS9','crm18_contact',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"j0icqd5vvHfbkeS9","created_at":"2026-12-02T15:14:35.600Z","updated_at":"2026-12-02T15:14:35.600Z","name":"crm18_contact","type":"view","namespace":"default","package_id":null,"package_version_id":null,"managed_by":null,"scope":"platform","bundle_member":null,"metadata":"{\"object\":\"crm18_contact\",\"list\":{\"label\":\"All Contacts\",\"type\":\"grid\",\"columns\":[{\"field\":\"name\"},{\"field\":\"account\"},{\"field\":\"status\"},{\"field\":\"salary\"}],\"sort\":[{\"field\":\"name\",\"order\":\"asc\"}],\"pagination\":{\"pageSize\":25},\"bulkActions\":[\"crm18_close_contact\",\"crm18_flag_contact\"]},\"name\":\"crm18_contact\"}","draft_changes":null,"extends":null,"strategy":"merge","owner":null,"state":"active","environment_id":null,"version":1,"source":null,"tags":null,"created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8"},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"sys_metadata","label":"crm18_contact"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('GqTPs7uXsSJ8Q_Ea','2026-12-02T15:14:35.610Z','2026-12-02T15:14:35.610Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:35.608Z','created','Created Metadata History "crm18_contact"','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','Owner',NULL,'sys_metadata_history','21bddfdc-e210-4313-91c2-45e07b6dc1d3','crm18_contact',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"21bddfdc-e210-4313-91c2-45e07b6dc1d3","created_at":"2026-12-02T15:14:35.606Z","updated_at":"2026-12-02T15:14:35.606Z","created_by":null,"updated_by":null,"event_seq":1,"name":"crm18_contact","type":"view","version":1,"package_id":null,"operation_type":"create","metadata":"{\"object\":\"crm18_contact\",\"list\":{\"label\":\"All Contacts\",\"type\":\"grid\",\"columns\":[{\"field\":\"name\"},{\"field\":\"account\"},{\"field\":\"status\"},{\"field\":\"salary\"}],\"sort\":[{\"field\":\"name\",\"order\":\"asc\"}],\"pagination\":{\"pageSize\":25},\"bulkActions\":[\"crm18_close_contact\",\"crm18_flag_contact\"]},\"name\":\"crm18_contact\"}","change_note":null,"source":"protocol.saveMetaItem","recorded_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","recorded_at":"2026-12-02T15:14:35.598Z"},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"sys_metadata_history","label":"crm18_contact"}}',NULL,'[]',NULL); +INSERT INTO "sys_activity__r20261202" ("id","created_at","updated_at","organization_id","created_by","updated_by","timestamp","type","summary","actor_id","actor_name","actor_avatar_url","object_name","record_id","record_label","source_object","source_id","url","environment_id","metadata","origin","changed_fields","milestone_key") VALUES('fI6IBv5tE9zV8cR0','2026-12-02T15:14:35.619Z','2026-12-02T15:14:35.619Z','org_mx69o0q4fm2fxl02',NULL,NULL,'2026-12-02T15:14:35.617Z','created','Created Metadata Audit "crm18_contact"',NULL,NULL,NULL,'sys_metadata_audit','OWZml0b2kcI4hep_','crm18_contact',NULL,NULL,NULL,NULL,'{"old":null,"new":{"id":"OWZml0b2kcI4hep_","created_at":"2026-12-02T15:14:35.615Z","updated_at":"2026-12-02T15:14:35.615Z","created_by":null,"updated_by":null,"occurred_at":"2026-12-02T15:14:35.615Z","actor":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","source":"protocol.saveMetaItem","type":"view","name":"crm18_contact","operation":"save","outcome":"allowed","code":"ok","lock_state":"none","lock_overridden":false,"request_id":null,"note":"active"},"text_sources":{"summary":["name"],"record_label":["name"]},"summary_message":{"key":"activityCreated","object":"sys_metadata_audit","label":"crm18_contact"}}',NULL,'[]',NULL); +CREATE TABLE `sys_api_key` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `name` text, `prefix` varchar(16), `user_id` varchar(255), `active_organization_id` varchar(255), `scopes` text, `expires_at` datetime, `last_used_at` datetime, `revoked` boolean default '0', `revoked_reason` varchar(255), `key` varchar(64), primary key (`id`)); +CREATE TABLE `sys_assignment_cursor` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `rule` varchar(100), `rule_package` text, `entry` varchar(100), `last_user_id` text, `version` float default '0', primary key (`id`)); +CREATE TABLE `sys_assignment_rule` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `organization_id` varchar(255) not null, `name` varchar(100), `label` text, `description` text, `object_name` varchar(100), `criteria` text, `sort_order` float default '0', `recipient_type` varchar(255) default 'queue', `recipient_id` text, `strategy` varchar(255), `load` text, `active` boolean default '1', primary key (`id`)); +CREATE TABLE `sys_attachment` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `parent_object` varchar(128), `parent_id` varchar(64), `file_id` varchar(255), `file_name` text, `mime_type` text, `size` float, `uploaded_by` varchar(255), `description` text, primary key (`id`)); +CREATE TABLE `sys_audience_binding_suggestion` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `package_id` varchar(255), `permission_set_name` varchar(100), `permission_set_package` text, `anchor` varchar(255) default 'everyone', `status` varchar(255) default 'pending', `deployment_decision` boolean default '0', `resolved_by` varchar(255), `resolved_at` datetime, primary key (`id`)); +CREATE TABLE `sys_audit_amendment` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `kind` varchar(255), `sealed_object` varchar(255), `chain_key` varchar(259), `tenant_id` varchar(255), `amended_at` datetime, `checkpoint_sequence` float, `row_id` varchar(255), `column_name` text, `sealed_commitment` text, `rewritten_commitment` text, `rewritten_by` text, `first_sequence` float, `last_sequence` float, `covered_from` datetime, `covered_to` datetime, `last_removed_digest` text, `policy` text, `policy_value` text, `signing_key_id` text, `signature` text, primary key (`id`)); +CREATE TABLE `sys_audit_checkpoint` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `sealed_object` varchar(255), `chain_key` varchar(259), `tenant_id` varchar(255), `sequence` float, `kind` varchar(255), `part_index` float, `final_part` boolean, `window_start` datetime, `window_end` datetime, `sealed_through` datetime, `leaf_count` float, `row_ids` text, `leaf_hashes` text, `root` text, `previous_digest` text, `columns` text, `canon_version` float, `seed_handle` text, `fencing_token` text, `sealed_at` datetime, `signing_key_id` text, `signature` text, primary key (`id`)); +CREATE TABLE `sys_audit_log` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `action` varchar(255), `user_id` varchar(255), `actor` text, `object_name` varchar(255), `record_id` varchar(255), `old_value` text, `new_value` text, `ip_address` text, `user_agent` text, `tenant_id` varchar(255), `metadata` text, primary key (`id`)); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('OI3BFBJCEc4qpoOB','2026-12-02T15:14:22.157Z','2026-12-02T15:14:22.157Z',NULL,NULL,'create',NULL,NULL,'sys_platform_setting','KdXx5J2BTv_SUJM7',NULL,'{"id":"KdXx5J2BTv_SUJM7","created_at":"2026-12-02T15:14:22.148Z","updated_at":"2026-12-02T15:14:22.148Z","created_by":null,"namespace":"auth","key":"api_key_policy_started_at","value":"2026-12-02T15:14:22.123Z","encrypted":false,"locked":false,"locked_reason":null,"updated_by":null}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('KcIV8q8TJ9O8AofS','2026-12-02T15:14:22.164Z','2026-12-02T15:14:22.164Z',NULL,NULL,'config_change',NULL,NULL,'sys_platform_setting','KdXx5J2BTv_SUJM7',NULL,'{"namespace":"auth","key":"api_key_policy_started_at","scope":"global","value":"2026-12-02T15:14:22.123Z","digest":"sha256:5e48eb605ea9209a85ae6e404d5e01c6705a4004e5f7768d9a7bfa50e06adf46"}',NULL,NULL,NULL,'{"event":"settings.set","namespace":"auth","key":"api_key_policy_started_at","scope":"global","encrypted":false}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('-aCe11AsVhpaYz51','2026-12-02T15:14:22.168Z','2026-12-02T15:14:22.168Z',NULL,NULL,'create',NULL,NULL,'sys_platform_setting_audit','rqmDXgbXwyu0yG3S',NULL,'{"id":"rqmDXgbXwyu0yG3S","created_at":"2026-12-02T15:14:22.166Z","updated_at":"2026-12-02T15:14:22.166Z","created_by":null,"updated_by":null,"namespace":"auth","key":"api_key_policy_started_at","scope":"global","action":"set","actor_id":null,"source":"api","reason":null,"old_hash":null,"new_hash":"sha256:5e48eb605ea9209a85ae6e404d5e01c6705a4004e5f7768d9a7bfa50e06adf46","encrypted":false,"request_id":null}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('QpuVysbUZTrtCAKV','2026-12-02T15:14:23.024Z','2026-12-02T15:14:23.024Z',NULL,NULL,'create',NULL,NULL,'sys_user','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8',NULL,'{"id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","created_at":"2026-12-02T15:14:23.020Z","updated_at":"2026-12-02T15:14:23.020Z","name":"Owner","email":"owner@crm18.test","email_verified":false,"two_factor_enabled":false,"role":"user","banned":false,"ban_reason":null,"ban_expires":null,"failed_login_count":0,"locked_until":null,"password_changed_at":null,"phone_number":null,"phone_number_verified":false,"must_change_password":false,"mfa_required_at":null,"last_login_at":null,"last_login_ip":null,"ai_access":false,"principal_kind":"human","accountable_user_id":null,"image":null,"locale":null,"manager_id":null,"primary_business_unit_id":null,"source":"env_native"}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('aa7SdHwV1Cn7CyVS','2026-12-02T15:14:23.081Z','2026-12-02T15:14:23.081Z',NULL,NULL,'create',NULL,NULL,'sys_user_permission_set','ups_mx69o1y9dsixh1ek',NULL,'{"id":"ups_mx69o1y9dsixh1ek","created_at":"2026-12-02T15:14:23.074Z","updated_at":"2026-12-02T15:14:23.074Z","created_by":null,"updated_by":null,"user_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","permission_set":"admin_full_access","organization_id":"org_mx69o0q4fm2fxl02","permission_set_package":"com.objectstack.plugin-security","granted_by":null,"valid_from":null,"valid_until":null,"reason":null,"last_certified_at":null,"certified_by":null}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('-t1u6B_ofB3PyLTm','2026-12-02T15:14:23.093Z','2026-12-02T15:14:23.093Z',NULL,NULL,'create',NULL,NULL,'sys_member','mem_mx69o1ypy4ozz8g7',NULL,'{"id":"mem_mx69o1ypy4ozz8g7","created_at":"2026-12-02T15:14:23.090Z","updated_at":"2026-12-02T15:14:23.090Z","organization_id":"org_mx69o0q4fm2fxl02","user_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","role":"owner"}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('DCKejAc06MlOOzK-','2026-12-02T15:14:23.106Z','2026-12-02T15:14:23.106Z',NULL,NULL,'create',NULL,NULL,'sys_user_permission_set','ups_mx69o1z2cfb821nx',NULL,'{"id":"ups_mx69o1z2cfb821nx","created_at":"2026-12-02T15:14:23.102Z","updated_at":"2026-12-02T15:14:23.102Z","created_by":null,"updated_by":null,"user_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","permission_set":"organization_admin_no_bypass","organization_id":"org_mx69o0q4fm2fxl02","permission_set_package":"com.objectstack.plugin-security","granted_by":null,"valid_from":null,"valid_until":null,"reason":"auto-org-admin-grant: granted from membership grade ''owner'' (sys_member mem_mx69o1ypy4ozz8g7) → organization_admin_no_bypass","last_certified_at":null,"certified_by":null}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('tH32QlTV246jJPvA','2026-12-02T15:14:23.117Z','2026-12-02T15:14:23.117Z',NULL,NULL,'create',NULL,NULL,'sys_migration','adr-0093-default-org-owner-bind',NULL,'{"id":"adr-0093-default-org-owner-bind","created_at":"2026-12-02T15:14:23.115Z","updated_at":"2026-12-02T15:14:23.115Z","created_by":null,"updated_by":null,"last_run_at":"2026-12-02T15:14:23.115Z","verified_at":null,"applied_at":"2026-12-02T15:14:23.115Z","blocking":0,"advisory":null,"details":"{\"outcome\":\"bound\",\"organizationId\":\"org_mx69o0q4fm2fxl02\"}","deviation_observed_at":null,"deviation_detail":null,"columns_moved_at":null}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('6vSE6UX0gsfU5N7k','2026-12-02T15:14:23.156Z','2026-12-02T15:14:23.156Z',NULL,NULL,'login','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_session','kQe0jKhuDw2sYFd0woCwpB3g5086q7To',NULL,NULL,'127.0.0.1','node','org_mx69o0q4fm2fxl02','{"endpoint":"/sign-up/email"}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('AXWtRfBQutbTfAw1','2026-12-02T15:14:23.173Z','2026-12-02T15:14:23.173Z',NULL,NULL,'update',NULL,NULL,'sys_user','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','{"password_changed_at":null}','{"password_changed_at":"2026-12-02T15:14:23.164Z"}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('OYdeBmrA7OIRaD0A','2026-12-02T15:14:23.207Z','2026-12-02T15:14:23.207Z',NULL,NULL,'create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7',NULL,'{"id":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","created_at":"2026-12-02T15:14:23.203Z","updated_at":"2026-12-02T15:14:23.203Z","name":"Member","email":"member@crm18.test","email_verified":false,"two_factor_enabled":false,"role":"user","banned":false,"ban_reason":null,"ban_expires":null,"failed_login_count":0,"locked_until":null,"password_changed_at":null,"phone_number":null,"phone_number_verified":false,"must_change_password":false,"mfa_required_at":null,"last_login_at":null,"last_login_ip":null,"ai_access":false,"principal_kind":"human","accountable_user_id":null,"image":null,"locale":null,"manager_id":null,"primary_business_unit_id":null,"source":"env_native"}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('uLstTBcHElkpQBya','2026-12-02T15:14:23.224Z','2026-12-02T15:14:23.224Z',NULL,NULL,'create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_member','mem_mx69o22ewrdpthu3',NULL,'{"id":"mem_mx69o22ewrdpthu3","created_at":"2026-12-02T15:14:23.222Z","updated_at":"2026-12-02T15:14:23.222Z","organization_id":"org_mx69o0q4fm2fxl02","user_id":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","role":"member"}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('x25x66F5dGzY2ulF','2026-12-02T15:14:23.340Z','2026-12-02T15:14:23.340Z',NULL,NULL,'update','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','{"must_change_password":false}','{"must_change_password":true}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('1XEIr671PTnbsfPL','2026-12-02T15:14:23.345Z','2026-12-02T15:14:23.345Z',NULL,NULL,'create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7',NULL,NULL,NULL,NULL,NULL,'{"event":"user.admin_created","placeholderEmail":false,"passwordGenerated":false,"organizationId":"org_mx69o0q4fm2fxl02","membershipCreated":true}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('5Of1mpXs6tWZFdr0','2026-12-02T15:14:23.469Z','2026-12-02T15:14:23.469Z',NULL,NULL,'login','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','sys_session','OZ8p5AoGQAKP87p88eVszd5ssqaNH3zm',NULL,NULL,'127.0.0.1','node','org_mx69o0q4fm2fxl02','{"endpoint":"/sign-in/email"}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('6QFDoytkNWDasJPe','2026-12-02T15:14:23.480Z','2026-12-02T15:14:23.480Z',NULL,NULL,'update','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','{"last_login_at":null,"last_login_ip":null}','{"last_login_at":"2026-12-02T15:14:23.474Z","last_login_ip":"127.0.0.1"}',NULL,NULL,NULL,'{"event":"auth.last_login_stamp"}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('v0W2B_T6vnnyP6WH','2026-12-02T15:14:23.932Z','2026-12-02T15:14:23.932Z',NULL,NULL,'update','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','{"password_changed_at":null,"must_change_password":true}','{"password_changed_at":"2026-12-02T15:14:23.928Z","must_change_password":false}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('PNRPw-C-ksd6VDeF','2026-12-02T15:14:24.090Z','2026-12-02T15:14:24.090Z',NULL,NULL,'login','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','sys_session','hcw4uNEy48GMcvZjN2O7J2FqzcMp0g78',NULL,NULL,'127.0.0.1','node','org_mx69o0q4fm2fxl02','{"endpoint":"/sign-in/email"}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('A5RhOTYboghU5yvE','2026-12-02T15:14:24.099Z','2026-12-02T15:14:24.099Z',NULL,NULL,'update','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','sys_user','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','{"last_login_at":"2026-12-02T15:14:23.474Z"}','{"last_login_at":"2026-12-02T15:14:24.095Z"}',NULL,NULL,NULL,'{"event":"auth.last_login_stamp"}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('ii7QYO4Yus9FnwMw','2026-12-02T15:14:24.124Z','2026-12-02T15:14:24.124Z',NULL,NULL,'create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF',NULL,'{"id":"1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF","created_at":"2026-12-02T15:14:24.122Z","updated_at":"2026-12-02T15:14:24.122Z","name":"Auditor","email":"auditor@crm18.test","email_verified":false,"two_factor_enabled":false,"role":"user","banned":false,"ban_reason":null,"ban_expires":null,"failed_login_count":0,"locked_until":null,"password_changed_at":null,"phone_number":null,"phone_number_verified":false,"must_change_password":false,"mfa_required_at":null,"last_login_at":null,"last_login_ip":null,"ai_access":false,"principal_kind":"human","accountable_user_id":null,"image":null,"locale":null,"manager_id":null,"primary_business_unit_id":null,"source":"env_native"}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('EA7f6PRuMFIvfwHD','2026-12-02T15:14:24.148Z','2026-12-02T15:14:24.148Z',NULL,NULL,'create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_member','mem_mx69o2s1tlsx8800',NULL,'{"id":"mem_mx69o2s1tlsx8800","created_at":"2026-12-02T15:14:24.146Z","updated_at":"2026-12-02T15:14:24.146Z","organization_id":"org_mx69o0q4fm2fxl02","user_id":"1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF","role":"member"}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('R3vHB442EklqDcJM','2026-12-02T15:14:24.256Z','2026-12-02T15:14:24.256Z',NULL,NULL,'update','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','{"must_change_password":false}','{"must_change_password":true}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('taI4R_yxd9wqk2au','2026-12-02T15:14:24.260Z','2026-12-02T15:14:24.260Z',NULL,NULL,'create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF',NULL,NULL,NULL,NULL,NULL,'{"event":"user.admin_created","placeholderEmail":false,"passwordGenerated":false,"organizationId":"org_mx69o0q4fm2fxl02","membershipCreated":true}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('-ASyCNf7FS3OFxmk','2026-12-02T15:14:24.400Z','2026-12-02T15:14:24.400Z',NULL,NULL,'login','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','sys_session','gfu3W4RbYNEklf1489jEr57ROs36XgB3',NULL,NULL,'127.0.0.1','node','org_mx69o0q4fm2fxl02','{"endpoint":"/sign-in/email"}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('zMU_D3HTSTkOE0bV','2026-12-02T15:14:24.408Z','2026-12-02T15:14:24.408Z',NULL,NULL,'update','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','{"last_login_at":null,"last_login_ip":null}','{"last_login_at":"2026-12-02T15:14:24.404Z","last_login_ip":"127.0.0.1"}',NULL,NULL,NULL,'{"event":"auth.last_login_stamp"}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('rkMrg2FX6cbmS8Da','2026-12-02T15:14:24.845Z','2026-12-02T15:14:24.845Z',NULL,NULL,'update','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','{"password_changed_at":null,"must_change_password":true}','{"password_changed_at":"2026-12-02T15:14:24.841Z","must_change_password":false}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('S-hrgOBX7Eez3YJ_','2026-12-02T15:14:35.010Z','2026-12-02T15:14:35.010Z',NULL,NULL,'login','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','sys_session','PUZXdpx9Kgr03bACPjTkvdSc4PUTvC1S',NULL,NULL,'127.0.0.1','node','org_mx69o0q4fm2fxl02','{"endpoint":"/sign-in/email"}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('vmJLNgp5__5DTa8a','2026-12-02T15:14:35.017Z','2026-12-02T15:14:35.017Z',NULL,NULL,'update','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','sys_user','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','{"last_login_at":"2026-12-02T15:14:24.404Z"}','{"last_login_at":"2026-12-02T15:14:35.014Z"}',NULL,NULL,NULL,'{"event":"auth.last_login_stamp"}'); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('pGo_xtsPaXV92NqF','2026-12-02T15:14:35.092Z','2026-12-02T15:14:35.092Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_user_permission_set','zPvFJMFMTDciSum6',NULL,'{"id":"zPvFJMFMTDciSum6","created_at":"2026-12-02T15:14:35.077Z","updated_at":"2026-12-02T15:14:35.077Z","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","user_id":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","permission_set":"crm18_member","organization_id":"org_mx69o0q4fm2fxl02","permission_set_package":"com.example.crm18","granted_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","valid_from":null,"valid_until":null,"reason":null,"last_certified_at":null,"certified_by":null}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('UP3_cluIwD4MtBuU','2026-12-02T15:14:35.131Z','2026-12-02T15:14:35.131Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_user_permission_set','mqpjWWjiULAXBZs7',NULL,'{"id":"mqpjWWjiULAXBZs7","created_at":"2026-12-02T15:14:35.123Z","updated_at":"2026-12-02T15:14:35.123Z","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","user_id":"1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF","permission_set":"crm18_auditor","organization_id":"org_mx69o0q4fm2fxl02","permission_set_package":"com.example.crm18","granted_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","valid_from":null,"valid_until":null,"reason":null,"last_certified_at":null,"certified_by":null}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('abD4tXQjCgvRmxE0','2026-12-02T15:14:35.167Z','2026-12-02T15:14:35.167Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','crm18_account','Za0K_bLbuHot3bok',NULL,'{"id":"Za0K_bLbuHot3bok","created_at":"2026-12-02T15:14:35.165Z","updated_at":"2026-12-02T15:14:35.165Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Acme","industry":"technology","status":"active","annual_revenue":1200000,"notes":"Key account, renewal in Q1"}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('YuBPEL0P2aQchq60','2026-12-02T15:14:35.199Z','2026-12-02T15:14:35.199Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','crm18_account','NuOyrbcsb9xZeIr5',NULL,'{"id":"NuOyrbcsb9xZeIr5","created_at":"2026-12-02T15:14:35.197Z","updated_at":"2026-12-02T15:14:35.197Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Globex","industry":"finance","status":"inactive","annual_revenue":500000,"notes":"Paused after the audit"}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('khiBNZCNrs9ykhIJ','2026-12-02T15:14:35.231Z','2026-12-02T15:14:35.231Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','crm18_account','cMYxu_0801wJ6HmI',NULL,'{"id":"cMYxu_0801wJ6HmI","created_at":"2026-12-02T15:14:35.229Z","updated_at":"2026-12-02T15:14:35.229Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Initech","industry":"retail","status":"inactive","annual_revenue":75000,"notes":"Small, steady"}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('wNtjxtXb1eUjNarX','2026-12-02T15:14:35.266Z','2026-12-02T15:14:35.266Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','crm18_contact','P3kqdaCWIjxsAUkq',NULL,'{"id":"P3kqdaCWIjxsAUkq","created_at":"2026-12-02T15:14:35.261Z","updated_at":"2026-12-02T15:14:35.261Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Ada Lovelace","account":"Za0K_bLbuHot3bok","referred_by":null,"email":"ada@acme.test","status":"open","flagged":false,"salary":150000}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('OuqbHuG9ObDiwrGv','2026-12-02T15:14:35.312Z','2026-12-02T15:14:35.312Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','crm18_contact','C7o2WVeswVQxUsXD',NULL,'{"id":"C7o2WVeswVQxUsXD","created_at":"2026-12-02T15:14:35.308Z","updated_at":"2026-12-02T15:14:35.308Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Grace Hopper","account":"Za0K_bLbuHot3bok","referred_by":"NuOyrbcsb9xZeIr5","email":"grace@acme.test","status":"open","flagged":false,"salary":140000}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('8GkKE_fxTK6mk_I6','2026-12-02T15:14:35.349Z','2026-12-02T15:14:35.349Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','crm18_contact','dFhmYYU80eElB6nd',NULL,'{"id":"dFhmYYU80eElB6nd","created_at":"2026-12-02T15:14:35.345Z","updated_at":"2026-12-02T15:14:35.345Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owner_id":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","owning_business_unit_id":null,"queue":null,"name":"Linus Pauling","account":"NuOyrbcsb9xZeIr5","referred_by":null,"email":"linus@globex.test","status":"open","flagged":false,"salary":120000}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('xkDdr0QgAHq9pWxq','2026-12-02T15:14:35.391Z','2026-12-02T15:14:35.391Z','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','create','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','crm18_contact','4Vo9mRADteWIDPlW',NULL,'{"id":"4Vo9mRADteWIDPlW","created_at":"2026-12-02T15:14:35.388Z","updated_at":"2026-12-02T15:14:35.388Z","organization_id":"org_mx69o0q4fm2fxl02","created_by":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","updated_by":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","owner_id":"80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7","owning_business_unit_id":null,"queue":null,"name":"Margaret Hamilton","account":"cMYxu_0801wJ6HmI","referred_by":null,"email":"margaret@initech.test","status":"open","flagged":false,"salary":90000}',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('m2SgJF1sNkIM_aJE','2026-12-02T15:14:35.603Z','2026-12-02T15:14:35.603Z',NULL,NULL,'create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_metadata','j0icqd5vvHfbkeS9',NULL,'{"id":"j0icqd5vvHfbkeS9","created_at":"2026-12-02T15:14:35.600Z","updated_at":"2026-12-02T15:14:35.600Z","name":"crm18_contact","type":"view","namespace":"default","package_id":null,"package_version_id":null,"managed_by":null,"scope":"platform","bundle_member":null,"metadata":"{\"object\":\"crm18_contact\",\"list\":{\"label\":\"All Contacts\",\"type\":\"grid\",\"columns\":[{\"field\":\"name\"},{\"field\":\"account\"},{\"field\":\"status\"},{\"field\":\"salary\"}],\"sort\":[{\"field\":\"name\",\"order\":\"asc\"}],\"pagination\":{\"pageSize\":25},\"bulkActions\":[\"crm18_close_contact\",\"crm18_flag_contact\"]},\"name\":\"crm18_contact\"}","draft_changes":null,"extends":null,"strategy":"merge","owner":null,"state":"active","environment_id":null,"version":1,"source":null,"tags":null,"created_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","updated_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8"}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('gq-9kNhfcIir7q4Z','2026-12-02T15:14:35.609Z','2026-12-02T15:14:35.609Z',NULL,NULL,'create','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','sys_metadata_history','21bddfdc-e210-4313-91c2-45e07b6dc1d3',NULL,'{"id":"21bddfdc-e210-4313-91c2-45e07b6dc1d3","created_at":"2026-12-02T15:14:35.606Z","updated_at":"2026-12-02T15:14:35.606Z","created_by":null,"updated_by":null,"event_seq":1,"name":"crm18_contact","type":"view","version":1,"package_id":null,"operation_type":"create","metadata":"{\"object\":\"crm18_contact\",\"list\":{\"label\":\"All Contacts\",\"type\":\"grid\",\"columns\":[{\"field\":\"name\"},{\"field\":\"account\"},{\"field\":\"status\"},{\"field\":\"salary\"}],\"sort\":[{\"field\":\"name\",\"order\":\"asc\"}],\"pagination\":{\"pageSize\":25},\"bulkActions\":[\"crm18_close_contact\",\"crm18_flag_contact\"]},\"name\":\"crm18_contact\"}","change_note":null,"source":"protocol.saveMetaItem","recorded_by":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","recorded_at":"2026-12-02T15:14:35.598Z"}',NULL,NULL,NULL,NULL); +INSERT INTO "sys_audit_log" ("id","created_at","updated_at","created_by","updated_by","action","user_id","actor","object_name","record_id","old_value","new_value","ip_address","user_agent","tenant_id","metadata") VALUES('J0jKZICLeXCwReGx','2026-12-02T15:14:35.618Z','2026-12-02T15:14:35.618Z',NULL,NULL,'create',NULL,NULL,'sys_metadata_audit','OWZml0b2kcI4hep_',NULL,'{"id":"OWZml0b2kcI4hep_","created_at":"2026-12-02T15:14:35.615Z","updated_at":"2026-12-02T15:14:35.615Z","created_by":null,"updated_by":null,"occurred_at":"2026-12-02T15:14:35.615Z","actor":"B4YBMHge1KjrzPLMHd56oOcApyQj8qx8","source":"protocol.saveMetaItem","type":"view","name":"crm18_contact","operation":"save","outcome":"allowed","code":"ok","lock_state":"none","lock_overridden":false,"request_id":null,"note":"active"}',NULL,NULL,NULL,NULL); +CREATE TABLE `sys_audit_signing_key` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `fingerprint` text, `public_key` text, `status` varchar(255), `retired_at` datetime, `private_handle` text, primary key (`id`)); +CREATE TABLE `sys_automation_run` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `organization_id` varchar(255) not null, `flow_name` varchar(255), `flow_package` text, `flow_version` float, `flow_checksum` text, `node_id` text, `node_type` text, `status` varchar(255) default 'paused', `correlation` varchar(255), `user_id` text, `trigger_type` text, `trigger_object` varchar(255), `trigger_record_id` varchar(255), `variables_json` text, `steps_json` text, `context_json` text, `screen_json` text, `started_at` datetime, `start_time` float, `active_ms` float, `finished_at` datetime, `duration_ms` float, `wait_ms` float, `error` text, `refusal_message` text, `selected_count` float, `acted_count` float, `skipped_count` float, `unmeasured_count` float, `summary_json` text, primary key (`id`)); +INSERT INTO "sys_automation_run" ("id","created_at","updated_at","created_by","updated_by","organization_id","flow_name","flow_package","flow_version","flow_checksum","node_id","node_type","status","correlation","user_id","trigger_type","trigger_object","trigger_record_id","variables_json","steps_json","context_json","screen_json","started_at","start_time","active_ms","finished_at","duration_ms","wait_ms","error","refusal_message","selected_count","acted_count","skipped_count","unmeasured_count","summary_json") VALUES('run_run_28157b69-968b-4515-9a5c-51d3dcd0cfde','2026-12-02T15:14:35.285Z','2026-12-02T15:14:35.285Z',NULL,NULL,'org_mx69o0q4fm2fxl02','crm18_contact_created_flow','com.example.crm18',1,NULL,'start',NULL,'completed',NULL,'B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','record-after-write','crm18_contact','P3kqdaCWIjxsAUkq',NULL,'[{"nodeId":"start","nodeType":"start","status":"success","startedAt":"2026-12-02T15:14:35.280Z","completedAt":"2026-12-02T15:14:35.280Z","durationMs":0}]',NULL,NULL,'2026-12-02T15:14:35.271Z',NULL,NULL,'2026-12-02T15:14:35.281Z',11,0,NULL,NULL,0,0,0,0,'{"selected":0,"acted":0,"skipped":0,"unmeasured":0,"failed":0,"nodes":[{"nodeId":"start","nodeType":"start","status":"success","runs":1,"failures":0,"skipped":0}],"gates":[]}'); +INSERT INTO "sys_automation_run" ("id","created_at","updated_at","created_by","updated_by","organization_id","flow_name","flow_package","flow_version","flow_checksum","node_id","node_type","status","correlation","user_id","trigger_type","trigger_object","trigger_record_id","variables_json","steps_json","context_json","screen_json","started_at","start_time","active_ms","finished_at","duration_ms","wait_ms","error","refusal_message","selected_count","acted_count","skipped_count","unmeasured_count","summary_json") VALUES('run_run_9238ef4c-4c46-414a-831a-2d064ff311cd','2026-12-02T15:14:35.320Z','2026-12-02T15:14:35.320Z',NULL,NULL,'org_mx69o0q4fm2fxl02','crm18_contact_created_flow','com.example.crm18',1,NULL,'start',NULL,'completed',NULL,'B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','record-after-write','crm18_contact','C7o2WVeswVQxUsXD',NULL,'[{"nodeId":"start","nodeType":"start","status":"success","startedAt":"2026-12-02T15:14:35.318Z","completedAt":"2026-12-02T15:14:35.318Z","durationMs":0}]',NULL,NULL,'2026-12-02T15:14:35.315Z',NULL,NULL,'2026-12-02T15:14:35.318Z',4,0,NULL,NULL,0,0,0,0,'{"selected":0,"acted":0,"skipped":0,"unmeasured":0,"failed":0,"nodes":[{"nodeId":"start","nodeType":"start","status":"success","runs":1,"failures":0,"skipped":0}],"gates":[]}'); +INSERT INTO "sys_automation_run" ("id","created_at","updated_at","created_by","updated_by","organization_id","flow_name","flow_package","flow_version","flow_checksum","node_id","node_type","status","correlation","user_id","trigger_type","trigger_object","trigger_record_id","variables_json","steps_json","context_json","screen_json","started_at","start_time","active_ms","finished_at","duration_ms","wait_ms","error","refusal_message","selected_count","acted_count","skipped_count","unmeasured_count","summary_json") VALUES('run_run_9f819792-b0c4-499a-ad19-7f0629974846','2026-12-02T15:14:35.359Z','2026-12-02T15:14:35.359Z',NULL,NULL,'org_mx69o0q4fm2fxl02','crm18_contact_created_flow','com.example.crm18',1,NULL,'start',NULL,'completed',NULL,'B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','record-after-write','crm18_contact','dFhmYYU80eElB6nd',NULL,'[{"nodeId":"start","nodeType":"start","status":"success","startedAt":"2026-12-02T15:14:35.356Z","completedAt":"2026-12-02T15:14:35.356Z","durationMs":0}]',NULL,NULL,'2026-12-02T15:14:35.351Z',NULL,NULL,'2026-12-02T15:14:35.356Z',5,0,NULL,NULL,0,0,0,0,'{"selected":0,"acted":0,"skipped":0,"unmeasured":0,"failed":0,"nodes":[{"nodeId":"start","nodeType":"start","status":"success","runs":1,"failures":0,"skipped":0}],"gates":[]}'); +INSERT INTO "sys_automation_run" ("id","created_at","updated_at","created_by","updated_by","organization_id","flow_name","flow_package","flow_version","flow_checksum","node_id","node_type","status","correlation","user_id","trigger_type","trigger_object","trigger_record_id","variables_json","steps_json","context_json","screen_json","started_at","start_time","active_ms","finished_at","duration_ms","wait_ms","error","refusal_message","selected_count","acted_count","skipped_count","unmeasured_count","summary_json") VALUES('run_run_ba8fc235-f317-4e06-a5ab-e39752bb155d','2026-12-02T15:14:35.401Z','2026-12-02T15:14:35.401Z',NULL,NULL,'org_mx69o0q4fm2fxl02','crm18_contact_created_flow','com.example.crm18',1,NULL,'start',NULL,'completed',NULL,'80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','record-after-write','crm18_contact','4Vo9mRADteWIDPlW',NULL,'[{"nodeId":"start","nodeType":"start","status":"success","startedAt":"2026-12-02T15:14:35.398Z","completedAt":"2026-12-02T15:14:35.398Z","durationMs":0}]',NULL,NULL,'2026-12-02T15:14:35.394Z',NULL,NULL,'2026-12-02T15:14:35.398Z',4,0,NULL,NULL,0,0,0,0,'{"selected":0,"acted":0,"skipped":0,"unmeasured":0,"failed":0,"nodes":[{"nodeId":"start","nodeType":"start","status":"success","runs":1,"failures":0,"skipped":0}],"gates":[]}'); +CREATE TABLE `sys_business_unit` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `name` text, `code` varchar(64), `kind` varchar(255) default 'department', `parent_business_unit_id` varchar(255), `timezone` text, `organization_id` varchar(255) not null, `manager_user_id` varchar(255), `active` boolean default '1', `effective_from` datetime, `effective_to` datetime, `external_ref` text, primary key (`id`)); +CREATE TABLE `sys_business_unit_member` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `business_unit_id` varchar(255), `user_id` varchar(255), `function_in_business_unit` varchar(255) default 'member', `is_primary` boolean default '1', `effective_from` datetime, `effective_to` datetime, primary key (`id`)); +CREATE TABLE `sys_comment` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `thread_id` varchar(255), `object_name` varchar(255), `record_id` varchar(255), `parent_id` varchar(255), `author_id` varchar(255), `author_name` text, `author_avatar_url` varchar(255), `body` text, `mentions` text, `is_edited` boolean default '0', `edited_at` datetime, primary key (`id`)); +CREATE TABLE `sys_comment_reaction` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `comment_id` varchar(255), `emoji` varchar(64), `user_id` varchar(255), primary key (`id`)); +CREATE TABLE `sys_connector_connection` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `organization_id` varchar(255) not null, `connector_name` varchar(255), `connector_package` varchar(255), `grant` varchar(255), `refresh_token` varchar(255), `registered_client` varchar(255), `client_id` text, `client_has_secret` boolean default '0', `status` varchar(255) default 'connected', `status_reason` text, `scopes` text, `expires_at` datetime, `revision` float default '1', `connected_at` datetime, `connected_by` text, primary key (`id`)); +CREATE TABLE `sys_connector_credential` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `ref` varchar(255), `value` varchar(255), `revision` float default '1', `connector_name` text, `package_id` text, `status` varchar(255) default 'set', `status_reason` text, `last_verified_at` datetime, `set_at` datetime, `set_by` text, primary key (`id`)); +CREATE TABLE `sys_device_code` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `device_code` varchar(191), `user_code` varchar(191), `user_id` varchar(255), `expires_at` datetime, `status` varchar(64), `last_polled_at` datetime, `polling_interval` float, `client_id` text, `scope` text, primary key (`id`)); +CREATE TABLE `sys_email` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `message_id` text, `from_address` text, `to_addresses` text, `cc_addresses` text, `bcc_addresses` text, `reply_to` text, `subject` text, `body_text` text, `body_html` text, `headers_json` text, `attachments_json` text, `status` varchar(255) default 'queued', `error` text, `attempt_count` float default '0', `sent_at` datetime, `related_object` varchar(100), `related_id` varchar(100), `sent_by` varchar(255), primary key (`id`)); +CREATE TABLE `sys_email_template` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `name` varchar(128), `package_id` text, `label` text, `category` varchar(255) default 'custom', `locale` varchar(16) default 'en-US', `description` text, `subject` text, `body_html` text, `body_text` text, `from_name` text, `from_address` text, `reply_to` text, `active` boolean default '1', `is_system` boolean default '0', `variables_json` text, `managed_by` varchar(255) default 'admin', `customized` boolean default '0', primary key (`id`)); +CREATE TABLE `sys_exchange_rate` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `currency` varchar(3), `rate` float, `effective_date` date, `source` varchar(255) default 'manual', primary key (`id`)); +CREATE TABLE `sys_file` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `key` text, `name` text, `mime_type` text, `size` float, `scope` varchar(255), `bucket` text, `acl` varchar(255), `status` varchar(255), `etag` text, `owner_id` text, `ref_object` varchar(128), `ref_id` varchar(64), `ref_field` text, `released_ref_object` text, `released_ref_id` text, `metadata` text, `deleted_at` datetime, primary key (`id`)); +CREATE TABLE `sys_flow_credential` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `flow_name` varchar(255), `flow_package` text, `state` varchar(255), `node_id` text, `credential_key` text, `position` varchar(64), `value` varchar(255), primary key (`id`)); +CREATE TABLE `sys_flow_dispatch` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `dispatched_at` datetime, `outcome` varchar(255), `settled_at` datetime, primary key (`id`)); +CREATE TABLE `sys_http_delivery` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `source` varchar(32), `ref_id` varchar(384), `dedup_key` varchar(191), `label` text, `url` text, `method` text, `headers_json` text, `signature` text, `timeout_ms` float, `payload_json` text, `partition_key` float, `status` varchar(16) default 'pending', `attempts` float default '0', `claimed_by` text, `claimed_at` float, `next_retry_at` float, `last_attempted_at` float, `response_code` float, `response_body` text, `error` text, primary key (`id`)); +CREATE TABLE `sys_identity_email` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `message_id` text, `from_address` text, `to_addresses` text, `cc_addresses` text, `bcc_addresses` text, `reply_to` text, `subject` text, `body_text` text, `body_html` text, `headers_json` text, `attachments_json` text, `status` varchar(255) default 'queued', `error` text, `attempt_count` float default '0', `sent_at` datetime, `related_object` varchar(100), `related_id` varchar(100), `sent_by` varchar(255), primary key (`id`)); +CREATE TABLE `sys_idp_group_mapping` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `source_kind` varchar(255) default 'scim', `source_id` varchar(255), `group_external_id` text, `group_display_name` text, `permission_set` text, `organization_id` varchar(255) not null, `match_status` varchar(255), `matched_group_id` text, `match_changed_at` datetime, primary key (`id`)); +CREATE TABLE `sys_import_job` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `updated_by` varchar(255), `object_name` varchar(255), `status` varchar(255) default 'pending', `total_rows` float default '0', `processed_rows` float default '0', `created_count` float default '0', `updated_count` float default '0', `skipped_count` float default '0', `error_count` float default '0', `write_mode` varchar(255) default 'insert', `dry_run` boolean default '0', `run_automations` boolean default '0', `treat_as_historical` boolean default '0', `error` text, `results` text, `undo_log` text, `reverted_at` datetime, `started_at` datetime, `completed_at` datetime, `created_by` varchar(255), primary key (`id`)); +CREATE TABLE `sys_inbox_message` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `user_id` text, `notification_id` text, `delivery_id` text, `actor_id` varchar(255), `topic` text, `title` text, `body_md` text, `severity` varchar(255), `action_url` text, `keyed_text` text, primary key (`id`)); +CREATE TABLE `sys_invitation` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `email` varchar(255), `role` varchar(255) default 'member', `status` varchar(255) default 'pending', `inviter_id` varchar(255), `expires_at` datetime, `team_id` varchar(255), `business_unit_id` varchar(255), `positions` text, primary key (`id`)); +CREATE TABLE `sys_job` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `name` varchar(255), `schedule_type` varchar(255), `schedule_expression` text, `timezone` text, `active` boolean default '1', `last_run_at` datetime, `last_status` varchar(255), `last_error` text, `run_count` float default '0', `failure_count` float default '0', primary key (`id`)); +CREATE TABLE `sys_job_queue` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `queue` varchar(255), `idempotency_key` varchar(255), `payload_json` text, `metadata_json` text, `status` varchar(255) default 'pending', `priority` float default '100', `attempts` float default '0', `max_attempts` float default '3', `backoff_type` varchar(255) default 'exponential', `backoff_delay_ms` float default '1000', `backoff_max_delay_ms` float, `scheduled_for` datetime, `locked_by` text, `locked_until` datetime, `last_error` text, `completed_at` datetime, primary key (`id`)); +CREATE TABLE `sys_job_run` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `job_name` varchar(255), `status` varchar(255) default 'running', `started_at` datetime, `completed_at` datetime, `duration_ms` float, `attempt` float default '1', `trigger` varchar(255) default 'schedule', `error` text, primary key (`id`)); +CREATE TABLE `sys_jwks` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `public_key` text, `private_key` text, `alg` text, `crv` text, `expires_at` datetime, primary key (`id`)); +CREATE TABLE `sys_lifecycle_state` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `last_swept_at` datetime, primary key (`id`)); +CREATE TABLE `sys_member` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `user_id` varchar(255), `role` varchar(255) default 'member', primary key (`id`)); +INSERT INTO "sys_member" ("id","created_at","updated_at","organization_id","user_id","role") VALUES('mem_mx69o1ypy4ozz8g7','2026-12-02T15:14:23.090Z','2026-12-02T15:14:23.090Z','org_mx69o0q4fm2fxl02','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','owner'); +INSERT INTO "sys_member" ("id","created_at","updated_at","organization_id","user_id","role") VALUES('mem_mx69o22ewrdpthu3','2026-12-02T15:14:23.222Z','2026-12-02T15:14:23.222Z','org_mx69o0q4fm2fxl02','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','member'); +INSERT INTO "sys_member" ("id","created_at","updated_at","organization_id","user_id","role") VALUES('mem_mx69o2s1tlsx8800','2026-12-02T15:14:24.146Z','2026-12-02T15:14:24.146Z','org_mx69o0q4fm2fxl02','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','member'); +CREATE TABLE `sys_metadata` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `name` varchar(255), `type` varchar(100), `namespace` varchar(100) default 'default', `package_id` varchar(255), `package_version_id` varchar(255), `managed_by` varchar(255), `scope` varchar(255) default 'platform', `bundle_member` varchar(100), `metadata` text, `draft_changes` text, `extends` text, `strategy` varchar(255) default 'merge', `owner` text, `state` varchar(255) default 'active', `environment_id` varchar(255), `version` float default '1', `checksum` text, `source` varchar(255), `tags` text, `created_by` varchar(255), `updated_by` varchar(255), primary key (`id`)); +INSERT INTO "sys_metadata" ("id","created_at","updated_at","name","type","namespace","package_id","package_version_id","managed_by","scope","bundle_member","metadata","draft_changes","extends","strategy","owner","state","environment_id","version","checksum","source","tags","created_by","updated_by") VALUES('j0icqd5vvHfbkeS9','2026-12-02T15:14:35.600Z','2026-12-02T15:14:35.600Z','crm18_contact','view','default',NULL,NULL,NULL,'platform',NULL,'{"object":"crm18_contact","list":{"label":"All Contacts","type":"grid","columns":[{"field":"name"},{"field":"account"},{"field":"status"},{"field":"salary"}],"sort":[{"field":"name","order":"asc"}],"pagination":{"pageSize":25},"bulkActions":["crm18_close_contact","crm18_flag_contact"]},"name":"crm18_contact"}',NULL,NULL,'merge',NULL,'active',NULL,1,'sha256:cd4643d7687775aef2e19ee94ecaa47546388535d979be0bedfceca383d870c4',NULL,NULL,'B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8'); +CREATE TABLE `sys_metadata_activation` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `metadata_type` varchar(100), `name` varchar(255), `package_id` varchar(255), `active` boolean default '1', primary key (`id`)); +CREATE TABLE `sys_metadata_audit` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `occurred_at` datetime, `actor` varchar(255), `source` text, `type` varchar(100), `name` varchar(255), `operation` varchar(255), `outcome` varchar(255), `code` text, `lock_state` text, `lock_overridden` boolean, `request_id` text, `note` text, primary key (`id`)); +INSERT INTO "sys_metadata_audit" ("id","created_at","updated_at","created_by","updated_by","occurred_at","actor","source","type","name","operation","outcome","code","lock_state","lock_overridden","request_id","note") VALUES('OWZml0b2kcI4hep_','2026-12-02T15:14:35.615Z','2026-12-02T15:14:35.615Z',NULL,NULL,'2026-12-02T15:14:35.615Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','protocol.saveMetaItem','view','crm18_contact','save','allowed','ok','none',0,NULL,'active'); +CREATE TABLE `sys_metadata_commit` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `package_id` varchar(255), `operation` varchar(255), `message` text, `actor` text, `ai_model` text, `parent_commit_id` varchar(64), `event_seq_start` float, `event_seq_end` float, `items` text, `item_count` float, primary key (`id`)); +CREATE TABLE `sys_metadata_history` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `event_seq` float, `name` varchar(255), `type` varchar(100), `version` float, `package_id` text, `operation_type` varchar(255), `metadata` text, `checksum` varchar(80), `previous_checksum` text, `change_note` text, `source` text, `recorded_by` varchar(255), `recorded_at` datetime, primary key (`id`)); +INSERT INTO "sys_metadata_history" ("id","created_at","updated_at","created_by","updated_by","event_seq","name","type","version","package_id","operation_type","metadata","checksum","previous_checksum","change_note","source","recorded_by","recorded_at") VALUES('21bddfdc-e210-4313-91c2-45e07b6dc1d3','2026-12-02T15:14:35.606Z','2026-12-02T15:14:35.606Z',NULL,NULL,1,'crm18_contact','view',1,NULL,'create','{"object":"crm18_contact","list":{"label":"All Contacts","type":"grid","columns":[{"field":"name"},{"field":"account"},{"field":"status"},{"field":"salary"}],"sort":[{"field":"name","order":"asc"}],"pagination":{"pageSize":25},"bulkActions":["crm18_close_contact","crm18_flag_contact"]},"name":"crm18_contact"}','sha256:cd4643d7687775aef2e19ee94ecaa47546388535d979be0bedfceca383d870c4',NULL,NULL,'protocol.saveMetaItem','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-02T15:14:35.598Z'); +CREATE TABLE `sys_migration` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `last_run_at` datetime, `verified_at` datetime, `applied_at` datetime, `blocking` float, `advisory` float, `details` text, `deviation_observed_at` datetime, `deviation_detail` text, `columns_moved_at` datetime, primary key (`id`)); +INSERT INTO "sys_migration" ("id","created_at","updated_at","created_by","updated_by","last_run_at","verified_at","applied_at","blocking","advisory","details","deviation_observed_at","deviation_detail","columns_moved_at") VALUES('adr-0131-organization-ownership','2026-12-02T15:14:21.471Z','2026-12-02T15:14:21.471Z',NULL,NULL,'2026-12-02T15:14:21.464Z','2026-12-02T15:14:21.464Z',NULL,0,0,'{"birth":{"shapeGeneration":1,"platformVersion":"18.6.0","createdAt":"2026-12-02T15:14:21.464Z"}}',NULL,NULL,NULL); +INSERT INTO "sys_migration" ("id","created_at","updated_at","created_by","updated_by","last_run_at","verified_at","applied_at","blocking","advisory","details","deviation_observed_at","deviation_detail","columns_moved_at") VALUES('adr-0104-file-references','2026-12-02T15:14:21.676Z','2026-12-02T15:14:21.676Z',NULL,NULL,'2026-12-02T15:14:21.672Z','2026-12-02T15:14:21.672Z',NULL,0,0,'{"attested":"datastore-created-empty"}',NULL,NULL,NULL); +INSERT INTO "sys_migration" ("id","created_at","updated_at","created_by","updated_by","last_run_at","verified_at","applied_at","blocking","advisory","details","deviation_observed_at","deviation_detail","columns_moved_at") VALUES('adr-0104-value-shapes','2026-12-02T15:14:21.682Z','2026-12-02T15:14:21.682Z',NULL,NULL,'2026-12-02T15:14:21.672Z','2026-12-02T15:14:21.672Z',NULL,0,0,'{"attested":"datastore-created-empty"}',NULL,NULL,NULL); +INSERT INTO "sys_migration" ("id","created_at","updated_at","created_by","updated_by","last_run_at","verified_at","applied_at","blocking","advisory","details","deviation_observed_at","deviation_detail","columns_moved_at") VALUES('adr-0093-membership-backfill','2026-12-02T15:14:21.940Z','2026-12-02T15:14:21.940Z',NULL,NULL,'2026-12-02T15:14:21.939Z',NULL,'2026-12-02T15:14:21.939Z',0,NULL,'{"policy":"auto","scanned":0,"bound":0,"skipped":0}',NULL,NULL,NULL); +INSERT INTO "sys_migration" ("id","created_at","updated_at","created_by","updated_by","last_run_at","verified_at","applied_at","blocking","advisory","details","deviation_observed_at","deviation_detail","columns_moved_at") VALUES('adr-0093-default-org-owner-bind','2026-12-02T15:14:23.115Z','2026-12-02T15:14:23.115Z',NULL,NULL,'2026-12-02T15:14:23.115Z',NULL,'2026-12-02T15:14:23.115Z',0,NULL,'{"outcome":"bound","organizationId":"org_mx69o0q4fm2fxl02"}',NULL,NULL,NULL); +CREATE TABLE `sys_migration_journal` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `run_id` varchar(64), `seq` float, `kind` varchar(255), `migration_id` varchar(128), `plan_hash` text, `chunk_index` float, `attempt` float, `detail` text, primary key (`id`)); +CREATE TABLE `sys_notification` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `topic` varchar(200), `payload` text, `severity` varchar(255) default 'info', `suppressed_channels` text, `dedup_key` varchar(255), `source_object` varchar(100), `source_id` varchar(100), `actor_id` varchar(255), primary key (`id`)); +CREATE TABLE `sys_notification_delivery` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `notification_id` varchar(255), `recipient_id` varchar(255), `recipient_user_id` varchar(255), `channel` varchar(64), `topic` text, `digest_key` varchar(331), `payload` text, `status` varchar(255) default 'pending', `attempts` float default '0', `partition_key` float default '0', `claimed_by` text, `claimed_at` float, `next_attempt_at` float, `last_attempted_at` float, `error` text, primary key (`id`)); +CREATE TABLE `sys_notification_preference` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `user_id` varchar(255), `topic` varchar(200) default '*', `channel` varchar(64) default '*', `enabled` boolean default '1', `digest` varchar(255) default 'none', `quiet_hours` text, primary key (`id`)); +CREATE TABLE `sys_notification_receipt` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `notification_id` varchar(255), `delivery_id` text, `user_id` varchar(255), `channel` varchar(64), `state` varchar(255) default 'delivered', `at` datetime, primary key (`id`)); +CREATE TABLE `sys_notification_template` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `topic` varchar(200), `channel` varchar(64) default 'email', `locale` varchar(16) default 'en', `version` float default '1', `subject` text, `body` text, `format` varchar(255) default 'markdown', `is_active` boolean default '1', primary key (`id`)); +CREATE TABLE `sys_oauth_access_token` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `token` text, `client_id` varchar(255), `session_id` varchar(255), `user_id` varchar(255), `refresh_id` varchar(255), `reference_id` text, `authorization_code_id` varchar(255), `resources` text, `requested_user_info_claims` text, `scopes` text, `expires_at` datetime, `revoked` datetime, `confirmation` text, primary key (`id`)); +CREATE TABLE `sys_oauth_application` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `name` text, `icon` varchar(255), `uri` varchar(255), `contacts` text, `tos` varchar(255), `policy` varchar(255), `metadata` text, `client_id` varchar(255), `client_discovery_id` text, `client_secret` text, `redirect_uris` text, `post_logout_redirect_uris` text, `type` varchar(255) default 'web', `public` boolean, `require_pkce` boolean, `token_endpoint_auth_method` text, `grant_types` text, `response_types` text, `scopes` text, `client_credentials_scopes` text, `subject_type` text, `jwks` text, `jwks_uri` varchar(255), `dpop_bound_access_tokens` boolean default '0', `disabled` boolean default '0', `skip_consent` boolean, `enable_end_session` boolean, `backchannel_logout_uri` varchar(255), `backchannel_logout_session_required` boolean, `software_id` text, `software_version` text, `software_statement` text, `user_id` varchar(255), `reference_id` varchar(255), primary key (`id`)); +CREATE TABLE `sys_oauth_client_assertion` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `expires_at` datetime, primary key (`id`)); +CREATE TABLE `sys_oauth_client_resource` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `client_id` varchar(255), `resource_id` varchar(255), `metadata` text, primary key (`id`)); +CREATE TABLE `sys_oauth_consent` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `client_id` varchar(255), `user_id` varchar(255), `reference_id` text, `resources` text, `requested_user_info_claims` text, `scopes` text, `last_used_at` datetime, primary key (`id`)); +CREATE TABLE `sys_oauth_refresh_token` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `token` text, `client_id` varchar(255), `session_id` varchar(255), `user_id` varchar(255), `reference_id` text, `authorization_code_id` varchar(255), `resources` text, `requested_user_info_claims` text, `scopes` text, `expires_at` datetime, `revoked` datetime, `rotated_at` datetime, `rotation_replay_response` text, `rotation_replay_expires_at` datetime, `auth_time` datetime, `confirmation` text, primary key (`id`)); +CREATE TABLE `sys_oauth_resource` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `identifier` varchar(255), `name` text, `access_token_ttl` float, `refresh_token_ttl` float, `signing_algorithm` text, `signing_key_id` text, `allowed_scopes` text, `custom_claims` text, `dpop_bound_access_tokens_required` boolean default '0', `disabled` boolean default '0', `policy_version` float default '1', `metadata` text, primary key (`id`)); +INSERT INTO "sys_oauth_resource" ("id","created_at","updated_at","identifier","name","access_token_ttl","refresh_token_ttl","signing_algorithm","signing_key_id","allowed_scopes","custom_claims","dpop_bound_access_tokens_required","disabled","policy_version","metadata") VALUES('5zTKhJsS7i7oOdsoX98P03mfCJSfCEp2','2026-12-02T15:14:22.026Z','2026-12-02T15:14:22.026Z','http://localhost:38735/api/v1/mcp','http://localhost:38735/api/v1/mcp',NULL,NULL,NULL,NULL,NULL,NULL,0,0,1,NULL); +CREATE TABLE `sys_organization` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `name` varchar(255), `slug` varchar(255), `logo` varchar(255), `metadata` text, `require_mfa` boolean default '0', `timezone` text, `parent_organization_id` varchar(255), `sort_order` float, primary key (`id`)); +INSERT INTO "sys_organization" ("id","created_at","updated_at","name","slug","logo","metadata","require_mfa","timezone","parent_organization_id","sort_order") VALUES('org_mx69o0q4fm2fxl02','2026-12-02T15:14:21.485Z','2026-12-02T15:14:21.485Z','Default Organization','default',NULL,NULL,0,NULL,NULL,NULL); +CREATE TABLE sys_packages ( + id TEXT NOT NULL, + version TEXT NOT NULL, + manifest TEXT NOT NULL, + metadata TEXT NOT NULL, + hash TEXT NOT NULL, + created_at TEXT DEFAULT CURRENT_TIMESTAMP, + updated_at TEXT DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (id, version) + ); +CREATE TABLE `sys_personal_view` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `user_id` varchar(255), `object_name` varchar(255), `label` text, `config` text, primary key (`id`)); +CREATE TABLE `sys_platform_setting` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `namespace` varchar(64), `key` varchar(128), `value` text, `encrypted` boolean default '0', `locked` boolean default '0', `locked_reason` text, `value_enc` text, `updated_by` varchar(255), primary key (`id`)); +INSERT INTO "sys_platform_setting" ("id","created_at","updated_at","created_by","namespace","key","value","encrypted","locked","locked_reason","value_enc","updated_by") VALUES('KdXx5J2BTv_SUJM7','2026-12-02T15:14:22.148Z','2026-12-02T15:14:22.148Z',NULL,'auth','api_key_policy_started_at','"2026-12-02T15:14:22.123Z"',0,0,NULL,NULL,NULL); +CREATE TABLE `sys_platform_setting_audit` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `namespace` varchar(128), `key` text, `scope` varchar(255) default 'global', `action` varchar(255), `actor_id` varchar(255), `source` varchar(255) default 'api', `reason` text, `old_hash` text, `new_hash` text, `encrypted` boolean default '0', `request_id` text, primary key (`id`)); +INSERT INTO "sys_platform_setting_audit" ("id","created_at","updated_at","created_by","updated_by","namespace","key","scope","action","actor_id","source","reason","old_hash","new_hash","encrypted","request_id") VALUES('rqmDXgbXwyu0yG3S','2026-12-02T15:14:22.166Z','2026-12-02T15:14:22.166Z',NULL,NULL,'auth','api_key_policy_started_at','global','set',NULL,'api',NULL,NULL,'sha256:5e48eb605ea9209a85ae6e404d5e01c6705a4004e5f7768d9a7bfa50e06adf46',0,NULL); +CREATE TABLE `sys_queue` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `name` varchar(100), `label` text, `description` text, primary key (`id`)); +CREATE TABLE `sys_queue_member` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `queue` varchar(100), `queue_package` text, `recipient_type` varchar(255) default 'position', `recipient_id` varchar(200), primary key (`id`)); +CREATE TABLE `sys_record_share` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `object_name` varchar(100), `record_id` varchar(100), `recipient_type` varchar(255) default 'user', `recipient_id` varchar(100), `access_level` varchar(255) default 'read', `source` varchar(255) default 'manual', `source_id` varchar(200), `granted_by` varchar(255), `reason` text, primary key (`id`)); +CREATE TABLE `sys_recycle_bin` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `object_name` varchar(255), `record_id` varchar(255), `record_count` float, `snapshot` text, `deleted_by` varchar(255), `deleted_at` datetime, `retention_days` float, `purge_after` datetime, `organization_id` varchar(255) not null, primary key (`id`)); +CREATE TABLE `sys_scim_connection_binding` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `connection_id` varchar(255), `connection_key` varchar(512), `provisioning_domain_id` varchar(255), `decommission_status` text default 'active', `decommissioned_at` datetime, `decommission_cursor_user_id` text, `decommission_reconciled_user_count` float default '0', `decommission_batch_count` float default '0', `decommission_revision` float default '0', `decommission_completed_at` datetime, `decommission_lease_id` text, `decommission_lease_expires_at` datetime, primary key (`id`)); +CREATE TABLE `sys_scim_connection_credential` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `connection_id` varchar(255), `provisioning_domain_id` text, `organization_id` varchar(255) not null, `label` text, `token_digest` varchar(255), `token_hint` text, `active` boolean default '1', `expires_at` datetime, `last_used_at` datetime, `user_id` varchar(255), primary key (`id`)); +CREATE TABLE `sys_scim_group` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `connection_id` varchar(255), `provisioning_domain_id` text, `revision` float default '0', `display_name` text, `display_name_key` varchar(512), `external_id` text, `external_id_key` varchar(512), `order_key` varchar(512), primary key (`id`)); +CREATE TABLE `sys_scim_group_member` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `connection_id` text, `group_id` varchar(255), `scim_user_id` varchar(255), `membership_key` varchar(512), primary key (`id`)); +CREATE TABLE `sys_scim_identity_tombstone` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `connection_id` varchar(255), `provisioning_domain_id` text, `external_id` text, `external_id_key` varchar(512), `user_id` varchar(255), `profile` text, `deleted_at` datetime, primary key (`id`)); +CREATE TABLE `sys_scim_projection_grant` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `connection_id` varchar(255), `provisioning_domain_id` text, `scim_user_id` varchar(255), `user_id` varchar(255), `source_kind` text, `source_id` text, `source_value` text, `role` text, `grant_key` varchar(512), primary key (`id`)); +CREATE TABLE `sys_scim_subject` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `user_id` varchar(255), `profile_source_id` text, `revision` float, primary key (`id`)); +CREATE TABLE `sys_scim_user` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `connection_id` varchar(255), `provisioning_domain_id` text, `user_id` varchar(255), `connection_user_key` varchar(512), `user_name` text, `user_name_key` varchar(512), `primary_email` text, `work_email_value_index` text, `email_value_index` text, `display_name` text, `formatted_name` text, `given_name` text, `family_name` text, `serialized_emails` text, `serialized_attributes` text, `external_id` text, `external_id_key` varchar(512), `active` boolean, `order_key` varchar(512), primary key (`id`)); +CREATE TABLE `sys_secret` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `rotated_at` datetime, `namespace` varchar(128), `key` varchar(128), `kms_key_id` varchar(256), `alg` text default 'aes-256-gcm', `version` float default '1', `ciphertext` text, primary key (`id`)); +CREATE TABLE `sys_seed_landed_key` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `object_name` varchar(255), `seed_key` text, `organization_id` varchar(255) not null, primary key (`id`)); +CREATE TABLE `sys_session` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `user_id` varchar(255), `expires_at` datetime, `last_activity_at` datetime, `revoked_at` datetime, `revoke_reason` text, `active_organization_id` varchar(255), `active_team_id` varchar(255), `ip_address` text, `user_agent` text, `impersonated_by` varchar(255), `token` varchar(255), primary key (`id`)); +INSERT INTO "sys_session" ("id","created_at","updated_at","user_id","expires_at","last_activity_at","revoked_at","revoke_reason","active_organization_id","active_team_id","ip_address","user_agent","impersonated_by","token") VALUES('kQe0jKhuDw2sYFd0woCwpB3g5086q7To','2026-12-02T15:14:23.145Z','2026-12-02T15:14:23.145Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-09T15:14:23.137Z','2026-12-02T15:14:23.145Z',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL,'127.0.0.1','node',NULL,'zNym9mb8OGgCTQePkvaOGRndWqnWAJd9'); +INSERT INTO "sys_session" ("id","created_at","updated_at","user_id","expires_at","last_activity_at","revoked_at","revoke_reason","active_organization_id","active_team_id","ip_address","user_agent","impersonated_by","token") VALUES('OZ8p5AoGQAKP87p88eVszd5ssqaNH3zm','2026-12-02T15:14:23.466Z','2026-12-02T15:14:23.466Z','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','2026-12-09T15:14:23.458Z','2026-12-02T15:14:23.466Z',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL,'127.0.0.1','node',NULL,'Cok3x2Gqf2OSaNMcZhFD1L95tM6h4m6O'); +INSERT INTO "sys_session" ("id","created_at","updated_at","user_id","expires_at","last_activity_at","revoked_at","revoke_reason","active_organization_id","active_team_id","ip_address","user_agent","impersonated_by","token") VALUES('hcw4uNEy48GMcvZjN2O7J2FqzcMp0g78','2026-12-02T15:14:24.087Z','2026-12-02T15:14:24.087Z','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','2026-12-09T15:14:24.080Z','2026-12-02T15:14:24.087Z',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL,'127.0.0.1','node',NULL,'1jGdGRH57oRQ7RsWHFLXZRcCJmRX1YZP'); +INSERT INTO "sys_session" ("id","created_at","updated_at","user_id","expires_at","last_activity_at","revoked_at","revoke_reason","active_organization_id","active_team_id","ip_address","user_agent","impersonated_by","token") VALUES('gfu3W4RbYNEklf1489jEr57ROs36XgB3','2026-12-02T15:14:24.397Z','2026-12-02T15:14:24.397Z','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','2026-12-09T15:14:24.390Z','2026-12-02T15:14:24.397Z',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL,'127.0.0.1','node',NULL,'WD1lX4oPXFUfpe84Qm9C4AGK13Xrvkcj'); +INSERT INTO "sys_session" ("id","created_at","updated_at","user_id","expires_at","last_activity_at","revoked_at","revoke_reason","active_organization_id","active_team_id","ip_address","user_agent","impersonated_by","token") VALUES('PUZXdpx9Kgr03bACPjTkvdSc4PUTvC1S','2026-12-02T15:14:35.008Z','2026-12-02T15:14:35.008Z','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','2026-12-09T15:14:35.001Z','2026-12-02T15:14:35.008Z',NULL,NULL,'org_mx69o0q4fm2fxl02',NULL,'127.0.0.1','node',NULL,'I9d3adHUeQOZHjKE2lOqUAFxsrlNDsDa'); +CREATE TABLE `sys_setting` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `namespace` varchar(64), `key` varchar(128), `scope` varchar(255) default 'tenant', `user_id` varchar(255), `value` text, `encrypted` boolean default '0', `locked` boolean default '0', `locked_reason` text, `value_enc` text, `updated_by` varchar(255), primary key (`id`)); +CREATE TABLE `sys_setting_audit` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `namespace` varchar(128), `key` text, `scope` varchar(255), `action` varchar(255), `actor_id` varchar(255), `source` varchar(255) default 'api', `reason` text, `old_hash` text, `new_hash` text, `encrypted` boolean default '0', `request_id` text, primary key (`id`)); +CREATE TABLE `sys_share_link` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `updated_by` varchar(255), `token` varchar(64), `object_name` varchar(100), `record_id` varchar(100), `permission` varchar(255) default 'view', `audience` varchar(255) default 'link_only', `expires_at` datetime, `email_allowlist` text, `password_hash` text, `redact_fields` text, `label` text, `revoked_at` datetime, `created_by` varchar(255), `last_used_at` datetime, `use_count` float default '0', primary key (`id`)); +CREATE TABLE `sys_sharing_rule` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `organization_id` varchar(255) not null, `name` varchar(100), `label` text, `description` text, `object_name` varchar(100), `criteria_json` text, `recipient_type` varchar(255) default 'business_unit', `recipient_id` text, `access_level` varchar(255) default 'read', `active` boolean default '1', `managed_by` varchar(255) default 'admin', `package_id` text, `customized` boolean default '0', primary key (`id`)); +CREATE TABLE `sys_sso_provider` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `provider_id` varchar(255), `issuer` text, `domain` varchar(255), `domain_verified` boolean default '0', `oidc_config` text, `saml_config` text, `allow_idp_initiated` boolean default '0', `allow_jit` boolean default '0', `skip_user_info` boolean default '0', `sign_out_of_idp` boolean default '0', `user_id` varchar(255), `organization_id` text, `oidc_client_secret` varchar(255), primary key (`id`)); +CREATE TABLE `sys_sync_run` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `organization_id` varchar(255) not null, `mapping` varchar(255), `mapping_package` varchar(255), `target_object` text, `source_kind` varchar(255), `source` text, `datasource` text, `read_path` varchar(255), `job_run_id` text, `trigger` varchar(255), `status` varchar(255) default 'running', `started_at` datetime, `ended_at` datetime, `read_count` float default '0', `created_count` float default '0', `updated_count` float default '0', `refused_count` float default '0', `watermark_field` text, `watermark_from` text, `watermark_committed` text, `committed_at` datetime, `holds_position` boolean default '0', `failure_reason` text, `failure` text, primary key (`id`)); +CREATE TABLE `sys_team` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `name` varchar(255), `organization_id` varchar(255) not null, `member_count` float default '0', primary key (`id`)); +CREATE TABLE `sys_team_member` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `team_id` varchar(255), `user_id` varchar(255), `membership_key` varchar(255), primary key (`id`)); +CREATE TABLE `sys_trusted_key` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `key_id` varchar(128), `public_key` text, `fingerprint` varchar(80), `source` varchar(255) default 'local', `status` varchar(255) default 'active', `added_by` text, `added_at` datetime, primary key (`id`)); +CREATE TABLE `sys_two_factor` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `user_id` varchar(255), `secret` text, `backup_codes` text, `verified` boolean default '1', `failed_verification_count` float default '0', `locked_until` datetime, primary key (`id`)); +CREATE TABLE `sys_upload_session` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `file_id` text, `key` text, `filename` text, `mime_type` text, `total_size` float, `chunk_size` float, `total_chunks` float, `uploaded_chunks` float, `uploaded_size` float, `parts` text, `resume_token` text, `backend_upload_id` text, `scope` text, `bucket` text, `metadata` text, `status` varchar(255), `started_at` datetime, `expires_at` datetime, primary key (`id`)); +CREATE TABLE `sys_user` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `name` text, `email` varchar(255), `email_verified` boolean default '0', `two_factor_enabled` boolean default '0', `role` text, `banned` boolean default '0', `ban_reason` text, `ban_expires` datetime, `failed_login_count` float default '0', `locked_until` datetime, `password_changed_at` datetime, `phone_number` varchar(32), `phone_number_verified` boolean default '0', `must_change_password` boolean default '0', `mfa_required_at` datetime, `last_login_at` datetime, `last_login_ip` text, `ai_access` boolean default '0', `principal_kind` varchar(255) default 'human', `accountable_user_id` varchar(255), `image` varchar(255), `locale` text, `manager_id` varchar(255), `primary_business_unit_id` varchar(255), `source` varchar(255) default 'env_native', primary key (`id`)); +INSERT INTO "sys_user" ("id","created_at","updated_at","name","email","email_verified","two_factor_enabled","role","banned","ban_reason","ban_expires","failed_login_count","locked_until","password_changed_at","phone_number","phone_number_verified","must_change_password","mfa_required_at","last_login_at","last_login_ip","ai_access","principal_kind","accountable_user_id","image","locale","manager_id","primary_business_unit_id","source") VALUES('B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','2026-12-02T15:14:23.020Z','2026-12-02T15:14:23.166Z','Owner','owner@crm18.test',0,0,'user',0,NULL,NULL,0,NULL,'2026-12-02T15:14:23.164Z',NULL,0,0,NULL,NULL,NULL,0,'human',NULL,NULL,NULL,NULL,NULL,'env_native'); +INSERT INTO "sys_user" ("id","created_at","updated_at","name","email","email_verified","two_factor_enabled","role","banned","ban_reason","ban_expires","failed_login_count","locked_until","password_changed_at","phone_number","phone_number_verified","must_change_password","mfa_required_at","last_login_at","last_login_ip","ai_access","principal_kind","accountable_user_id","image","locale","manager_id","primary_business_unit_id","source") VALUES('80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','2026-12-02T15:14:23.203Z','2026-12-02T15:14:24.097Z','Member','member@crm18.test',0,0,'user',0,NULL,NULL,0,NULL,'2026-12-02T15:14:23.928Z',NULL,0,0,NULL,'2026-12-02T15:14:24.095Z','127.0.0.1',0,'human',NULL,NULL,NULL,NULL,NULL,'env_native'); +INSERT INTO "sys_user" ("id","created_at","updated_at","name","email","email_verified","two_factor_enabled","role","banned","ban_reason","ban_expires","failed_login_count","locked_until","password_changed_at","phone_number","phone_number_verified","must_change_password","mfa_required_at","last_login_at","last_login_ip","ai_access","principal_kind","accountable_user_id","image","locale","manager_id","primary_business_unit_id","source") VALUES('1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','2026-12-02T15:14:24.122Z','2026-12-02T15:14:35.015Z','Auditor','auditor@crm18.test',0,0,'user',0,NULL,NULL,0,NULL,'2026-12-02T15:14:24.841Z',NULL,0,0,NULL,'2026-12-02T15:14:35.014Z','127.0.0.1',0,'human',NULL,NULL,NULL,NULL,NULL,'env_native'); +CREATE TABLE `sys_user_device` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `device_id` varchar(255), `user_id` varchar(255), `vendor` varchar(255), `token` varchar(512), `platform` varchar(255), `app_id` text, `locale` text, `origin` text, `name` text, `enabled` boolean default '1', `invalidated_at` datetime, `last_seen_at` datetime, primary key (`id`)); +CREATE TABLE `sys_user_permission_set` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `user_id` varchar(255), `permission_set` varchar(100), `organization_id` varchar(255) not null, `permission_set_package` varchar(255), `granted_by` varchar(255), `valid_from` datetime, `valid_until` datetime, `reason` text, `last_certified_at` datetime, `certified_by` varchar(255), primary key (`id`)); +INSERT INTO "sys_user_permission_set" ("id","created_at","updated_at","created_by","updated_by","user_id","permission_set","organization_id","permission_set_package","granted_by","valid_from","valid_until","reason","last_certified_at","certified_by") VALUES('ups_mx69o1y9dsixh1ek','2026-12-02T15:14:23.074Z','2026-12-02T15:14:23.074Z',NULL,NULL,'B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','admin_full_access','org_mx69o0q4fm2fxl02','com.objectstack.plugin-security',NULL,NULL,NULL,NULL,NULL,NULL); +INSERT INTO "sys_user_permission_set" ("id","created_at","updated_at","created_by","updated_by","user_id","permission_set","organization_id","permission_set_package","granted_by","valid_from","valid_until","reason","last_certified_at","certified_by") VALUES('ups_mx69o1z2cfb821nx','2026-12-02T15:14:23.102Z','2026-12-02T15:14:23.102Z',NULL,NULL,'B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','organization_admin_no_bypass','org_mx69o0q4fm2fxl02','com.objectstack.plugin-security',NULL,NULL,NULL,'auto-org-admin-grant: granted from membership grade ''owner'' (sys_member mem_mx69o1ypy4ozz8g7) → organization_admin_no_bypass',NULL,NULL); +INSERT INTO "sys_user_permission_set" ("id","created_at","updated_at","created_by","updated_by","user_id","permission_set","organization_id","permission_set_package","granted_by","valid_from","valid_until","reason","last_certified_at","certified_by") VALUES('zPvFJMFMTDciSum6','2026-12-02T15:14:35.077Z','2026-12-02T15:14:35.077Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7','crm18_member','org_mx69o0q4fm2fxl02','com.example.crm18','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8',NULL,NULL,NULL,NULL,NULL); +INSERT INTO "sys_user_permission_set" ("id","created_at","updated_at","created_by","updated_by","user_id","permission_set","organization_id","permission_set_package","granted_by","valid_from","valid_until","reason","last_certified_at","certified_by") VALUES('mqpjWWjiULAXBZs7','2026-12-02T15:14:35.123Z','2026-12-02T15:14:35.123Z','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8','1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF','crm18_auditor','org_mx69o0q4fm2fxl02','com.example.crm18','B4YBMHge1KjrzPLMHd56oOcApyQj8qx8',NULL,NULL,NULL,NULL,NULL); +CREATE TABLE `sys_user_position` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `created_by` varchar(255), `updated_by` varchar(255), `user_id` varchar(255), `position` varchar(100), `business_unit_id` varchar(255), `organization_id` varchar(255) not null, `granted_by` varchar(255), `valid_from` datetime, `valid_until` datetime, `reason` text, `delegated_from` varchar(255), `last_certified_at` datetime, `certified_by` varchar(255), primary key (`id`)); +CREATE TABLE `sys_user_preference` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `organization_id` varchar(255) not null, `created_by` varchar(255), `updated_by` varchar(255), `user_id` varchar(255), `key` varchar(255), `value` text, primary key (`id`)); +CREATE TABLE `sys_verification` (`id` varchar(255), `created_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `updated_at` datetime default (strftime('%Y-%m-%dT%H:%M:%fZ', 'now')), `value` text, `expires_at` datetime, `identifier` varchar(255), primary key (`id`)); +CREATE INDEX `idx_crm18_account_created_at_id` on `crm18_account` (`created_at`, `id`); +CREATE INDEX `idx_crm18_account_owner_id` on `crm18_account` (`owner_id`); +CREATE INDEX `idx_crm18_contact_account` on `crm18_contact` (`account`); +CREATE INDEX `idx_crm18_contact_created_at_id` on `crm18_contact` (`created_at`, `id`); +CREATE INDEX `idx_crm18_contact_owner_id` on `crm18_contact` (`owner_id`); +CREATE INDEX `idx_crm18_contact_referred_by` on `crm18_contact` (`referred_by`); +CREATE INDEX `idx_crm18_note_created_at_id` on `crm18_note` (`created_at`, `id`); +CREATE INDEX `idx_crm18_note_owner_id` on `crm18_note` (`owner_id`); +CREATE INDEX `idx_sys_account_created_at_id` on `sys_account` (`created_at`, `id`); +CREATE INDEX `idx_sys_account_user_id` on `sys_account` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_account_provider_id_account_id` on `sys_account` (`provider_id`, `account_id`); +CREATE INDEX `idx_sys_activity__r20261202_actor_id` on `sys_activity__r20261202` (`actor_id`); +CREATE INDEX `idx_sys_activity__r20261202_environment_id` on `sys_activity__r20261202` (`environment_id`); +CREATE INDEX `idx_sys_activity__r20261202_object_name_record_id` on `sys_activity__r20261202` (`object_name`, `record_id`); +CREATE INDEX `idx_sys_activity__r20261202_timestamp` on `sys_activity__r20261202` (`timestamp`); +CREATE INDEX `idx_sys_activity__r20261202_type` on `sys_activity__r20261202` (`type`); +CREATE INDEX `idx_sys_api_key_active_organization_id` on `sys_api_key` (`active_organization_id`); +CREATE INDEX `idx_sys_api_key_created_at_id` on `sys_api_key` (`created_at`, `id`); +CREATE INDEX `idx_sys_api_key_prefix` on `sys_api_key` (`prefix`); +CREATE INDEX `idx_sys_api_key_revoked` on `sys_api_key` (`revoked`); +CREATE INDEX `idx_sys_api_key_user_id` on `sys_api_key` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_api_key_key` on `sys_api_key` (`key`); +CREATE INDEX `idx_sys_assignment_cursor_created_at_id` on `sys_assignment_cursor` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_assignment_cursor_organization_id_rule_entry` on `sys_assignment_cursor` (`organization_id`, `rule`, `entry`); +CREATE INDEX `idx_sys_assignment_rule_created_at_id` on `sys_assignment_rule` (`created_at`, `id`); +CREATE INDEX `idx_sys_assignment_rule_object_name_active` on `sys_assignment_rule` (`object_name`, `active`); +CREATE INDEX `idx_sys_assignment_rule_organization_id` on `sys_assignment_rule` (`organization_id`); +CREATE UNIQUE INDEX `uniq_sys_assignment_rule_organization_id_name` on `sys_assignment_rule` (`organization_id`, `name`); +CREATE INDEX `idx_sys_attachment_created_at_id` on `sys_attachment` (`created_at`, `id`); +CREATE INDEX `idx_sys_attachment_file_id` on `sys_attachment` (`file_id`); +CREATE INDEX `idx_sys_attachment_parent_object_parent_id_created_at` on `sys_attachment` (`parent_object`, `parent_id`, `created_at`); +CREATE INDEX `idx_sys_attachment_uploaded_by` on `sys_attachment` (`uploaded_by`); +CREATE INDEX `idx_sys_audience_binding_suggestion_created_at_id` on `sys_audience_binding_suggestion` (`created_at`, `id`); +CREATE INDEX `idx_sys_audience_binding_suggestion_package_id` on `sys_audience_binding_suggestion` (`package_id`); +CREATE INDEX `idx_sys_audience_binding_suggestion_resolved_by` on `sys_audience_binding_suggestion` (`resolved_by`); +CREATE INDEX `idx_sys_audience_binding_suggestion_status` on `sys_audience_binding_suggestion` (`status`); +CREATE UNIQUE INDEX `uniq_sys_audience_binding_suggestion_a736dc5a` on `sys_audience_binding_suggestion` (`organization_id`, `package_id`, `permission_set_name`, `anchor`); +CREATE INDEX `idx_sys_audit_amendment_created_at_id` on `sys_audit_amendment` (`created_at`, `id`); +CREATE INDEX `idx_sys_audit_amendment_row_id` on `sys_audit_amendment` (`row_id`); +CREATE INDEX `idx_sys_audit_amendment_sealed_object_chain_key_kind` on `sys_audit_amendment` (`sealed_object`, `chain_key`, `kind`); +CREATE INDEX `idx_sys_audit_checkpoint_created_at_id` on `sys_audit_checkpoint` (`created_at`, `id`); +CREATE INDEX `idx_sys_audit_checkpoint_sealed_object_window_start` on `sys_audit_checkpoint` (`sealed_object`, `window_start`); +CREATE UNIQUE INDEX `uniq_sys_audit_checkpoint_sealed_object_chain_key_sequence` on `sys_audit_checkpoint` (`sealed_object`, `chain_key`, `sequence`); +CREATE INDEX `idx_sys_audit_log_action` on `sys_audit_log` (`action`); +CREATE INDEX `idx_sys_audit_log_created_at` on `sys_audit_log` (`created_at`); +CREATE INDEX `idx_sys_audit_log_created_at_id` on `sys_audit_log` (`created_at`, `id`); +CREATE INDEX `idx_sys_audit_log_object_name_record_id` on `sys_audit_log` (`object_name`, `record_id`); +CREATE INDEX `idx_sys_audit_log_tenant_id` on `sys_audit_log` (`tenant_id`); +CREATE INDEX `idx_sys_audit_log_user_id` on `sys_audit_log` (`user_id`); +CREATE INDEX `idx_sys_audit_signing_key_created_at_id` on `sys_audit_signing_key` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_audit_signing_key_fingerprint` on `sys_audit_signing_key` (`fingerprint`); +CREATE INDEX `idx_sys_automation_run_correlation` on `sys_automation_run` (`correlation`); +CREATE INDEX `idx_sys_automation_run_created_at_id` on `sys_automation_run` (`created_at`, `id`); +CREATE INDEX `idx_sys_automation_run_flow_name_started_at` on `sys_automation_run` (`flow_name`, `started_at`); +CREATE INDEX `idx_sys_automation_run_flow_name_status` on `sys_automation_run` (`flow_name`, `status`); +CREATE INDEX `idx_sys_automation_run_status_created_at` on `sys_automation_run` (`status`, `created_at`); +CREATE INDEX `idx_sys_automation_run_status_updated_at` on `sys_automation_run` (`status`, `updated_at`); +CREATE INDEX `idx_sys_automation_run_trigger_object_trigger_record_id` on `sys_automation_run` (`trigger_object`, `trigger_record_id`); +CREATE INDEX `idx_sys_business_unit_active` on `sys_business_unit` (`active`); +CREATE INDEX `idx_sys_business_unit_created_at_id` on `sys_business_unit` (`created_at`, `id`); +CREATE INDEX `idx_sys_business_unit_manager_user_id` on `sys_business_unit` (`manager_user_id`); +CREATE INDEX `idx_sys_business_unit_organization_id` on `sys_business_unit` (`organization_id`); +CREATE INDEX `idx_sys_business_unit_parent_business_unit_id` on `sys_business_unit` (`parent_business_unit_id`); +CREATE UNIQUE INDEX `uniq_sys_business_unit_code_organization_id` on `sys_business_unit` (`code`, `organization_id`); +CREATE INDEX `idx_sys_business_unit_member_created_at_id` on `sys_business_unit_member` (`created_at`, `id`); +CREATE INDEX `idx_sys_business_unit_member_is_primary` on `sys_business_unit_member` (`is_primary`); +CREATE INDEX `idx_sys_business_unit_member_user_id` on `sys_business_unit_member` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_business_unit_member_business_unit_id_user_id` on `sys_business_unit_member` (`business_unit_id`, `user_id`); +CREATE INDEX `idx_sys_comment_author_id` on `sys_comment` (`author_id`); +CREATE INDEX `idx_sys_comment_created_at_id` on `sys_comment` (`created_at`, `id`); +CREATE INDEX `idx_sys_comment_object_name_record_id` on `sys_comment` (`object_name`, `record_id`); +CREATE INDEX `idx_sys_comment_parent_id` on `sys_comment` (`parent_id`); +CREATE INDEX `idx_sys_comment_thread_id_created_at` on `sys_comment` (`thread_id`, `created_at`); +CREATE INDEX `idx_sys_comment_reaction_created_at_id` on `sys_comment_reaction` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_comment_reaction_96ccd30b` on `sys_comment_reaction` (`organization_id`, `comment_id`, `emoji`, `user_id`); +CREATE INDEX `idx_sys_connector_connection_created_at_id` on `sys_connector_connection` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_connector_connection_418b410f` on `sys_connector_connection` (`organization_id`, `connector_package`, `connector_name`); +CREATE UNIQUE INDEX uniq_sys_connector_connection_packageless ON sys_connector_connection (organization_id, connector_name) WHERE connector_package IS NULL; +CREATE INDEX `idx_sys_connector_credential_created_at_id` on `sys_connector_credential` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_connector_credential_ref` on `sys_connector_credential` (`ref`); +CREATE INDEX `idx_sys_device_code_created_at_id` on `sys_device_code` (`created_at`, `id`); +CREATE INDEX `idx_sys_device_code_status` on `sys_device_code` (`status`); +CREATE INDEX `idx_sys_device_code_user_id` on `sys_device_code` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_device_code_device_code` on `sys_device_code` (`device_code`); +CREATE UNIQUE INDEX `uniq_sys_device_code_user_code` on `sys_device_code` (`user_code`); +CREATE INDEX `idx_sys_email_created_at_id` on `sys_email` (`created_at`, `id`); +CREATE INDEX `idx_sys_email_related_object_related_id` on `sys_email` (`related_object`, `related_id`); +CREATE INDEX `idx_sys_email_sent_by` on `sys_email` (`sent_by`); +CREATE INDEX `idx_sys_email_status_created_at` on `sys_email` (`status`, `created_at`); +CREATE INDEX `idx_sys_email_template_active` on `sys_email_template` (`active`); +CREATE INDEX `idx_sys_email_template_category` on `sys_email_template` (`category`); +CREATE INDEX `idx_sys_email_template_created_at_id` on `sys_email_template` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_email_template_organization_id_name_locale` on `sys_email_template` (`organization_id`, `name`, `locale`); +CREATE INDEX `idx_sys_exchange_rate_created_at_id` on `sys_exchange_rate` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_exchange_rate_0e2e5c03` on `sys_exchange_rate` (`organization_id`, `currency`, `effective_date`); +CREATE INDEX `idx_sys_file_created_at_id` on `sys_file` (`created_at`, `id`); +CREATE INDEX `idx_sys_file_owner_id` on `sys_file` (`owner_id`); +CREATE INDEX `idx_sys_file_ref_object_ref_id` on `sys_file` (`ref_object`, `ref_id`); +CREATE INDEX `idx_sys_flow_credential_created_at_id` on `sys_flow_credential` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_flow_credential_flow_name_state_position` on `sys_flow_credential` (`flow_name`, `state`, `position`); +CREATE INDEX `idx_sys_flow_dispatch_created_at` on `sys_flow_dispatch` (`created_at`); +CREATE INDEX `idx_sys_flow_dispatch_created_at_id` on `sys_flow_dispatch` (`created_at`, `id`); +CREATE INDEX `idx_sys_http_delivery_created_at_id` on `sys_http_delivery` (`created_at`, `id`); +CREATE INDEX `idx_sys_http_delivery_source_ref_id` on `sys_http_delivery` (`source`, `ref_id`); +CREATE INDEX `idx_sys_http_delivery_status_claimed_at` on `sys_http_delivery` (`status`, `claimed_at`); +CREATE INDEX `idx_sys_http_delivery_status_partition_key_next_retry_at` on `sys_http_delivery` (`status`, `partition_key`, `next_retry_at`); +CREATE UNIQUE INDEX `uniq_sys_http_delivery_source_dedup_key` on `sys_http_delivery` (`source`, `dedup_key`); +CREATE INDEX `idx_sys_identity_email_created_at_id` on `sys_identity_email` (`created_at`, `id`); +CREATE INDEX `idx_sys_identity_email_related_object_related_id` on `sys_identity_email` (`related_object`, `related_id`); +CREATE INDEX `idx_sys_identity_email_sent_by` on `sys_identity_email` (`sent_by`); +CREATE INDEX `idx_sys_identity_email_status_created_at` on `sys_identity_email` (`status`, `created_at`); +CREATE INDEX `idx_sys_idp_group_mapping_created_at_id` on `sys_idp_group_mapping` (`created_at`, `id`); +CREATE INDEX `idx_sys_idp_group_mapping_organization_id` on `sys_idp_group_mapping` (`organization_id`); +CREATE INDEX `idx_sys_idp_group_mapping_source_kind_source_id` on `sys_idp_group_mapping` (`source_kind`, `source_id`); +CREATE INDEX `idx_sys_import_job_created_at_id` on `sys_import_job` (`created_at`, `id`); +CREATE INDEX `idx_sys_import_job_created_by_created_at` on `sys_import_job` (`created_by`, `created_at`); +CREATE INDEX `idx_sys_import_job_object_name_created_at` on `sys_import_job` (`object_name`, `created_at`); +CREATE INDEX `idx_sys_import_job_status_created_at` on `sys_import_job` (`status`, `created_at`); +CREATE INDEX `idx_sys_inbox_message_actor_id` on `sys_inbox_message` (`actor_id`); +CREATE INDEX `idx_sys_inbox_message_created_at_id` on `sys_inbox_message` (`created_at`, `id`); +CREATE INDEX `idx_sys_invitation_business_unit_id` on `sys_invitation` (`business_unit_id`); +CREATE INDEX `idx_sys_invitation_created_at_id` on `sys_invitation` (`created_at`, `id`); +CREATE INDEX `idx_sys_invitation_email` on `sys_invitation` (`email`); +CREATE INDEX `idx_sys_invitation_expires_at` on `sys_invitation` (`expires_at`); +CREATE INDEX `idx_sys_invitation_inviter_id` on `sys_invitation` (`inviter_id`); +CREATE INDEX `idx_sys_invitation_organization_id` on `sys_invitation` (`organization_id`); +CREATE INDEX `idx_sys_invitation_team_id` on `sys_invitation` (`team_id`); +CREATE INDEX `idx_sys_job_active` on `sys_job` (`active`); +CREATE INDEX `idx_sys_job_created_at_id` on `sys_job` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_job_name` on `sys_job` (`name`); +CREATE INDEX `idx_sys_job_queue_created_at_id` on `sys_job_queue` (`created_at`, `id`); +CREATE INDEX `idx_sys_job_queue_idempotency_key_queue` on `sys_job_queue` (`idempotency_key`, `queue`); +CREATE INDEX `idx_sys_job_queue_queue_status_priority_scheduled_for` on `sys_job_queue` (`queue`, `status`, `priority`, `scheduled_for`); +CREATE INDEX `idx_sys_job_queue_status` on `sys_job_queue` (`status`); +CREATE INDEX `idx_sys_job_run_created_at_id` on `sys_job_run` (`created_at`, `id`); +CREATE INDEX `idx_sys_job_run_job_name_started_at` on `sys_job_run` (`job_name`, `started_at`); +CREATE INDEX `idx_sys_job_run_status_started_at` on `sys_job_run` (`status`, `started_at`); +CREATE INDEX `idx_sys_jwks_created_at_id` on `sys_jwks` (`created_at`, `id`); +CREATE INDEX `idx_sys_lifecycle_state_created_at_id` on `sys_lifecycle_state` (`created_at`, `id`); +CREATE INDEX `idx_sys_member_created_at_id` on `sys_member` (`created_at`, `id`); +CREATE INDEX `idx_sys_member_user_id` on `sys_member` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_member_organization_id_user_id` on `sys_member` (`organization_id`, `user_id`); +CREATE INDEX `idx_sys_metadata_created_at_id` on `sys_metadata` (`created_at`, `id`); +CREATE INDEX `idx_sys_metadata_environment_id` on `sys_metadata` (`environment_id`); +CREATE INDEX `idx_sys_metadata_namespace` on `sys_metadata` (`namespace`); +CREATE UNIQUE INDEX idx_sys_metadata_overlay_active ON sys_metadata (type, name, COALESCE(package_id, ''), COALESCE(bundle_member, '')) WHERE state = 'active'; +CREATE UNIQUE INDEX idx_sys_metadata_overlay_draft ON sys_metadata (type, name, COALESCE(package_id, ''), COALESCE(bundle_member, '')) WHERE state = 'draft'; +CREATE INDEX `idx_sys_metadata_package_version_id` on `sys_metadata` (`package_version_id`); +CREATE INDEX `idx_sys_metadata_state` on `sys_metadata` (`state`); +CREATE INDEX `idx_sys_metadata_type_scope` on `sys_metadata` (`type`, `scope`); +CREATE INDEX `idx_sys_metadata_activation_created_at_id` on `sys_metadata_activation` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_metadata_activation_metadata_type_package_id_name` on `sys_metadata_activation` (`metadata_type`, `package_id`, `name`); +CREATE UNIQUE INDEX uniq_sys_metadata_activation_packageless ON sys_metadata_activation (metadata_type, name) WHERE package_id IS NULL; +CREATE INDEX `idx_sys_metadata_audit_actor_occurred_at` on `sys_metadata_audit` (`actor`, `occurred_at`); +CREATE INDEX `idx_sys_metadata_audit_created_at_id` on `sys_metadata_audit` (`created_at`, `id`); +CREATE INDEX `idx_sys_metadata_audit_occurred_at` on `sys_metadata_audit` (`occurred_at`); +CREATE INDEX `idx_sys_metadata_audit_outcome` on `sys_metadata_audit` (`outcome`); +CREATE INDEX `idx_sys_metadata_audit_type_name_occurred_at` on `sys_metadata_audit` (`type`, `name`, `occurred_at`); +CREATE INDEX `idx_sys_metadata_commit_created_at` on `sys_metadata_commit` (`created_at`); +CREATE INDEX `idx_sys_metadata_commit_created_at_id` on `sys_metadata_commit` (`created_at`, `id`); +CREATE INDEX `idx_sys_metadata_commit_package_id_created_at` on `sys_metadata_commit` (`package_id`, `created_at`); +CREATE INDEX `idx_sys_metadata_commit_parent_commit_id` on `sys_metadata_commit` (`parent_commit_id`); +CREATE INDEX `idx_sys_metadata_history_created_at_id` on `sys_metadata_history` (`created_at`, `id`); +CREATE INDEX `idx_sys_metadata_history_operation_type` on `sys_metadata_history` (`operation_type`); +CREATE INDEX `idx_sys_metadata_history_recorded_at` on `sys_metadata_history` (`recorded_at`); +CREATE INDEX `idx_sys_metadata_history_recorded_by` on `sys_metadata_history` (`recorded_by`); +CREATE INDEX `idx_sys_metadata_history_type_name` on `sys_metadata_history` (`type`, `name`); +CREATE INDEX `idx_sys_metadata_history_type_name_checksum` on `sys_metadata_history` (`type`, `name`, `checksum`); +CREATE INDEX `idx_sys_metadata_history_type_name_recorded_at` on `sys_metadata_history` (`type`, `name`, `recorded_at`); +CREATE UNIQUE INDEX `uniq_sys_metadata_history_event_seq` on `sys_metadata_history` (`event_seq`); +CREATE UNIQUE INDEX `uniq_sys_metadata_history_type_name_version` on `sys_metadata_history` (`type`, `name`, `version`); +CREATE INDEX `idx_sys_migration_created_at_id` on `sys_migration` (`created_at`, `id`); +CREATE INDEX `idx_sys_migration_journal_created_at_id` on `sys_migration_journal` (`created_at`, `id`); +CREATE INDEX `idx_sys_migration_journal_migration_id` on `sys_migration_journal` (`migration_id`); +CREATE INDEX `idx_sys_migration_journal_run_id_kind` on `sys_migration_journal` (`run_id`, `kind`); +CREATE UNIQUE INDEX `uniq_sys_migration_journal_run_id_seq` on `sys_migration_journal` (`run_id`, `seq`); +CREATE INDEX `idx_sys_notification_actor_id` on `sys_notification` (`actor_id`); +CREATE INDEX `idx_sys_notification_created_at_id` on `sys_notification` (`created_at`, `id`); +CREATE INDEX `idx_sys_notification_source_object_source_id` on `sys_notification` (`source_object`, `source_id`); +CREATE INDEX `idx_sys_notification_topic_created_at` on `sys_notification` (`topic`, `created_at`); +CREATE UNIQUE INDEX `uniq_sys_notification_dedup_key` on `sys_notification` (`dedup_key`); +CREATE INDEX `idx_sys_notification_delivery_ad1bb657` on `sys_notification_delivery` (`digest_key`, `status`, `next_attempt_at`); +CREATE INDEX `idx_sys_notification_delivery_b3081700` on `sys_notification_delivery` (`status`, `partition_key`, `next_attempt_at`); +CREATE INDEX `idx_sys_notification_delivery_created_at_id` on `sys_notification_delivery` (`created_at`, `id`); +CREATE INDEX `idx_sys_notification_delivery_notification_id` on `sys_notification_delivery` (`notification_id`); +CREATE INDEX `idx_sys_notification_delivery_recipient_user_id` on `sys_notification_delivery` (`recipient_user_id`); +CREATE INDEX `idx_sys_notification_delivery_status_claimed_at` on `sys_notification_delivery` (`status`, `claimed_at`); +CREATE UNIQUE INDEX `uniq_sys_notification_delivery_f5f71821` on `sys_notification_delivery` (`notification_id`, `recipient_id`, `channel`); +CREATE INDEX `idx_sys_notification_preference_created_at_id` on `sys_notification_preference` (`created_at`, `id`); +CREATE INDEX `idx_sys_notification_preference_topic` on `sys_notification_preference` (`topic`); +CREATE UNIQUE INDEX uniq_sys_notification_preference_a22d7d27 ON sys_notification_preference (organization_id, COALESCE(user_id, ''), topic, channel); +CREATE INDEX `idx_sys_notification_receipt_created_at_id` on `sys_notification_receipt` (`created_at`, `id`); +CREATE INDEX `idx_sys_notification_receipt_user_id_state` on `sys_notification_receipt` (`user_id`, `state`); +CREATE UNIQUE INDEX `uniq_sys_notification_receipt_bb478a66` on `sys_notification_receipt` (`notification_id`, `user_id`, `channel`); +CREATE INDEX `idx_sys_notification_template_created_at_id` on `sys_notification_template` (`created_at`, `id`); +CREATE INDEX `idx_sys_notification_template_topic` on `sys_notification_template` (`topic`); +CREATE INDEX `idx_sys_notification_template_topic_channel_locale` on `sys_notification_template` (`topic`, `channel`, `locale`); +CREATE INDEX `idx_sys_oauth_access_token_authorization_code_id` on `sys_oauth_access_token` (`authorization_code_id`); +CREATE INDEX `idx_sys_oauth_access_token_client_id` on `sys_oauth_access_token` (`client_id`); +CREATE INDEX `idx_sys_oauth_access_token_created_at_id` on `sys_oauth_access_token` (`created_at`, `id`); +CREATE INDEX `idx_sys_oauth_access_token_refresh_id` on `sys_oauth_access_token` (`refresh_id`); +CREATE INDEX `idx_sys_oauth_access_token_session_id` on `sys_oauth_access_token` (`session_id`); +CREATE INDEX `idx_sys_oauth_access_token_user_id` on `sys_oauth_access_token` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_oauth_access_token_token` on `sys_oauth_access_token` (`token`); +CREATE INDEX `idx_sys_oauth_application_created_at_id` on `sys_oauth_application` (`created_at`, `id`); +CREATE INDEX `idx_sys_oauth_application_reference_id` on `sys_oauth_application` (`reference_id`); +CREATE INDEX `idx_sys_oauth_application_user_id` on `sys_oauth_application` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_oauth_application_client_id` on `sys_oauth_application` (`client_id`); +CREATE INDEX `idx_sys_oauth_client_assertion_created_at_id` on `sys_oauth_client_assertion` (`created_at`, `id`); +CREATE INDEX `idx_sys_oauth_client_resource_client_id` on `sys_oauth_client_resource` (`client_id`); +CREATE INDEX `idx_sys_oauth_client_resource_created_at_id` on `sys_oauth_client_resource` (`created_at`, `id`); +CREATE INDEX `idx_sys_oauth_client_resource_resource_id` on `sys_oauth_client_resource` (`resource_id`); +CREATE INDEX `idx_sys_oauth_consent_client_id` on `sys_oauth_consent` (`client_id`); +CREATE INDEX `idx_sys_oauth_consent_created_at_id` on `sys_oauth_consent` (`created_at`, `id`); +CREATE INDEX `idx_sys_oauth_consent_user_id` on `sys_oauth_consent` (`user_id`); +CREATE INDEX `idx_sys_oauth_refresh_token_authorization_code_id` on `sys_oauth_refresh_token` (`authorization_code_id`); +CREATE INDEX `idx_sys_oauth_refresh_token_client_id` on `sys_oauth_refresh_token` (`client_id`); +CREATE INDEX `idx_sys_oauth_refresh_token_created_at_id` on `sys_oauth_refresh_token` (`created_at`, `id`); +CREATE INDEX `idx_sys_oauth_refresh_token_session_id` on `sys_oauth_refresh_token` (`session_id`); +CREATE INDEX `idx_sys_oauth_refresh_token_user_id` on `sys_oauth_refresh_token` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_oauth_refresh_token_token` on `sys_oauth_refresh_token` (`token`); +CREATE INDEX `idx_sys_oauth_resource_created_at_id` on `sys_oauth_resource` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_oauth_resource_identifier` on `sys_oauth_resource` (`identifier`); +CREATE INDEX `idx_sys_organization_created_at_id` on `sys_organization` (`created_at`, `id`); +CREATE INDEX `idx_sys_organization_name` on `sys_organization` (`name`); +CREATE INDEX `idx_sys_organization_parent_organization_id` on `sys_organization` (`parent_organization_id`); +CREATE UNIQUE INDEX `uniq_sys_organization_slug` on `sys_organization` (`slug`); +CREATE INDEX idx_packages_latest + ON sys_packages(id, created_at DESC) + ; +CREATE INDEX `idx_sys_personal_view_created_at_id` on `sys_personal_view` (`created_at`, `id`); +CREATE INDEX `idx_sys_personal_view_user_id_object_name` on `sys_personal_view` (`user_id`, `object_name`); +CREATE INDEX `idx_sys_platform_setting_created_at_id` on `sys_platform_setting` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_platform_setting_namespace_key` on `sys_platform_setting` (`namespace`, `key`); +CREATE INDEX `idx_sys_platform_setting_audit_actor_id_created_at` on `sys_platform_setting_audit` (`actor_id`, `created_at`); +CREATE INDEX `idx_sys_platform_setting_audit_created_at_id` on `sys_platform_setting_audit` (`created_at`, `id`); +CREATE INDEX `idx_sys_platform_setting_audit_namespace_created_at` on `sys_platform_setting_audit` (`namespace`, `created_at`); +CREATE INDEX `idx_sys_queue_created_at_id` on `sys_queue` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_queue_organization_id_name` on `sys_queue` (`organization_id`, `name`); +CREATE INDEX `idx_sys_queue_member_created_at_id` on `sys_queue_member` (`created_at`, `id`); +CREATE INDEX `idx_sys_queue_member_queue` on `sys_queue_member` (`queue`); +CREATE INDEX `idx_sys_queue_member_recipient_type_recipient_id` on `sys_queue_member` (`recipient_type`, `recipient_id`); +CREATE UNIQUE INDEX `uniq_sys_queue_member_4d856f1f` on `sys_queue_member` (`organization_id`, `queue`, `recipient_type`, `recipient_id`); +CREATE INDEX `idx_sys_record_share_created_at_id` on `sys_record_share` (`created_at`, `id`); +CREATE INDEX `idx_sys_record_share_granted_by` on `sys_record_share` (`granted_by`); +CREATE INDEX `idx_sys_record_share_object_name_recipient_type_recipient_id` on `sys_record_share` (`object_name`, `recipient_type`, `recipient_id`); +CREATE INDEX `idx_sys_record_share_object_name_record_id` on `sys_record_share` (`object_name`, `record_id`); +CREATE INDEX `idx_sys_record_share_source_source_id` on `sys_record_share` (`source`, `source_id`); +CREATE INDEX `idx_sys_recycle_bin_created_at_id` on `sys_recycle_bin` (`created_at`, `id`); +CREATE INDEX `idx_sys_recycle_bin_deleted_by` on `sys_recycle_bin` (`deleted_by`); +CREATE INDEX `idx_sys_recycle_bin_object_name_record_id` on `sys_recycle_bin` (`object_name`, `record_id`); +CREATE INDEX `idx_sys_recycle_bin_purge_after` on `sys_recycle_bin` (`purge_after`); +CREATE INDEX `idx_sys_scim_connection_binding_connection_id` on `sys_scim_connection_binding` (`connection_id`); +CREATE INDEX `idx_sys_scim_connection_binding_created_at_id` on `sys_scim_connection_binding` (`created_at`, `id`); +CREATE INDEX `idx_sys_scim_connection_binding_provisioning_domain_id` on `sys_scim_connection_binding` (`provisioning_domain_id`); +CREATE UNIQUE INDEX `uniq_sys_scim_connection_binding_connection_key` on `sys_scim_connection_binding` (`connection_key`); +CREATE INDEX `idx_sys_scim_connection_credential_connection_id` on `sys_scim_connection_credential` (`connection_id`); +CREATE INDEX `idx_sys_scim_connection_credential_created_at_id` on `sys_scim_connection_credential` (`created_at`, `id`); +CREATE INDEX `idx_sys_scim_connection_credential_organization_id` on `sys_scim_connection_credential` (`organization_id`); +CREATE INDEX `idx_sys_scim_connection_credential_user_id` on `sys_scim_connection_credential` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_scim_connection_credential_token_digest` on `sys_scim_connection_credential` (`token_digest`); +CREATE INDEX `idx_sys_scim_group_connection_id` on `sys_scim_group` (`connection_id`); +CREATE INDEX `idx_sys_scim_group_created_at_id` on `sys_scim_group` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_scim_group_display_name_key` on `sys_scim_group` (`display_name_key`); +CREATE UNIQUE INDEX `uniq_sys_scim_group_external_id_key` on `sys_scim_group` (`external_id_key`); +CREATE UNIQUE INDEX `uniq_sys_scim_group_order_key` on `sys_scim_group` (`order_key`); +CREATE INDEX `idx_sys_scim_group_member_created_at_id` on `sys_scim_group_member` (`created_at`, `id`); +CREATE INDEX `idx_sys_scim_group_member_group_id` on `sys_scim_group_member` (`group_id`); +CREATE INDEX `idx_sys_scim_group_member_scim_user_id` on `sys_scim_group_member` (`scim_user_id`); +CREATE UNIQUE INDEX `uniq_sys_scim_group_member_membership_key` on `sys_scim_group_member` (`membership_key`); +CREATE INDEX `idx_sys_scim_identity_tombstone_connection_id` on `sys_scim_identity_tombstone` (`connection_id`); +CREATE INDEX `idx_sys_scim_identity_tombstone_created_at_id` on `sys_scim_identity_tombstone` (`created_at`, `id`); +CREATE INDEX `idx_sys_scim_identity_tombstone_user_id` on `sys_scim_identity_tombstone` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_scim_identity_tombstone_external_id_key` on `sys_scim_identity_tombstone` (`external_id_key`); +CREATE INDEX `idx_sys_scim_projection_grant_connection_id` on `sys_scim_projection_grant` (`connection_id`); +CREATE INDEX `idx_sys_scim_projection_grant_created_at_id` on `sys_scim_projection_grant` (`created_at`, `id`); +CREATE INDEX `idx_sys_scim_projection_grant_scim_user_id` on `sys_scim_projection_grant` (`scim_user_id`); +CREATE INDEX `idx_sys_scim_projection_grant_user_id` on `sys_scim_projection_grant` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_scim_projection_grant_grant_key` on `sys_scim_projection_grant` (`grant_key`); +CREATE INDEX `idx_sys_scim_subject_created_at_id` on `sys_scim_subject` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_scim_subject_user_id` on `sys_scim_subject` (`user_id`); +CREATE INDEX `idx_sys_scim_user_connection_id` on `sys_scim_user` (`connection_id`); +CREATE INDEX `idx_sys_scim_user_created_at_id` on `sys_scim_user` (`created_at`, `id`); +CREATE INDEX `idx_sys_scim_user_user_id` on `sys_scim_user` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_scim_user_connection_user_key` on `sys_scim_user` (`connection_user_key`); +CREATE UNIQUE INDEX `uniq_sys_scim_user_external_id_key` on `sys_scim_user` (`external_id_key`); +CREATE UNIQUE INDEX `uniq_sys_scim_user_order_key` on `sys_scim_user` (`order_key`); +CREATE UNIQUE INDEX `uniq_sys_scim_user_user_name_key` on `sys_scim_user` (`user_name_key`); +CREATE INDEX `idx_sys_secret_created_at_id` on `sys_secret` (`created_at`, `id`); +CREATE INDEX `idx_sys_secret_kms_key_id` on `sys_secret` (`kms_key_id`); +CREATE INDEX `idx_sys_secret_namespace_key` on `sys_secret` (`namespace`, `key`); +CREATE INDEX `idx_sys_seed_landed_key_created_at_id` on `sys_seed_landed_key` (`created_at`, `id`); +CREATE INDEX `idx_sys_seed_landed_key_organization_id_object_name` on `sys_seed_landed_key` (`organization_id`, `object_name`); +CREATE INDEX `idx_sys_session_active_organization_id` on `sys_session` (`active_organization_id`); +CREATE INDEX `idx_sys_session_active_team_id` on `sys_session` (`active_team_id`); +CREATE INDEX `idx_sys_session_created_at_id` on `sys_session` (`created_at`, `id`); +CREATE INDEX `idx_sys_session_expires_at` on `sys_session` (`expires_at`); +CREATE INDEX `idx_sys_session_impersonated_by` on `sys_session` (`impersonated_by`); +CREATE INDEX `idx_sys_session_user_id` on `sys_session` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_session_token` on `sys_session` (`token`); +CREATE INDEX `idx_sys_setting_created_at_id` on `sys_setting` (`created_at`, `id`); +CREATE INDEX `idx_sys_setting_namespace_scope` on `sys_setting` (`namespace`, `scope`); +CREATE INDEX `idx_sys_setting_user_id_namespace` on `sys_setting` (`user_id`, `namespace`); +CREATE UNIQUE INDEX uniq_sys_setting_organization_id_namespace_key_scope_user_id ON sys_setting (organization_id, namespace, key, scope, COALESCE(user_id, '')); +CREATE INDEX `idx_sys_setting_audit_actor_id_created_at` on `sys_setting_audit` (`actor_id`, `created_at`); +CREATE INDEX `idx_sys_setting_audit_created_at_id` on `sys_setting_audit` (`created_at`, `id`); +CREATE INDEX `idx_sys_setting_audit_namespace_created_at` on `sys_setting_audit` (`namespace`, `created_at`); +CREATE INDEX `idx_sys_share_link_created_at_id` on `sys_share_link` (`created_at`, `id`); +CREATE INDEX `idx_sys_share_link_created_by_revoked_at` on `sys_share_link` (`created_by`, `revoked_at`); +CREATE INDEX `idx_sys_share_link_expires_at` on `sys_share_link` (`expires_at`); +CREATE INDEX `idx_sys_share_link_object_name_record_id` on `sys_share_link` (`object_name`, `record_id`); +CREATE UNIQUE INDEX `uniq_sys_share_link_token` on `sys_share_link` (`token`); +CREATE INDEX `idx_sys_sharing_rule_created_at_id` on `sys_sharing_rule` (`created_at`, `id`); +CREATE INDEX `idx_sys_sharing_rule_object_name_active` on `sys_sharing_rule` (`object_name`, `active`); +CREATE INDEX `idx_sys_sharing_rule_organization_id` on `sys_sharing_rule` (`organization_id`); +CREATE UNIQUE INDEX `uniq_sys_sharing_rule_organization_id_name` on `sys_sharing_rule` (`organization_id`, `name`); +CREATE INDEX `idx_sys_sso_provider_created_at_id` on `sys_sso_provider` (`created_at`, `id`); +CREATE INDEX `idx_sys_sso_provider_domain` on `sys_sso_provider` (`domain`); +CREATE INDEX `idx_sys_sso_provider_user_id` on `sys_sso_provider` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_sso_provider_provider_id` on `sys_sso_provider` (`provider_id`); +CREATE INDEX `idx_sys_sync_run_created_at_id` on `sys_sync_run` (`created_at`, `id`); +CREATE INDEX `idx_sys_sync_run_d41bc05b` on `sys_sync_run` (`mapping`, `mapping_package`, `organization_id`, `committed_at`); +CREATE INDEX `idx_sys_sync_run_mapping_started_at` on `sys_sync_run` (`mapping`, `started_at`); +CREATE INDEX `idx_sys_sync_run_status_created_at` on `sys_sync_run` (`status`, `created_at`); +CREATE INDEX `idx_sys_team_created_at_id` on `sys_team` (`created_at`, `id`); +CREATE INDEX `idx_sys_team_organization_id` on `sys_team` (`organization_id`); +CREATE UNIQUE INDEX `uniq_sys_team_name_organization_id` on `sys_team` (`name`, `organization_id`); +CREATE INDEX `idx_sys_team_member_created_at_id` on `sys_team_member` (`created_at`, `id`); +CREATE INDEX `idx_sys_team_member_user_id` on `sys_team_member` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_team_member_membership_key` on `sys_team_member` (`membership_key`); +CREATE UNIQUE INDEX `uniq_sys_team_member_team_id_user_id` on `sys_team_member` (`team_id`, `user_id`); +CREATE INDEX `idx_sys_trusted_key_created_at_id` on `sys_trusted_key` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_trusted_key_fingerprint` on `sys_trusted_key` (`fingerprint`); +CREATE UNIQUE INDEX `uniq_sys_trusted_key_key_id` on `sys_trusted_key` (`key_id`); +CREATE INDEX `idx_sys_two_factor_created_at_id` on `sys_two_factor` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_two_factor_user_id` on `sys_two_factor` (`user_id`); +CREATE INDEX `idx_sys_upload_session_created_at_id` on `sys_upload_session` (`created_at`, `id`); +CREATE INDEX `idx_sys_user_accountable_user_id` on `sys_user` (`accountable_user_id`); +CREATE INDEX `idx_sys_user_created_at` on `sys_user` (`created_at`); +CREATE INDEX `idx_sys_user_created_at_id` on `sys_user` (`created_at`, `id`); +CREATE INDEX `idx_sys_user_manager_id` on `sys_user` (`manager_id`); +CREATE INDEX `idx_sys_user_primary_business_unit_id` on `sys_user` (`primary_business_unit_id`); +CREATE UNIQUE INDEX `uniq_sys_user_email` on `sys_user` (`email`); +CREATE UNIQUE INDEX `uniq_sys_user_phone_number` on `sys_user` (`phone_number`); +CREATE INDEX `idx_sys_user_device_created_at_id` on `sys_user_device` (`created_at`, `id`); +CREATE UNIQUE INDEX `uniq_sys_user_device_token` on `sys_user_device` (`token`); +CREATE UNIQUE INDEX `uniq_sys_user_device_user_id_device_id` on `sys_user_device` (`user_id`, `device_id`); +CREATE INDEX `idx_sys_user_permission_set_certified_by` on `sys_user_permission_set` (`certified_by`); +CREATE INDEX `idx_sys_user_permission_set_created_at_id` on `sys_user_permission_set` (`created_at`, `id`); +CREATE INDEX `idx_sys_user_permission_set_granted_by` on `sys_user_permission_set` (`granted_by`); +CREATE INDEX `idx_sys_user_permission_set_organization_id` on `sys_user_permission_set` (`organization_id`); +CREATE INDEX `idx_sys_user_permission_set_user_id` on `sys_user_permission_set` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_user_permission_set_fbd7677c` on `sys_user_permission_set` (`user_id`, `permission_set`, `permission_set_package`, `organization_id`); +CREATE UNIQUE INDEX uniq_sys_user_permission_set_packageless ON sys_user_permission_set (user_id, permission_set, organization_id) WHERE permission_set_package IS NULL; +CREATE INDEX `idx_sys_user_position_business_unit_id` on `sys_user_position` (`business_unit_id`); +CREATE INDEX `idx_sys_user_position_certified_by` on `sys_user_position` (`certified_by`); +CREATE INDEX `idx_sys_user_position_created_at_id` on `sys_user_position` (`created_at`, `id`); +CREATE INDEX `idx_sys_user_position_delegated_from` on `sys_user_position` (`delegated_from`); +CREATE INDEX `idx_sys_user_position_granted_by` on `sys_user_position` (`granted_by`); +CREATE INDEX `idx_sys_user_position_organization_id` on `sys_user_position` (`organization_id`); +CREATE INDEX `idx_sys_user_position_position` on `sys_user_position` (`position`); +CREATE INDEX `idx_sys_user_position_user_id` on `sys_user_position` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_user_position_user_id_position_organization_id` on `sys_user_position` (`user_id`, `position`, `organization_id`); +CREATE INDEX `idx_sys_user_preference_created_at_id` on `sys_user_preference` (`created_at`, `id`); +CREATE INDEX `idx_sys_user_preference_user_id` on `sys_user_preference` (`user_id`); +CREATE UNIQUE INDEX `uniq_sys_user_preference_organization_id_user_id_key` on `sys_user_preference` (`organization_id`, `user_id`, `key`); +CREATE INDEX `idx_sys_verification_created_at_id` on `sys_verification` (`created_at`, `id`); +CREATE INDEX `idx_sys_verification_expires_at` on `sys_verification` (`expires_at`); +CREATE INDEX `idx_sys_verification_identifier` on `sys_verification` (`identifier`); +COMMIT; diff --git a/packages/qa/upgrade-source/fixture-db-18.6.0/manifest.json b/packages/qa/upgrade-source/fixture-db-18.6.0/manifest.json new file mode 100644 index 00000000000..7967615dff8 --- /dev/null +++ b/packages/qa/upgrade-source/fixture-db-18.6.0/manifest.json @@ -0,0 +1,136 @@ +{ + "people": { + "owner": { + "email": "owner@crm18.test", + "password": "Crm18!Owner-pass", + "name": "Owner", + "id": "B4YBMHge1KjrzPLMHd56oOcApyQj8qx8" + }, + "member": { + "email": "member@crm18.test", + "password": "Crm18!Member-pass", + "name": "Member", + "permissionSet": "crm18_member", + "id": "80Vg94KJDrdbhWawLsjXb8sDQbdpMiW7" + }, + "auditor": { + "email": "auditor@crm18.test", + "password": "Crm18!Auditor-pass", + "name": "Auditor", + "permissionSet": "crm18_auditor", + "id": "1gtMI2dvDvvZPKw57fpqgwXfIIRkQ8JF" + } + }, + "records": [ + { + "object": "crm18_account", + "id": "Za0K_bLbuHot3bok", + "name": "Acme", + "values": { + "name": "Acme", + "industry": "technology", + "status": "active", + "annual_revenue": 1200000, + "notes": "Key account, renewal in Q1" + } + }, + { + "object": "crm18_account", + "id": "NuOyrbcsb9xZeIr5", + "name": "Globex", + "values": { + "name": "Globex", + "industry": "finance", + "status": "inactive", + "annual_revenue": 500000, + "notes": "Paused after the audit" + } + }, + { + "object": "crm18_account", + "id": "cMYxu_0801wJ6HmI", + "name": "Initech", + "values": { + "name": "Initech", + "industry": "retail", + "status": "inactive", + "annual_revenue": 75000, + "notes": "Small, steady" + } + }, + { + "object": "crm18_contact", + "id": "P3kqdaCWIjxsAUkq", + "name": "Ada Lovelace", + "createdBy": "owner", + "values": { + "name": "Ada Lovelace", + "account": "Za0K_bLbuHot3bok", + "email": "ada@acme.test", + "salary": 150000 + } + }, + { + "object": "crm18_contact", + "id": "C7o2WVeswVQxUsXD", + "name": "Grace Hopper", + "createdBy": "owner", + "values": { + "name": "Grace Hopper", + "account": "Za0K_bLbuHot3bok", + "referred_by": "NuOyrbcsb9xZeIr5", + "email": "grace@acme.test", + "salary": 140000 + } + }, + { + "object": "crm18_contact", + "id": "dFhmYYU80eElB6nd", + "name": "Linus Pauling", + "createdBy": "owner", + "values": { + "name": "Linus Pauling", + "account": "NuOyrbcsb9xZeIr5", + "email": "linus@globex.test", + "salary": 120000 + } + }, + { + "object": "crm18_contact", + "id": "4Vo9mRADteWIDPlW", + "name": "Margaret Hamilton", + "createdBy": "member", + "values": { + "name": "Margaret Hamilton", + "account": "cMYxu_0801wJ6HmI", + "email": "margaret@initech.test", + "salary": 90000 + } + } + ], + "storedView": { + "name": "crm18_contact", + "droppedColumn": "email", + "columns": [ + "name", + "account", + "status", + "salary" + ], + "bulkActions": [ + "crm18_close_contact", + "crm18_flag_contact" + ] + }, + "observedOn18": { + "auditorContactRows": 4, + "auditorReadsSalary": true, + "memberAccountRows": 3, + "memberReadsAccountNotes": false, + "negativeRevenueStatus": 400, + "storedView": { + "provenance": "package", + "valid": true + } + } +} diff --git a/packages/qa/upgrade-source/fixture-db-18.6.0/provenance.json b/packages/qa/upgrade-source/fixture-db-18.6.0/provenance.json new file mode 100644 index 00000000000..16f373e2d4e --- /dev/null +++ b/packages/qa/upgrade-source/fixture-db-18.6.0/provenance.json @@ -0,0 +1,15 @@ +{ + "what": "The SQLite database a 18.6.0 install of fixture-18.6.0/ wrote, populated over HTTP, dumped to SQL text.", + "packages": "published 18.6.0 (npm registry): @objectstack/cli 18.6.0, @objectstack/spec 18.6.0", + "scaffold": "npx create-objectstack@18.6.0 crm18 --skip-skills, then the metadata authored with that install's `os generate` and edited by hand; see ../README.md", + "command": "node packages/qa/upgrade-source/generate-fixture-db.mjs", + "boot": "os start --artifact ./dist/objectstack.json (the installed 18.6.0 CLI), OS_DATABASE_URL=file:/fixture.db, OS_AUTH_SECRET and OS_SECRET_KEY = FIXTURE_ENV in the generator (published, not secret)", + "generated": "2026-12-02", + "node": "v22.23.5", + "pnpm": "10.31.0", + "sha256": { + "database.sql": "b544fcb78adde09cf647bef0f1235540afee23062cfd6475bc1a145e6094c56e", + "fixture.db (the binary 18.6.0 wrote, not committed)": "f9c7e6a664a7dafb09ca21bbc40781d867f85e1f8c92aa311f30adf8ff0c9b8b", + "manifest.json": "153a6f2c2bc220861dc33ce4e52f56e1b4b9e4ad03995774d8e4654d1cc4e10a" + } +} diff --git a/packages/qa/upgrade-source/generate-fixture-db.mjs b/packages/qa/upgrade-source/generate-fixture-db.mjs new file mode 100644 index 00000000000..2166c00ed17 --- /dev/null +++ b/packages/qa/upgrade-source/generate-fixture-db.mjs @@ -0,0 +1,340 @@ +#!/usr/bin/env node +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. +// +// generate-fixture-db.mjs — writes the upgrade-source gate's 18.6.0 database, +// ONCE, with the PUBLISHED 18.6.0 toolchain from the npm registry, and records +// how in `fixture-db-18.6.0/provenance.json`. Nothing in this checkout's +// packages is used: the fixture project is copied to a scratch directory, +// installed from the registry at the pins its package.json names (18.6.0), +// built and booted with that install's own `os`, and used over HTTP the way a +// user and an administrator would. Never hand-edit the outputs: re-run this. +// +// node packages/qa/upgrade-source/generate-fixture-db.mjs [--keep] +// +// Writes, under packages/qa/upgrade-source/fixture-db-18.6.0/: +// database.sql the SQLite database 18.6.0 wrote, as one deterministic SQL +// script (tables by name, rows by rowid, then indexes) — the +// text form the 18.0 upgrade harness fixture uses, so a +// change is a reviewable diff, not an opaque binary; +// manifest.json what was put in it, by stable key: the people and their +// passwords, every seeded record id, the stored view +// customization, and what 18.6.0 served for each read the +// gate asserts on 19 (the "18 outcome"); +// provenance.json the exact command, the versions that ran, and the hashes. +// +// Needs network access to the npm registry, pnpm on PATH, and Node >= 22.13 +// (`node:sqlite`). `--keep` leaves the scratch directory behind for a look. +import { spawn, spawnSync } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'; +import { createServer } from 'node:net'; +import { tmpdir } from 'node:os'; +import { dirname, join, resolve } from 'node:path'; +import { DatabaseSync } from 'node:sqlite'; +import { fileURLToPath } from 'node:url'; + +const HERE = dirname(fileURLToPath(import.meta.url)); +const FIXTURE = resolve(HERE, 'fixture-18.6.0'); +const OUT = resolve(HERE, 'fixture-db-18.6.0'); +const PUBLISHED = '18.6.0'; + +// Fixed, published, NOT secret: the database must be bootable by the gate on +// any runner, so whatever 18.6.0 seals with them must be openable again with +// the same values. They protect nothing. The key is 32 bytes as hex (what the +// crypto provider asks for), derived from a phrase so no key-shaped literal is +// committed; run.mjs derives it the same way. +export const FIXTURE_ENV = { + OS_AUTH_SECRET: 'upgrade-source-gate-fixture-auth-secret-not-a-secret', + OS_SECRET_KEY: createHash('sha256').update('upgrade-source-gate-fixture-secret-key-not-a-secret').digest('hex'), +}; + +export const PEOPLE = { + owner: { email: 'owner@crm18.test', password: 'Crm18!Owner-pass', name: 'Owner' }, + member: { email: 'member@crm18.test', password: 'Crm18!Member-pass', name: 'Member', permissionSet: 'crm18_member' }, + auditor: { email: 'auditor@crm18.test', password: 'Crm18!Auditor-pass', name: 'Auditor', permissionSet: 'crm18_auditor' }, +}; + +const ACCOUNTS = [ + { name: 'Acme', industry: 'technology', status: 'active', annual_revenue: 1200000, notes: 'Key account, renewal in Q1' }, + { name: 'Globex', industry: 'finance', status: 'inactive', annual_revenue: 500000, notes: 'Paused after the audit' }, + { name: 'Initech', industry: 'retail', status: 'inactive', annual_revenue: 75000, notes: 'Small, steady' }, +]; +// `account` / `referred_by` name an ACCOUNTS entry by its `name`; `by` is who creates it. +const CONTACTS = [ + { name: 'Ada Lovelace', account: 'Acme', email: 'ada@acme.test', salary: 150000, by: 'owner' }, + { name: 'Grace Hopper', account: 'Acme', referred_by: 'Globex', email: 'grace@acme.test', salary: 140000, by: 'owner' }, + { name: 'Linus Pauling', account: 'Globex', email: 'linus@globex.test', salary: 120000, by: 'owner' }, + { name: 'Margaret Hamilton', account: 'Initech', email: 'margaret@initech.test', salary: 90000, by: 'member' }, +]; +const STORED_VIEW = 'crm18_contact'; +const DROPPED_COLUMN = 'email'; + +function run(cmd, args, opts = {}) { + const r = spawnSync(cmd, args, { stdio: 'inherit', ...opts }); + if (r.status !== 0) throw new Error(`${cmd} ${args.join(' ')} exited ${r.status}`); +} + +function freePort() { + return new Promise((ok, fail) => { + const s = createServer(); + s.unref(); + s.on('error', fail); + s.listen(0, () => { + const { port } = s.address(); + s.close(() => ok(port)); + }); + }); +} + +const sha256 = (buf) => createHash('sha256').update(buf).digest('hex'); + +/** One SQL literal for one stored value; a string keeps its bytes exactly. */ +function literal(value) { + if (value === null) return 'NULL'; + if (typeof value === 'number' || typeof value === 'bigint') return String(value); + if (typeof value === 'string') return `'${value.replace(/'/g, "''")}'`; + return `X'${Buffer.from(value).toString('hex')}'`; +} +const ident = (name) => `"${name.replace(/"/g, '""')}"`; + +/** The whole database as one deterministic SQL script (the upgrade harness's dump, in plain JS). */ +function dumpSqliteToSql(file) { + const db = new DatabaseSync(file, { readOnly: true }); + try { + const tables = db + .prepare("SELECT name, sql FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%' ORDER BY name") + .all(); + const indexes = db + .prepare("SELECT sql FROM sqlite_master WHERE type = 'index' AND sql IS NOT NULL ORDER BY tbl_name, name") + .all(); + const out = ['PRAGMA foreign_keys=OFF;', 'BEGIN TRANSACTION;']; + for (const { name, sql } of tables) { + out.push(`${sql};`); + const rows = db.prepare(`SELECT * FROM ${ident(name)} ORDER BY rowid`); + rows.setReadBigInts(true); + for (const row of rows.all()) { + const cols = Object.keys(row); + out.push(`INSERT INTO ${ident(name)} (${cols.map(ident).join(',')}) VALUES(${cols.map((c) => literal(row[c])).join(',')});`); + } + } + for (const { sql } of indexes) out.push(`${sql};`); + out.push('COMMIT;', ''); + return out.join('\n'); + } finally { + db.close(); + } +} + +async function main() { + const keep = process.argv.includes('--keep'); + const work = mkdtempSync(join(tmpdir(), 'upgrade-source-gen-')); + const app = join(work, 'app'); + const dbFile = join(work, 'fixture.db'); + cpSync(FIXTURE, app, { recursive: true }); + console.log(`scratch: ${work}`); + + // 1. Install from the registry at the fixture's own pins, and prove it is 18.6.0. + run('pnpm', ['install', '--no-frozen-lockfile'], { cwd: app }); + const cliPkg = JSON.parse(readFileSync(join(app, 'node_modules/@objectstack/cli/package.json'), 'utf8')); + const specPkg = JSON.parse(readFileSync(join(app, 'node_modules/@objectstack/spec/package.json'), 'utf8')); + // Every @objectstack/* pin the fixture declares, installed at the published version, not just the two above. + const fixturePkg = JSON.parse(readFileSync(join(app, 'package.json'), 'utf8')); + const pins = [fixturePkg.dependencies, fixturePkg.devDependencies].flatMap((d) => Object.keys(d ?? {})).filter((n) => n.startsWith('@objectstack/')); + const off = pins + .map((n) => [n, JSON.parse(readFileSync(join(app, 'node_modules', n, 'package.json'), 'utf8')).version]) + .filter(([, v]) => v !== PUBLISHED); + if (off.length > 0) { + throw new Error(`installed ${off.map(([n, v]) => `${n}@${v}`).join(', ')}; every @objectstack/* pin must be the published ${PUBLISHED}`); + } + const os = join(app, 'node_modules/.bin/os'); + run(os, ['validate'], { cwd: app }); + run(os, ['build'], { cwd: app }); + + // 2. Boot it on a new SQLite file. + const port = await freePort(); + const base = `http://localhost:${port}/api/v1`; + const env = { ...process.env, ...FIXTURE_ENV, OS_DATABASE_URL: `file:${dbFile}` }; + const server = spawn(os, ['start', '--artifact', './dist/objectstack.json', '--port', String(port)], { + cwd: app, + env, + stdio: ['ignore', 'pipe', 'pipe'], + }); + let log = ''; + server.stdout.on('data', (d) => { log += d; }); + server.stderr.on('data', (d) => { log += d; }); + const exited = new Promise((ok) => server.on('exit', ok)); + try { + let healthy = false; + for (let i = 0; i < 60 && !healthy; i++) { + if (server.exitCode !== null) break; + healthy = await fetch(`${base}/health`).then((r) => r.ok, () => false); + if (!healthy) await new Promise((r) => setTimeout(r, 2000)); + } + if (!healthy) throw new Error(`18.6.0 never became healthy:\n${log}`); + + const manifest = await populate(base); + + // 3. Stop it cleanly, so every write is on disk before the dump. + server.kill('SIGTERM'); + await exited; + + const sql = dumpSqliteToSql(dbFile); + mkdirSync(OUT, { recursive: true }); + writeFileSync(join(OUT, 'database.sql'), sql); + writeFileSync(join(OUT, 'manifest.json'), `${JSON.stringify(manifest, null, 2)}\n`); + const pnpmVersion = spawnSync('pnpm', ['--version'], { encoding: 'utf8' }).stdout.trim(); + const provenance = { + what: 'The SQLite database a 18.6.0 install of fixture-18.6.0/ wrote, populated over HTTP, dumped to SQL text.', + packages: `published ${PUBLISHED} (npm registry): @objectstack/cli ${cliPkg.version}, @objectstack/spec ${specPkg.version}`, + scaffold: `npx create-objectstack@${PUBLISHED} crm18 --skip-skills, then the metadata authored with that install's \`os generate\` and edited by hand; see ../README.md`, + command: 'node packages/qa/upgrade-source/generate-fixture-db.mjs', + boot: `os start --artifact ./dist/objectstack.json (the installed ${PUBLISHED} CLI), OS_DATABASE_URL=file:/fixture.db, OS_AUTH_SECRET and OS_SECRET_KEY = FIXTURE_ENV in the generator (published, not secret)`, + generated: new Date().toISOString().slice(0, 10), + node: process.version, + pnpm: pnpmVersion, + sha256: { + 'database.sql': sha256(sql), + 'fixture.db (the binary 18.6.0 wrote, not committed)': sha256(readFileSync(dbFile)), + 'manifest.json': sha256(readFileSync(join(OUT, 'manifest.json'))), + }, + }; + writeFileSync(join(OUT, 'provenance.json'), `${JSON.stringify(provenance, null, 2)}\n`); + console.log(`wrote ${OUT}`); + } finally { + if (server.exitCode === null) server.kill('SIGKILL'); + if (!keep) rmSync(work, { recursive: true, force: true }); + } +} + +async function call(base, token, method, path, body) { + // The auth routes rate-limit sign-ins (429): wait the window out, as a + // person retrying would, rather than fail the generation on a throttle. + for (let attempt = 0; ; attempt++) { + const r = await callOnce(base, token, method, path, body); + if (r.status !== 429 || attempt >= 8) return r; + await new Promise((ok) => setTimeout(ok, 5000)); + } +} + +async function callOnce(base, token, method, path, body) { + const res = await fetch(`${base}${path}`, { + method, + // Node's fetch is a browser-shaped client, so the auth routes ask it for an + // Origin (curl is let through without one); the server's own origin is trusted. + headers: { 'Content-Type': 'application/json', Origin: new URL(base).origin, ...(token ? { Authorization: `Bearer ${token}` } : {}) }, + ...(body === undefined ? {} : { body: JSON.stringify(body) }), + }); + const text = await res.text(); + let json; + try { json = JSON.parse(text); } catch { json = text; } + return { status: res.status, json }; +} + +async function expectOk(p, what) { + const r = await p; + if (r.status < 200 || r.status > 299) throw new Error(`${what} answered ${r.status}: ${JSON.stringify(r.json).slice(0, 600)}`); + return r.json; +} + +const rowsOf = (body) => (Array.isArray(body) ? body : (body?.records ?? body?.data?.records ?? body?.value ?? body?.data ?? [])); + +async function populate(base) { + // People. The first sign-up is the install's administrator; after it + // self-registration is closed (invite-only), so the administrator creates the + // other two with a first password, and each signs in and sets their own, as + // the platform requires before anything else. + const tokens = {}; + const users = {}; + const owner = await expectOk( + call(base, null, 'POST', '/auth/sign-up/email', { email: PEOPLE.owner.email, password: PEOPLE.owner.password, name: PEOPLE.owner.name }), + 'sign-up owner', + ); + tokens.owner = owner.token; + users.owner = owner.user.id; + for (const key of ['member', 'auditor']) { + const p = PEOPLE[key]; + const first = `${p.password}-first`; + const made = await expectOk( + call(base, tokens.owner, 'POST', '/auth/admin/create-user', { email: p.email, password: first, name: p.name, role: 'user' }), + `create user ${key}`, + ); + users[key] = made.data?.user?.id ?? made.user?.id; + const signedIn = await expectOk(call(base, null, 'POST', '/auth/sign-in/email', { email: p.email, password: first }), `first sign-in ${key}`); + await expectOk( + call(base, signedIn.token, 'POST', '/auth/change-password', { currentPassword: first, newPassword: p.password }), + `change password ${key}`, + ); + const again = await expectOk(call(base, null, 'POST', '/auth/sign-in/email', { email: p.email, password: p.password }), `sign-in ${key}`); + tokens[key] = again.token; + } + for (const key of ['member', 'auditor']) { + await expectOk( + call(base, tokens.owner, 'POST', '/data/sys_user_permission_set', { user_id: users[key], permission_set: PEOPLE[key].permissionSet }), + `assign ${PEOPLE[key].permissionSet}`, + ); + } + + // Records. + const accountIds = {}; + const records = []; + for (const a of ACCOUNTS) { + const body = await expectOk(call(base, tokens.owner, 'POST', '/data/crm18_account', a), `create account ${a.name}`); + accountIds[a.name] = body.id; + records.push({ object: 'crm18_account', id: body.id, name: a.name, values: a }); + } + for (const c of CONTACTS) { + const { by, ...rest } = c; + const values = { ...rest, account: accountIds[c.account], ...(c.referred_by ? { referred_by: accountIds[c.referred_by] } : {}) }; + const body = await expectOk(call(base, tokens[by], 'POST', '/data/crm18_contact', values), `create contact ${c.name}`); + records.push({ object: 'crm18_contact', id: body.id, name: c.name, createdBy: by, values }); + } + + // The validation rule refuses on 18. + const refused = await call(base, tokens.owner, 'POST', '/data/crm18_account', { name: 'Negative Co', annual_revenue: -1 }); + if (refused.status < 400) throw new Error(`the validation rule did not refuse a negative revenue on 18.6.0 (status ${refused.status})`); + + // The Studio-style save: GET the view, drop a column, PUT the body back. + const got = await expectOk(call(base, tokens.owner, 'GET', `/meta/view/${STORED_VIEW}`), 'GET view'); + const item = { ...got.item }; + for (const k of Object.keys(item)) if (k.startsWith('_')) delete item[k]; + item.list = { ...item.list, columns: item.list.columns.filter((c) => c.field !== DROPPED_COLUMN) }; + if (!Array.isArray(item.list.bulkActions) || item.list.bulkActions.length === 0) { + throw new Error('the view to customize carries no list.bulkActions: the stored row would not have the shape the gate needs'); + } + await expectOk(call(base, tokens.owner, 'PUT', `/meta/view/${STORED_VIEW}`, item), 'PUT view'); + const stored = await expectOk(call(base, tokens.owner, 'GET', `/meta/view/${STORED_VIEW}`), 'GET view after save'); + const storedColumns = stored.item.list.columns.map((c) => c.field); + if (storedColumns.includes(DROPPED_COLUMN)) throw new Error('the view save did not take: the dropped column is still served'); + + // What 18.6.0 serves for the reads the gate asserts on 19. + const auditorContacts = rowsOf(await expectOk(call(base, tokens.auditor, 'GET', '/data/crm18_contact'), 'auditor reads contacts')); + const memberAccounts = rowsOf(await expectOk(call(base, tokens.member, 'GET', '/data/crm18_account'), 'member reads accounts')); + const observedOn18 = { + auditorContactRows: auditorContacts.length, + auditorReadsSalary: auditorContacts.length > 0 && auditorContacts.every((r) => r.salary !== undefined && r.salary !== null), + memberAccountRows: memberAccounts.length, + memberReadsAccountNotes: memberAccounts.some((r) => r.notes !== undefined && r.notes !== null), + negativeRevenueStatus: refused.status, + storedView: { provenance: stored.item._provenance ?? null, valid: stored.item._diagnostics?.valid ?? null }, + }; + + return { + people: Object.fromEntries(Object.entries(PEOPLE).map(([k, p]) => [k, { ...p, id: users[k] }])), + records, + storedView: { + name: STORED_VIEW, + droppedColumn: DROPPED_COLUMN, + columns: storedColumns, + bulkActions: stored.item.list.bulkActions ?? null, + }, + observedOn18, + }; +} + +if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + if (!existsSync(FIXTURE)) throw new Error(`no fixture at ${FIXTURE}`); + main().catch((e) => { + console.error(e?.stack ?? e); + process.exit(1); + }); +} diff --git a/packages/qa/upgrade-source/helper-wiring/crm-stack.ts b/packages/qa/upgrade-source/helper-wiring/crm-stack.ts new file mode 100644 index 00000000000..36b0bd7615c --- /dev/null +++ b/packages/qa/upgrade-source/helper-wiring/crm-stack.ts @@ -0,0 +1,56 @@ +import { defineStack } from '@objectstack/spec'; +import { ConnectorRestPlugin } from '@objectstack/connector-rest'; +import { ConnectorOpenApiPlugin } from '@objectstack/connector-openapi'; +import { ConnectorMcpPlugin } from '@objectstack/connector-mcp'; +import * as objects from './src/objects'; +import * as views from './src/views'; +import * as actions from './src/actions'; +import * as flows from './src/flows'; +import * as dashboards from './src/dashboards'; +import * as apps from './src/apps'; +import * as skills from './src/skills'; +import * as picklists from './src/picklists'; +import * as permissions from './src/security'; +import * as datasets from './src/datasets'; + +// The second wiring the upgrade-source gate walks: the same sources as the +// template's `objectstack.config.ts`, but the stack is BUILT by a helper this +// module exports and composed in the config with `composeStacks(…)` — the +// shape a larger app (HotCRM's `createHotCrmServiceStack(…)`) takes. + +const exportsOf = (barrel: M): M[keyof M][] => Object.values(barrel); + +export interface CrmStackOptions { + /** The package id; one helper builds the stack for more than one deployment. */ + id: string; +} + +/** The CRM package, built from the project's barrels. */ +export function createCrmStack(options: CrmStackOptions) { + return defineStack({ + manifest: { + id: options.id, + namespace: 'crm18', + version: '0.1.0', + type: 'app', + name: 'Crm18', + engines: { protocol: '^18' }, + }, + requires: ['automation', 'triggers'], + plugins: [ + new ConnectorRestPlugin(), + new ConnectorOpenApiPlugin(), + new ConnectorMcpPlugin(), + ], + objects: exportsOf(objects), + views: exportsOf(views), + actions: exportsOf(actions), + flows: exportsOf(flows), + dashboards: exportsOf(dashboards), + apps: exportsOf(apps), + skills: exportsOf(skills), + picklists: exportsOf(picklists), + permissions: exportsOf(permissions), + datasets: exportsOf(datasets), + }); +} diff --git a/packages/qa/upgrade-source/helper-wiring/objectstack.config.ts b/packages/qa/upgrade-source/helper-wiring/objectstack.config.ts new file mode 100644 index 00000000000..7b99618404f --- /dev/null +++ b/packages/qa/upgrade-source/helper-wiring/objectstack.config.ts @@ -0,0 +1,6 @@ +import { composeStacks } from '@objectstack/spec'; +import { createCrmStack } from './crm-stack'; + +// The helper-built wiring (see crm-stack.ts): the stack is the composition of +// what a helper returns, so no stack key in this file is a literal. +export default composeStacks([createCrmStack({ id: 'com.example.crm18' })]); diff --git a/packages/qa/upgrade-source/helper-wiring/package.json b/packages/qa/upgrade-source/helper-wiring/package.json new file mode 100644 index 00000000000..ad1d2c5318a --- /dev/null +++ b/packages/qa/upgrade-source/helper-wiring/package.json @@ -0,0 +1,38 @@ +{ + "name": "crm18-helper-wiring", + "version": "0.1.0", + "private": true, + "type": "module", + "engines": { + "pnpm": ">=10.15" + }, + "scripts": { + "dev": "objectstack dev", + "start": "objectstack start", + "build": "objectstack build", + "deploy": "objectstack deploy", + "validate": "objectstack validate", + "lint": "objectstack lint", + "typecheck": "tsc --noEmit", + "test": "vitest run" + }, + "dependencies": { + "@objectstack/spec": "18.6.0", + "@objectstack/runtime": "18.6.0", + "@objectstack/plugin-hono-server": "18.6.0", + "@objectstack/connector-rest": "18.6.0", + "@objectstack/connector-openapi": "18.6.0", + "@objectstack/connector-mcp": "18.6.0" + }, + "devDependencies": { + "@objectstack/cli": "18.6.0", + "@objectstack/skills": "18.6.0", + "@objectstack/verify": "18.6.0", + "typescript": "^5.3.0", + "vitest": "~4.1.12" + }, + "overrides": { + "vitest": "~4.1.12", + "uuid@<12.0.0": "^11.1.1" + } +} diff --git a/packages/qa/upgrade-source/run.mjs b/packages/qa/upgrade-source/run.mjs new file mode 100644 index 00000000000..66007f71114 --- /dev/null +++ b/packages/qa/upgrade-source/run.mjs @@ -0,0 +1,947 @@ +#!/usr/bin/env node +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. +// +// run.mjs — the v18 → v19 SOURCE-upgrade gate: the path a real 18.x user takes, +// walked end to end against THIS checkout, with no model key anywhere. +// +// node packages/qa/upgrade-source/run.mjs --tarballs --work +// node packages/qa/upgrade-source/run.mjs --self-test +// +// `` given to --tarballs is what `node scripts/publish-smoke-pack.mjs ` +// writes: one packed tarball per publishable package and `overrides.json`, the +// name → `file:` map (scaffold-e2e.yml installs a scaffolded project the same +// way). `--work` is a new scratch directory this run fills; nothing in the +// checkout is written. +// +// ## What it walks +// +// The committed fixture (`fixture-18.6.0/`) is a project an 18.6.0 user has: +// the blank template's config with its `exportsOf(…)` wiring unchanged, two +// objects joined by a master-detail and a lookup, list views carrying +// `list.bulkActions`, actions, a permission set with View All / Modify All and +// its own row hiding a field, a validation rule, a record-triggered flow, a +// dataset, a dashboard and a committed `access-matrix.json`. Its database +// (`fixture-db-18.6.0/`) was written by the PUBLISHED 18.6.0 CLI +// (`generate-fixture-db.mjs`, provenance beside it): seeded records, three +// people, and one Studio-style view save stored as an overlay row that still +// carries `bulkActions`. +// +// Provenance (P1): the committed database and manifest hash to what +// provenance.json records. +// Template wiring (T*): bump every `@objectstack/*` pin to this checkout's +// version, install the packed tarballs, `os migrate meta --from 18 --write`, +// re-run, read the protocol range, `os validate`, `os build`. +// Data (D*): load the 18.6.0 database, `os migrate apply --yes`, +// `os migrate protocol --to 19 --apply --yes` (the step the 19 boot names for an +// 18 database), `os migrate meta --stored`. +// Boot (B*): `os start` on that database; the people sign in with their 18 +// passwords, every seeded record reads back, the stored view is served valid, +// and the field reads are the RULED 19 ones. +// Helper wiring (H*): the same sources behind a `composeStacks(createCrmStack(…))` +// config (the HotCRM shape), for the edits the tool can prove there. +// +// ## Reds that wait on a card +// +// An assertion whose fix is still open would be declared in ASSERTIONS with +// `waitsOn` (none is today). It would still red the run, and read as "waiting" +// only while all three hold: the red is the failure +// that card describes (a step that broke some other way flags its red +// `unexpected`, e.g. a dry run that exits non-zero), and the card reads `open` +// on the GitHub API in this run. Anything else is UNEXPECTED. A waiting +// assertion that passes is a STALE entry and keeps the verdict red until its +// `waitsOn` is dropped, so the list can never sit there excusing a later +// regression of the same assertion. +// +// The mechanical change sets the chain applies are pinned by conversion id and +// path (EXPECTED_APPLIED: template 12, helper 15), so a conversion that stops +// firing reds the run instead of passing on the tool's own report. +// +// ## The dispatch-gates population +// +// This is an install / build / boot pipeline driven from one workflow +// (`upgrade-source-gate.yml`), not a named local check family; its +// `--self-test` covers the pure judgements (pin rewrite, lockfile resolution, +// drift explanation, helper refusals, the verdict) on fixtures, no network. +import { spawn, spawnSync } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import { appendFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs'; +import { createServer } from 'node:net'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const HERE = dirname(fileURLToPath(import.meta.url)); +const FIXTURE = resolve(HERE, 'fixture-18.6.0'); +const FIXTURE_DB = resolve(HERE, 'fixture-db-18.6.0'); +const HELPER_WIRING = resolve(HERE, 'helper-wiring'); + +// The generator's published, non-secret boot values (generate-fixture-db.mjs). +const FIXTURE_ENV = { + OS_AUTH_SECRET: 'upgrade-source-gate-fixture-auth-secret-not-a-secret', + OS_SECRET_KEY: createHash('sha256').update('upgrade-source-gate-fixture-secret-key-not-a-secret').digest('hex'), +}; + +const VIEW_ALL_FIELDS = 'permission-view-all-fields-beside-record-bypass'; + +/** + * Every assertion this gate makes, in run order. `waitsOn` names the open card + * whose fix turns it green; it is the expected-red list, in one place. + */ +export const ASSERTIONS = Object.freeze([ + { id: 'P1', title: 'the committed database.sql and manifest.json hash to the sha256 their provenance.json records' }, + { id: 'T1', title: "every name in this checkout's overrides.json that the install resolved came from its tarball, and every declared @objectstack/* dependency is pinned to one" }, + { id: 'T11', title: 'the dry run, --json and human, both exit 0 and the --json run prints its JSON report' }, + { id: 'T2', title: "the dry run names the auditor's own field row beside Modify All: --json ownFieldRowNarrowing has crm18_auditor / crm18_contact.salary, read-and-edit on 18 → hidden on 19, and the human report names the same row" }, + { id: 'T10', title: 'the dry run applies exactly the pinned 12 mechanical changes (conversion id + path), no more and no fewer' }, + { id: 'T3', title: '`os migrate meta --from 18 --write` exits 0' }, + { id: 'T4', title: '`--write` writes every mechanical change and its re-check agrees' }, + { id: 'T5', title: 'a re-run of `os migrate meta --from 18` reports applied: 0' }, + { id: 'T6', title: "the config's engines.protocol reads '^19'" }, + { id: 'T7', title: '`os validate` exits 0' }, + { id: 'T8', title: '`os migrate meta` tells the user to run `os build --update-access-matrix` when its edits move the committed access matrix' }, + { id: 'T9', title: '`os build` passes, or stops only on access-matrix drift every line of which is a View All Fields edit the migration made; `--update-access-matrix` then builds' }, + { id: 'D1', title: '`os migrate apply --yes` on the 18.6.0 database exits 0' }, + { id: 'D2', title: '`os migrate protocol --to 19 --apply --yes` on that database exits 0' }, + { id: 'D3', title: '`os migrate meta --stored` refuses the stored view 19 serves invalid: exit 1, clean: false, the row servedInvalid at list.bulkActions and pending rewrite' }, + { id: 'D4', title: '`os migrate meta --stored --apply --yes` rewrites that stored view row and exits 0' }, + { id: 'B1', title: 'the app boots on the migrated database and answers /health' }, + { id: 'B2', title: 'every person signs in with their 18 password' }, + { id: 'B3', title: 'every seeded record reads back by id, with every value it was seeded with' }, + { id: 'B4', title: 'the stored view customization is served valid, with its stored columns' }, + { id: 'B5', title: "the auditor reads every contact and no contact's salary, while the owner reads every salary (the ruled 19 field axis: the set's own readable:false row beats View All / Modify All)" }, + { id: 'B6', title: "the auditor's edit of a contact's salary is refused 403 PERMISSION_DENIED (viewAllFields votes read only)" }, + { id: 'B7', title: "the member still reads no account's notes, while the owner reads every account's notes" }, + { id: 'B8', title: 'the validation rule still refuses a negative annual revenue (400 VALIDATION_FAILED), as on 18' }, + { id: 'H1', title: 'helper wiring: `--write` writes or names, with the builder it cannot follow, every mechanical change and the range' }, + { id: 'H2', title: 'helper wiring: `--write` exits non-zero exactly when it left a change by hand' }, + { id: 'H3', title: 'helper wiring: once the named edits are applied, a re-run reports applied: 0' }, + { id: 'H4', title: 'helper wiring: `os validate` exits 0' }, + { id: 'H5', title: 'helper wiring: `os build` passes under the same drift rule as T9' }, + { id: 'H6', title: 'helper wiring: `--write` reports exactly the pinned 15 mechanical changes (conversion id + path)' }, +]); + +/** + * The mechanical change sets the chain applies to the fixture, by conversion id + * and path, as measured on the merge preview of 3e569944c1 (CI run 46912699833). + * Pinned so a conversion that stops firing reds here instead of passing on the + * tool's own report of what it applied. The helper wiring's composed stack also + * carries each object's own copy of its actions (`objects[N].actions[M]`), hence 15. + */ +const VAF = 'permission-view-all-fields-beside-record-bypass'; +const LOC = 'action-locations-acted-on'; +const SEL = 'view-bulk-actions-to-action-selection'; +export const EXPECTED_APPLIED = Object.freeze({ + template: Object.freeze([ + [VAF, 'permissions[0].objects.crm18_account.viewAllFields'], + [VAF, 'permissions[0].objects.crm18_contact.viewAllFields'], + [LOC, 'actions[0].locations'], [LOC, 'actions[1].locations'], [LOC, 'actions[2].locations'], + [SEL, 'views[0].list.bulkActions'], [SEL, 'views[0].list.bulkActions'], + [SEL, 'views[1].list.bulkActions'], [SEL, 'views[1].list.bulkActions'], + [SEL, 'actions[0].locations'], [SEL, 'actions[1].locations'], [SEL, 'actions[2].locations'], + ]), + helper: Object.freeze([ + [VAF, 'permissions[0].objects.crm18_account.viewAllFields'], + [VAF, 'permissions[0].objects.crm18_contact.viewAllFields'], + [LOC, 'actions[0].locations'], [LOC, 'actions[1].locations'], [LOC, 'actions[2].locations'], + [LOC, 'objects[1].actions[0].locations'], [LOC, 'objects[2].actions[0].locations'], [LOC, 'objects[2].actions[1].locations'], + [SEL, 'views[0].list.bulkActions'], [SEL, 'views[0].list.bulkActions'], + [SEL, 'views[1].list.bulkActions'], [SEL, 'views[1].list.bulkActions'], + [SEL, 'objects[1].actions[0].locations'], [SEL, 'objects[2].actions[0].locations'], [SEL, 'objects[2].actions[1].locations'], + ]), +}); + +// ── Pure judgements (each covered by --self-test) ───────────────────────── + +/** The version a packed tarball spec carries: `file:…/objectstack-cli-19.0.0-next.3.tgz` → `19.0.0-next.3`. */ +export function tarballVersion(spec) { + const m = /-(\d+\.\d+\.\d+(?:-[0-9A-Za-z.]+)?)\.tgz$/.exec(spec ?? ''); + return m ? m[1] : null; +} + +/** + * The user's pin bump: every `@objectstack/*` dependency set to the version its + * tarball carries. Returns the new manifest and the names it could not pin. + */ +export function bumpPins(pkg, overrides) { + const out = JSON.parse(JSON.stringify(pkg)); + const missing = []; + for (const key of ['dependencies', 'devDependencies']) { + for (const name of Object.keys(out[key] ?? {})) { + if (!name.startsWith('@objectstack/')) continue; + const version = tarballVersion(overrides[name]); + if (version) out[key][name] = version; + else missing.push(name); + } + } + return { pkg: out, missing }; +} + +/** The project's own pnpm-workspace.yaml with every packed tarball pinned through `overrides`. */ +export function appendOverrides(workspaceYaml, overrides) { + return [ + workspaceYaml.replace(/\s*$/, ''), + '', + '# appended by the upgrade-source gate: every publishable package of the checkout', + '# redirected to its packed tarball.', + 'overrides:', + ...Object.entries(overrides).map(([name, spec]) => ` '${name}': '${spec}'`), + '', + ].join('\n'); +} + +/** + * scaffold-e2e.yml's reading of the lockfile, over EVERY name in overrides.json: + * which resolved from a tarball, which leaked to the registry; and which declared + * `@objectstack/*` names resolved from neither. + */ +export function lockfileResolution(lockText, names, declared) { + const lines = lockText.split(/\r?\n/); + const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + const pinned = new Set(); + const leaked = new Set(); + for (const name of names) { + const key = new RegExp(`^\\s*'?${esc(name)}@([^']+?)'?:\\s*$`); + for (const line of lines) { + const m = key.exec(line); + if (!m) continue; + if (m[1].startsWith('file:')) pinned.add(name); + else if (/^[0-9]/.test(m[1])) leaked.add(`${name}@${m[1]}`); + } + } + return { scanned: names.length, pinned: pinned.size, unpinned: declared.filter((n) => !pinned.has(n)), leaked: [...leaked].sort() }; +} + +/** An applied list against a pinned one, as multisets of `conversionId path`. */ +export function appliedSetDiff(applied, expected) { + const key = (c, p) => `${c} ${p ?? '(no path)'}`; + const want = new Map(); + for (const [c, p] of expected) want.set(key(c, p), (want.get(key(c, p)) ?? 0) + 1); + const extra = []; + for (const a of applied ?? []) { + const k = key(a.conversionId, a.path); + if ((want.get(k) ?? 0) > 0) want.set(k, want.get(k) - 1); + else extra.push(k); + } + const missing = [...want].flatMap(([k, n]) => Array(n).fill(k)); + return { missing, extra }; +} + +/** The fields of `values` a read row disagrees with (a reference read back as `{ id }` compares by id). */ +export function valueMismatches(row, values) { + const out = []; + for (const [field, want] of Object.entries(values ?? {})) { + const raw = row?.[field]; + const got = raw && typeof raw === 'object' && 'id' in raw ? raw.id : raw; + const same = typeof want === 'number' ? Number(got) === want : String(got) === String(want); + if (!same) out.push(`${field}: read ${JSON.stringify(raw)}, seeded ${JSON.stringify(want)}`); + } + return out; +} + +/** Which committed fixture files do not hash to what provenance.json records. `files` maps name → contents. */ +export function provenanceMismatches(provenance, files) { + const out = []; + for (const [name, text] of Object.entries(files)) { + const want = provenance?.sha256?.[name]; + const got = createHash('sha256').update(text).digest('hex'); + if (want !== got) out.push(`${name}: sha256 ${got}, provenance records ${want ?? 'nothing'}`); + } + return out; +} + +/** The `engines.protocol` range a source file declares, or null. */ +export function declaredProtocol(sourceText) { + const m = /engines\s*:\s*\{[^}]*?protocol\s*:\s*(['"`])([^'"`]+)\1/.exec(sourceText); + return m ? m[2] : null; +} + +const stripAnsi = (s) => String(s).replace(/\x1b\[[0-9;]*m/g, ''); + +/** + * Whether a build's access-matrix drift is explained by the migration: every + * drift line is a View All Fields gain on an object the chain added + * `viewAllFields` to. Returns `{ drift, unexplained }`; `drift` false when the + * output reports none. + */ +export function explainDrift(buildOutput, applied) { + const text = stripAnsi(buildOutput); + if (!/Access matrix drift/.test(text)) return { drift: false, unexplained: [] }; + const objects = new Set( + (applied ?? []) + .filter((a) => a.conversionId === VIEW_ALL_FIELDS) + .map((a) => /\.objects\.([^.]+)\.viewAllFields$/.exec(a.path)?.[1]) + .filter(Boolean), + ); + const lines = text.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith('•')); + const unexplained = lines.filter((line) => { + const m = /^•\s*'([^']+)' gains View All Fields on '([^']+)'$/.exec(line); + return !m || !objects.has(m[2]); + }); + if (lines.length === 0) unexplained.push('(the build reported drift but listed no change)'); + return { drift: true, unexplained }; +} + +/** + * The helper wiring's `--write` report judged: every applied change is either + * written or listed by hand naming what built it, and the range likewise. + * Returns the problems found (empty = honest). + */ +export function judgeHelperWrite(json) { + const problems = []; + const write = json?.write; + if (!write) return ['the run printed no `write` report']; + const builder = (reason) => /`[A-Za-z_$][\w$]*\(…\)`/.test(reason ?? ''); + const accounted = write.written.length + write.manual.length; + if (accounted !== json.applied.length) { + problems.push(`${json.applied.length} change(s) applied, ${write.written.length} written + ${write.manual.length} left by hand = ${accounted}`); + } + for (const m of write.manual) { + if (m.kind !== 'helper' || !builder(m.reason)) { + problems.push(`${m.path} (${m.conversionId}) left as [${m.kind}] without naming the call that built it: ${m.reason}`); + } + } + if ((write.unexplained ?? []).length > 0) problems.push(`unexplained: ${JSON.stringify(write.unexplained)}`); + const range = write.range; + if (range && range.status !== 'written' && !(range.kind === 'helper' && builder(range.reason))) { + problems.push(`the protocol range was left as [${range.kind}] without naming the call that built it: ${range.reason}`); + } + if (write.written.length > 0 && write.verification && write.verification.ok !== true) { + problems.push(`the re-check over the written sources disagreed: ${JSON.stringify(write.verification)}`); + } + return problems; +} + +/** Rows out of a data-API list answer, whatever envelope it wears. */ +export function rowsOf(body) { + return Array.isArray(body) ? body : (body?.records ?? body?.data?.records ?? body?.value ?? body?.data ?? []); +} + +/** + * The run's verdict from per-assertion results (`pass` | `fail` | `not-run`). + * Every declared assertion must have a result; a missing one is `not-run`. + */ +export function verdict(assertions, results, cardStates = {}) { + const rows = assertions.map((a) => ({ ...a, ...(results[a.id] ?? { status: 'not-run', detail: 'never reached' }) })); + // A red counts as waiting only while ALL hold: it declares a card, the red is the + // failure that card describes (not flagged `unexpected` by its own step, e.g. a + // command that exited non-zero), and the card is read as open. A closed or + // unreadable card makes it UNEXPECTED, so a waitsOn cannot outlive its card. + const isWaiting = (r) => r.status !== 'pass' && r.waitsOn && !r.unexpected && cardStates[r.waitsOn] === 'open'; + const waiting = rows.filter(isWaiting); + const unexpected = rows.filter((r) => r.status !== 'pass' && !isWaiting(r)); + // A declared waitsOn that passes is a STALE entry: the verdict stays red until it + // is dropped, so the list cannot sit there excusing a later regression. + const landed = rows.filter((r) => r.status === 'pass' && r.waitsOn); + return { rows, waiting, unexpected, landed, cardStates, green: waiting.length === 0 && unexpected.length === 0 && landed.length === 0 }; +} + +export function renderSummary(v) { + const out = ['## Upgrade-source gate (v18 → v19)', '']; + out.push('| Id | Result | Assertion | Waits on |', '|---|---|---|---|'); + for (const r of v.rows) { + const mark = r.status === 'pass' ? 'PASS' : r.status === 'fail' ? 'FAIL' : 'NOT RUN'; + out.push(`| ${r.id} | ${mark} | ${r.title.replace(/\|/g, '\\|')} | ${r.waitsOn ? `#${r.waitsOn}` : ''} |`); + } + out.push(''); + if (v.waiting.length > 0) { + out.push(`Expected red, waiting on an open fix: ${v.waiting.map((r) => `${r.id} (#${r.waitsOn})`).join(', ')}.`); + } + if (v.unexpected.length > 0) { + const why = (r) => (r.waitsOn + ? (r.unexpected ? `not the failure #${r.waitsOn} describes` : `#${r.waitsOn} reads ${v.cardStates?.[r.waitsOn] ?? 'unknown'}`) + : 'no card declared'); + out.push(`UNEXPECTED red: ${v.unexpected.map((r) => `${r.id} (${why(r)})`).join(', ')}.`); + } + if (v.landed.length > 0) { + out.push(`STALE expected-red entry: ${v.landed.map((r) => `${r.id} (#${r.waitsOn})`).join(', ')} passes — that fix has landed; drop its \`waitsOn\` in run.mjs (red until then).`); + } + out.push('', v.green ? 'Verdict: GREEN.' : 'Verdict: RED.'); + for (const r of v.rows.filter((x) => x.status !== 'pass')) { + out.push('', `### ${r.id} ${r.status === 'fail' ? 'FAIL' : 'NOT RUN'}${r.waitsOn ? ` (waits on #${r.waitsOn})` : ''}`, '', '```text', String(r.detail ?? '').slice(0, 4000), '```'); + } + return `${out.join('\n')}\n`; +} + +// ── The walk ─────────────────────────────────────────────────────────────── + +const results = {}; +function record(id, ok, detail, { unexpected = false } = {}) { + if (!ASSERTIONS.some((a) => a.id === id)) throw new Error(`run.mjs records an undeclared assertion ${id}`); + results[id] = { status: ok ? 'pass' : 'fail', detail: detail ?? '', ...(unexpected ? { unexpected: true } : {}) }; + const a = ASSERTIONS.find((x) => x.id === id); + const tag = ok ? 'PASS' : `FAIL${a.waitsOn && !unexpected ? ` (declared to wait on #${a.waitsOn})` : ' (UNEXPECTED)'}`; + const first = String(detail ?? '').split('\n')[0].slice(0, 200); + console.log(`[${id}] ${tag} ${a.title}${ok ? (first ? `\n ${first}` : '') : `\n ${String(detail ?? '').split('\n').slice(0, 12).join('\n ')}`}`); + if (!ok && process.env.GITHUB_ACTIONS) { + console.log(`::error title=upgrade-source ${id}${a.waitsOn ? ` (waits on #${a.waitsOn})` : ''}::${a.title}`); + } +} + +let logDir = ''; +let commandCount = 0; +function sh(label, cmd, args, { cwd, env, timeoutMs = 300_000 } = {}) { + commandCount += 1; + const r = spawnSync(cmd, args, { + cwd, + env: { ...process.env, ...env }, + encoding: 'utf8', + maxBuffer: 256 * 1024 * 1024, + timeout: timeoutMs, + }); + const file = join(logDir, `${String(commandCount).padStart(2, '0')}-${label}.log`); + writeFileSync(file, `$ ${cmd} ${args.join(' ')}\n(cwd ${cwd})\nexit ${r.status}${r.error ? ` (${r.error.message})` : ''}\n\n--- stdout\n${r.stdout ?? ''}\n--- stderr\n${r.stderr ?? ''}\n`); + console.log(` $ ${[cmd, ...args].join(' ')} → exit ${r.status} (log: ${file})`); + return { status: r.status, stdout: r.stdout ?? '', stderr: r.stderr ?? '', file }; +} + +function parseJson(text) { + try { return JSON.parse(text); } catch { return null; } +} + +const tail = (r, n = 30) => stripAnsi(`${r.stdout}\n${r.stderr}`).trim().split('\n').slice(-n).join('\n'); + +function freePort() { + return new Promise((ok, fail) => { + const s = createServer(); + s.unref(); + s.on('error', fail); + s.listen(0, () => { + const { port } = s.address(); + s.close(() => ok(port)); + }); + }); +} + +/** Copy the fixture (and an overlay wiring over it), bump its pins, pin the tarballs and install. */ +function prepareProject(dir, overrides, tarballs, overlay) { + cpSync(FIXTURE, dir, { recursive: true }); + if (overlay) cpSync(overlay, dir, { recursive: true }); + const { pkg, missing } = bumpPins(JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')), overrides); + if (missing.length > 0) throw new Error(`no packed tarball for ${missing.join(', ')} in ${tarballs}/overrides.json`); + writeFileSync(join(dir, 'package.json'), `${JSON.stringify(pkg, null, 2)}\n`); + writeFileSync(join(dir, 'pnpm-workspace.yaml'), appendOverrides(readFileSync(join(dir, 'pnpm-workspace.yaml'), 'utf8'), overrides)); + const install = sh('install', 'pnpm', ['install', '--no-frozen-lockfile'], { cwd: dir, timeoutMs: 900_000 }); + const declared = [pkg.dependencies, pkg.devDependencies].flatMap((d) => Object.keys(d ?? {})).filter((n) => n.startsWith('@objectstack/')); + return { install, declared }; +} + +/** `os build`, judged under the drift rule; on explained drift, `--update-access-matrix`, then a plain build. */ +function buildUnderDriftRule(label, dir, os, applied) { + const first = sh(`${label}-build`, os, ['build'], { cwd: dir }); + if (first.status === 0) return { ok: true, detail: 'built with no drift' }; + const { drift, unexplained } = explainDrift(`${first.stdout}\n${first.stderr}`, applied); + if (!drift) return { ok: false, detail: tail(first) }; + if (unexplained.length > 0) return { ok: false, detail: `access-matrix drift the migration does not explain:\n${unexplained.join('\n')}` }; + const update = sh(`${label}-build-update-matrix`, os, ['build', '--update-access-matrix'], { cwd: dir }); + if (update.status !== 0) return { ok: false, detail: tail(update) }; + const again = sh(`${label}-build-again`, os, ['build'], { cwd: dir }); + return again.status === 0 + ? { ok: true, detail: 'drift on the migration\'s own viewAllFields edits only; --update-access-matrix, then a clean build' } + : { ok: false, detail: tail(again) }; +} + +async function http(base, token, method, path, body) { + for (let attempt = 0; ; attempt++) { + const res = await fetch(`${base}${path}`, { + method, + headers: { 'Content-Type': 'application/json', Origin: new URL(base).origin, ...(token ? { Authorization: `Bearer ${token}` } : {}) }, + ...(body === undefined ? {} : { body: JSON.stringify(body) }), + }); + const text = await res.text(); + if (res.status === 429 && attempt < 8) { + await new Promise((ok) => setTimeout(ok, 5000)); + continue; + } + return { status: res.status, json: parseJson(text) ?? text }; + } +} + +async function bootAndRead(dir, os, env, manifest) { + const port = await freePort(); + const base = `http://localhost:${port}/api/v1`; + const logFile = join(logDir, 'boot-server.log'); + const server = spawn(os, ['start', '--artifact', './dist/objectstack.json', '--port', String(port)], { + cwd: dir, + env: { ...process.env, ...env }, + stdio: ['ignore', 'pipe', 'pipe'], + }); + let log = ''; + server.stdout.on('data', (d) => { log += d; }); + server.stderr.on('data', (d) => { log += d; }); + const exited = new Promise((ok) => server.on('exit', ok)); + try { + let healthy = false; + for (let i = 0; i < 60 && !healthy && server.exitCode === null; i++) { + healthy = await fetch(`${base}/health`).then((r) => r.ok, () => false); + if (!healthy) await new Promise((ok) => setTimeout(ok, 2000)); + } + record('B1', healthy, healthy ? `healthy on :${port}` : stripAnsi(log).split('\n').filter((l) => /✗|ERROR|refus/i.test(l)).slice(0, 8).join('\n') || stripAnsi(log).slice(-3000)); + if (!healthy) return; + + // B2: the people sign in with their 18 passwords. + const tokens = {}; + const failed = []; + for (const [key, p] of Object.entries(manifest.people)) { + const r = await http(base, null, 'POST', '/auth/sign-in/email', { email: p.email, password: p.password }); + if (r.status === 200 && r.json?.token) tokens[key] = r.json.token; + else failed.push(`${key}: ${r.status} ${JSON.stringify(r.json).slice(0, 200)}`); + } + record('B2', failed.length === 0, failed.join('\n')); + if (!tokens.owner) return; + + // B3: every seeded record, by id and name. + const missing = []; + const ownerRows = {}; + let compared = 0; + for (const object of [...new Set(manifest.records.map((r) => r.object))]) { + const r = await http(base, tokens.owner, 'GET', `/data/${object}?limit=200`); + const rows = rowsOf(r.json); + ownerRows[object] = rows; + for (const rec of manifest.records.filter((x) => x.object === object)) { + const row = rows.find((x) => x.id === rec.id); + if (!row) { missing.push(`${object} ${rec.id} '${rec.name}': not read back (status ${r.status})`); continue; } + const off = valueMismatches(row, rec.values); + compared += Object.keys(rec.values ?? {}).length; + if (off.length > 0) missing.push(`${object} ${rec.id} '${rec.name}': ${off.join('; ')}`); + } + } + record('B3', missing.length === 0, missing.length === 0 + ? `${manifest.records.length} records read back, ${compared} seeded values equal` + : missing.join('\n')); + + // B4: the stored view. + const sv = manifest.storedView; + const view = await http(base, tokens.owner, 'GET', `/meta/view/${sv.name}`); + const item = view.json?.item; + const columns = item?.list?.columns?.map((c) => c.field) ?? []; + const valid = item?._diagnostics?.valid === true; + const sameColumns = JSON.stringify(columns) === JSON.stringify(sv.columns); + record('B4', view.status === 200 && valid && sameColumns, + `status ${view.status}; _diagnostics ${JSON.stringify(item?._diagnostics ?? null).slice(0, 600)}; columns ${JSON.stringify(columns)} (stored ${JSON.stringify(sv.columns)})`); + + const contacts = manifest.records.filter((r) => r.object === 'crm18_contact'); + const accounts = manifest.records.filter((r) => r.object === 'crm18_account'); + + // B5/B6: the auditor, under the ruled 19 field axis. + if (tokens.auditor) { + const r = await http(base, tokens.auditor, 'GET', '/data/crm18_contact?limit=200'); + const rows = rowsOf(r.json); + const withSalary = rows.filter((x) => x.salary !== undefined && x.salary !== null); + // Positive control: the owner reads the very field, on every contact, so its absence above is the auditor's grant. + const ownerSalaries = (ownerRows.crm18_contact ?? []).filter((x) => x.salary !== undefined && x.salary !== null); + record('B5', r.status === 200 && rows.length === contacts.length && withSalary.length === 0 && ownerSalaries.length === contacts.length, + `auditor: status ${r.status}, ${rows.length} of ${contacts.length} contacts, salary on ${withSalary.length}; control, owner: salary on ${ownerSalaries.length} of ${contacts.length} (on 18 the auditor read it: ${manifest.observedOn18.auditorReadsSalary})`); + const target = contacts[0]; + const edit = await http(base, tokens.auditor, 'PATCH', `/data/crm18_contact/${target.id}`, { salary: 1 }); + // A refusal is judged by its envelope (status + code), never by a bare 4xx. + record('B6', edit.status === 403 && edit.json?.code === 'PERMISSION_DENIED', + `PATCH salary as the auditor answered ${edit.status}: ${JSON.stringify(edit.json).slice(0, 300)}`); + } else { + record('B5', false, 'the auditor could not sign in (B2)'); + record('B6', false, 'the auditor could not sign in (B2)'); + } + + // B7: the member's hidden account notes. + if (tokens.member) { + const r = await http(base, tokens.member, 'GET', '/data/crm18_account?limit=200'); + const rows = rowsOf(r.json); + const withNotes = rows.filter((x) => x.notes !== undefined && x.notes !== null); + const ownerNotes = (ownerRows.crm18_account ?? []).filter((x) => x.notes !== undefined && x.notes !== null); + record('B7', r.status === 200 && rows.length === accounts.length && withNotes.length === 0 && ownerNotes.length === accounts.length, + `member: status ${r.status}, ${rows.length} of ${accounts.length} accounts, notes on ${withNotes.length}; control, owner: notes on ${ownerNotes.length} of ${accounts.length}`); + } else { + record('B7', false, 'the member could not sign in (B2)'); + } + + // B8: the validation rule. + const neg = await http(base, tokens.owner, 'POST', '/data/crm18_account', { name: 'Negative Co', annual_revenue: -1 }); + record('B8', neg.status === manifest.observedOn18.negativeRevenueStatus && neg.json?.code === 'VALIDATION_FAILED', + `answered ${neg.status} (18 answered ${manifest.observedOn18.negativeRevenueStatus}): ${JSON.stringify(neg.json).slice(0, 300)}`); + } finally { + if (server.exitCode === null) { + server.kill('SIGTERM'); + await Promise.race([exited, new Promise((ok) => setTimeout(ok, 10_000))]); + if (server.exitCode === null) server.kill('SIGKILL'); + } + writeFileSync(logFile, log); + } +} + +async function walk({ tarballs, work }) { + const overrides = JSON.parse(readFileSync(join(tarballs, 'overrides.json'), 'utf8')); + if (existsSync(work) && readdirSync(work).length > 0) throw new Error(`--work ${work} is not empty; give the run a new directory`); + mkdirSync(work, { recursive: true }); + logDir = join(work, 'logs'); + mkdirSync(logDir, { recursive: true }); + const manifestText = readFileSync(join(FIXTURE_DB, 'manifest.json'), 'utf8'); + const sqlText = readFileSync(join(FIXTURE_DB, 'database.sql'), 'utf8'); + const manifest = JSON.parse(manifestText); + + // The committed database is the one the generator wrote: its hashes, as recorded. + const provenance = JSON.parse(readFileSync(join(FIXTURE_DB, 'provenance.json'), 'utf8')); + const hashMismatches = provenanceMismatches(provenance, { 'database.sql': sqlText, 'manifest.json': manifestText }); + record('P1', hashMismatches.length === 0, + hashMismatches.length === 0 ? `database.sql and manifest.json match provenance.json (${provenance.packages})` : hashMismatches.join('\n')); + + // ── Template wiring ── + console.log('\n== Template wiring (the 18.6.0 blank template\'s exportsOf(…) config) =='); + const app = join(work, 'template'); + const { install, declared } = prepareProject(app, overrides, tarballs); + if (install.status !== 0) { + record('T1', false, `pnpm install exited ${install.status}:\n${tail(install)}`); + return; + } + const res = lockfileResolution(readFileSync(join(app, 'pnpm-lock.yaml'), 'utf8'), Object.keys(overrides), declared); + const resOk = res.unpinned.length === 0 && res.leaked.length === 0; + record('T1', resOk, resOk + ? `${res.pinned} package(s) resolved from packed tarballs, 0 from the registry, over all ${res.scanned} names in overrides.json; all ${declared.length} declared @objectstack/* among them` + : [...res.leaked.map((l) => `resolved from the registry: ${l}`), ...res.unpinned.map((n) => `declared but not resolved from a tarball: ${n}`)].join('\n')); + const os = join(app, 'node_modules/.bin/os'); + + const dry = sh('meta-dry-run', os, ['migrate', 'meta', '--from', '18', '--json'], { cwd: app }); + const dryJson = parseJson(dry.stdout); + const dryHuman = sh('meta-dry-run-human', os, ['migrate', 'meta', '--from', '18'], { cwd: app }); + const dryText = `${dry.stdout}\n${dryHuman.stdout}\n${dryHuman.stderr}`; + const dryClean = dry.status === 0 && dryJson !== null && dryHuman.status === 0; + record('T11', dryClean, `--json exited ${dry.status} (${dryJson === null ? 'stdout is not JSON' : `JSON: applied ${dryJson.applied?.length}, todos ${dryJson.todos?.length}`}), the human run exited ${dryHuman.status}` + + (dryClean ? '' : `\n${tail(dry, 12)}\n${tail(dryHuman, 12)}`)); + if (!dryClean) { + // The dry run itself broke: T11 carries that red, and T2's own red is flagged as not its failure. + record('T2', false, `the dry run did not run cleanly: --json exited ${dry.status} (${dryJson === null ? 'stdout is not JSON' : 'JSON parsed'}), the human run exited ${dryHuman.status}\n${tail(dry, 12)}\n${tail(dryHuman, 12)}`, { unexpected: true }); + } else { + // The dry run's --json report names each own field row that protocol 19 narrows + // beside Modify All (`ownFieldRowNarrowing`): the fixture's auditor row must be + // there, with its 18 and 19 outcomes. + const rows = Array.isArray(dryJson.ownFieldRowNarrowing) ? dryJson.ownFieldRowNarrowing : null; + const entry = rows?.find((r) => r.set === 'crm18_auditor' && r.field === 'crm18_contact.salary'); + const jsonNamed = entry?.protocol18 === 'read-and-edit' && entry?.protocol19 === 'hidden'; + // The human report names the same row: its subject (set and field row), never its prose. + const humanNamed = stripAnsi(dryHuman.stdout).split('\n') + .some((l) => l.includes("permission set 'crm18_auditor'") && l.includes("field row 'crm18_contact.salary'")); + const named = jsonNamed && humanNamed; + record('T2', named, named + ? `ownFieldRowNarrowing names crm18_auditor's crm18_contact.salary: protocol18 ${entry.protocol18}, protocol19 ${entry.protocol19} (${rows.length} entr${rows.length === 1 ? 'y' : 'ies'}); the human report names the same row` + : `both dry runs exited 0 (applied ${dryJson.applied.length}). JSON: ${jsonNamed ? 'names the row' : rows === null ? 'the --json report carries no ownFieldRowNarrowing list' : `ownFieldRowNarrowing holds ${JSON.stringify(rows).slice(0, 600)}, and no entry reads crm18_auditor / crm18_contact.salary going read-and-edit → hidden`}. ` + + `Human: ${humanNamed ? 'names the row' : "no line names permission set 'crm18_auditor' with field row 'crm18_contact.salary'"}.`); + } + const dryDiff = appliedSetDiff(dryJson?.applied, EXPECTED_APPLIED.template); + record('T10', dryJson !== null && dryDiff.missing.length === 0 && dryDiff.extra.length === 0, + dryJson === null ? 'the --json dry run printed no JSON' + : dryDiff.missing.length + dryDiff.extra.length === 0 ? `${dryJson.applied.length} applied = the pinned ${EXPECTED_APPLIED.template.length}` + : `missing: ${dryDiff.missing.join('; ') || 'none'}\nextra: ${dryDiff.extra.join('; ') || 'none'}`); + + const write = sh('meta-write', os, ['migrate', 'meta', '--from', '18', '--write', '--json'], { cwd: app }); + const writeJson = parseJson(write.stdout); + record('T3', write.status === 0, `exit ${write.status}; ${writeJson ? `applied ${writeJson.applied.length}, written ${writeJson.write?.written?.length ?? '?'}` : 'no JSON'}\n${tail(write)}`); + const w = writeJson?.write; + const allWritten = Boolean(w) && w.status === 'written' && w.manual.length === 0 && w.written.length === writeJson.applied.length + && w.verification?.ok === true && (w.unexplained ?? []).length === 0; + record('T4', allWritten, w + ? `status ${w.status}; applied ${writeJson.applied.length}, written ${w.written.length}, by hand ${w.manual.length}; verification ${JSON.stringify(w.verification)}\n${w.manual.map((m) => `${m.path} [${m.kind}] ${m.reason}`).join('\n')}` + : `no write report:\n${tail(write)}`); + + const rerun = sh('meta-rerun', os, ['migrate', 'meta', '--from', '18', '--json'], { cwd: app }); + const rerunJson = parseJson(rerun.stdout); + record('T5', rerun.status === 0 && rerunJson?.applied?.length === 0, + `exit ${rerun.status}; applied ${rerunJson?.applied?.length ?? '(no JSON)'}: ${JSON.stringify(rerunJson?.applied?.map((a) => a.path) ?? []).slice(0, 800)}`); + + const range = declaredProtocol(readFileSync(join(app, 'objectstack.config.ts'), 'utf8')); + record('T6', range === '^19', `objectstack.config.ts declares engines.protocol ${JSON.stringify(range)}`); + + const validate = sh('validate', os, ['validate'], { cwd: app }); + record('T7', validate.status === 0, tail(validate)); + + const applied = writeJson?.applied ?? dryJson?.applied ?? []; + const movesMatrix = applied.some((a) => a.conversionId === VIEW_ALL_FIELDS) && existsSync(join(FIXTURE, 'access-matrix.json')); + const toldMatrix = /update-access-matrix/.test(`${dryText}\n${write.stdout}\n${write.stderr}`); + record('T8', !movesMatrix || toldMatrix, + 'the chain adds viewAllFields to permission entries the committed access-matrix.json records, and neither the dry run nor --write names `os build --update-access-matrix`'); + + const built = buildUnderDriftRule('template', app, os, applied); + record('T9', built.ok, built.detail); + + // ── Data ── + console.log('\n== Data (the database 18.6.0 wrote) =='); + const dbFile = join(work, 'fixture.db'); + const { DatabaseSync } = await import('node:sqlite'); + const db = new DatabaseSync(dbFile); + db.exec(readFileSync(join(FIXTURE_DB, 'database.sql'), 'utf8')); + db.close(); + const dbEnv = { ...FIXTURE_ENV, OS_DATABASE_URL: `file:${dbFile}` }; + + const apply = sh('migrate-apply', os, ['migrate', 'apply', '--yes'], { cwd: app, env: dbEnv }); + record('D1', apply.status === 0, tail(apply)); + const proto = sh('migrate-protocol', os, ['migrate', 'protocol', '--to', '19', '--apply', '--yes'], { cwd: app, env: dbEnv }); + record('D2', proto.status === 0, tail(proto)); + + // The operator's loop: the read-only preview first, then --apply for what it lists. + const stored = sh('meta-stored', os, ['migrate', 'meta', '--stored', '--json'], { cwd: app, env: dbEnv }); + const storedJson = parseJson(stored.stdout); + const storedRow = storedJson?.rows?.find((r) => r.type === 'view' && r.name === manifest.storedView.name); + const outcomes = JSON.stringify((storedJson?.rows ?? []).map((r) => ({ type: r.type, name: r.name, outcome: r.outcome }))); + const refused = stored.status === 1 && storedJson?.clean === false && storedJson?.servedInvalid >= 1 + && storedRow?.outcome === 'pending' && storedRow?.servedInvalid?.path === 'list.bulkActions'; + record('D3', refused, + `--stored exited ${stored.status}; clean ${JSON.stringify(storedJson?.clean)}, servedInvalid ${JSON.stringify(storedJson?.servedInvalid)}, pending ${JSON.stringify(storedJson?.pending)}; rows ${outcomes}; ` + + `the view row: servedInvalid at ${JSON.stringify(storedRow?.servedInvalid?.path ?? null)}${refused ? '' : `; ${String(storedRow?.todos?.[0]?.reason ?? storedRow?.reason ?? '').slice(0, 400)}`}`); + const applyStored = sh('meta-stored-apply', os, ['migrate', 'meta', '--stored', '--apply', '--yes', '--json'], { cwd: app, env: dbEnv }); + const aj = parseJson(applyStored.stdout); + const appliedRow = aj?.rows?.find((r) => r.type === 'view' && r.name === manifest.storedView.name); + record('D4', applyStored.status === 0 && appliedRow?.outcome === 'rewritten', + `--stored --apply exited ${applyStored.status}; the view row ${appliedRow ? `'${appliedRow.outcome}'` : 'unreported'}: ` + + `${String(appliedRow?.todos?.[0]?.reason ?? appliedRow?.reason ?? aj?.error ?? '').slice(0, 500)}`); + + // ── Boot ── + console.log('\n== Boot (os start on the migrated database) =='); + await bootAndRead(app, os, dbEnv, manifest); + + // ── Helper wiring ── + console.log('\n== Helper wiring (composeStacks(createCrmStack(…)), the HotCRM shape) =='); + const helper = join(work, 'helper'); + const helperInstall = prepareProject(helper, overrides, tarballs, HELPER_WIRING); + if (helperInstall.install.status !== 0) { + record('H1', false, `pnpm install exited ${helperInstall.install.status}:\n${tail(helperInstall.install)}`); + return; + } + const hos = join(helper, 'node_modules/.bin/os'); + const hwrite = sh('helper-meta-write', hos, ['migrate', 'meta', '--from', '18', '--write', '--json'], { cwd: helper }); + const hj = parseJson(hwrite.stdout); + const problems = judgeHelperWrite(hj); + record('H1', hj !== null && problems.length === 0, hj ? problems.join('\n') : `no JSON:\n${tail(hwrite)}`); + const helperDiff = appliedSetDiff(hj?.applied, EXPECTED_APPLIED.helper); + record('H6', hj !== null && helperDiff.missing.length === 0 && helperDiff.extra.length === 0, + hj === null ? 'the helper --write printed no JSON' + : helperDiff.missing.length + helperDiff.extra.length === 0 ? `${hj.applied.length} applied = the pinned ${EXPECTED_APPLIED.helper.length}` + : `missing: ${helperDiff.missing.join('; ') || 'none'}\nextra: ${helperDiff.extra.join('; ') || 'none'}`); + const leftByHand = Boolean(hj?.write) && (hj.write.manual.length > 0 || hj.write.range?.status === 'manual'); + record('H2', hj !== null && (hwrite.status !== 0) === leftByHand, + `exit ${hwrite.status}; ${hj?.write?.manual?.length ?? '?'} change(s) and the range (${hj?.write?.range?.status ?? 'none'}) left by hand`); + + // The author applies what was left, as listed: the template wiring's written + // sources are exactly those edits, and the helper's own range moves to '^19'. + cpSync(join(app, 'src'), join(helper, 'src'), { recursive: true }); + const stackFile = join(helper, 'crm-stack.ts'); + writeFileSync(stackFile, readFileSync(stackFile, 'utf8').replace(/protocol:\s*'\^18'/, "protocol: '^19'")); + const hrerun = sh('helper-meta-rerun', hos, ['migrate', 'meta', '--from', '18', '--json'], { cwd: helper }); + const hrj = parseJson(hrerun.stdout); + record('H3', hrerun.status === 0 && hrj?.applied?.length === 0, + `exit ${hrerun.status}; applied ${hrj?.applied?.length ?? '(no JSON)'}: ${JSON.stringify(hrj?.applied?.map((a) => a.path) ?? []).slice(0, 800)}`); + const hvalidate = sh('helper-validate', hos, ['validate'], { cwd: helper }); + record('H4', hvalidate.status === 0, tail(hvalidate)); + const hbuilt = buildUnderDriftRule('helper', helper, hos, hj?.applied ?? []); + record('H5', hbuilt.ok, hbuilt.detail); +} + +// ── Self-test ────────────────────────────────────────────────────────────── + +let selfTestReachedVerdict = false; + +/** Battery → minimum case count. Names are pinned, never one total. */ +const SELF_TEST_BATTERIES = Object.freeze({ + 'tarball-version': 3, + 'pin-bump': 2, + 'workspace-overrides': 1, + 'lockfile-resolution': 4, + 'declared-protocol': 3, + 'drift-explanation': 4, + 'helper-write': 5, + 'rows-envelope': 3, + 'verdict': 8, + 'roster': 2, + 'applied-set': 4, + 'seeded-values': 2, + 'provenance-hash': 2, +}); +const SELF_TEST_BATTERY_FLOOR = 13; + +function selfTest() { + let failed = 0; + const seen = new Map(); + const check = (battery, label, ok) => { + seen.set(battery, (seen.get(battery) ?? 0) + 1); + if (ok) console.log(` ✓ [${battery}] ${label}`); + else { console.error(` ✗ [${battery}] ${label}`); failed += 1; } + }; + + check('tarball-version', 'a release tarball', tarballVersion('file:/t/objectstack-cli-19.0.0.tgz') === '19.0.0'); + check('tarball-version', 'a prerelease tarball', tarballVersion('file:/t/objectstack-cli-19.0.0-next.3.tgz') === '19.0.0-next.3'); + check('tarball-version', 'a spec that is no tarball', tarballVersion('^19.0.0') === null); + + const overrides = { '@objectstack/spec': 'file:/t/objectstack-spec-19.0.0-next.3.tgz', '@objectstack/cli': 'file:/t/objectstack-cli-19.0.0-next.3.tgz' }; + const bumped = bumpPins({ dependencies: { '@objectstack/spec': '18.6.0', zod: '^4' }, devDependencies: { '@objectstack/cli': '18.6.0' } }, overrides); + check('pin-bump', 'every @objectstack/* pin moves to its tarball version, others stay', + bumped.missing.length === 0 && bumped.pkg.dependencies['@objectstack/spec'] === '19.0.0-next.3' + && bumped.pkg.devDependencies['@objectstack/cli'] === '19.0.0-next.3' && bumped.pkg.dependencies.zod === '^4'); + const unpacked = bumpPins({ dependencies: { '@objectstack/runtime': '18.6.0' } }, overrides); + check('pin-bump', 'a pin with no tarball is named, not left on 18', unpacked.missing.join() === '@objectstack/runtime'); + + const ws = appendOverrides('packages: []\n\nallowBuilds:\n esbuild: true\n', overrides); + check('workspace-overrides', 'the template keys stay and every tarball is pinned', + ws.includes('allowBuilds:') && ws.includes(" '@objectstack/spec': 'file:/t/objectstack-spec-19.0.0-next.3.tgz'") && ws.includes('overrides:')); + + const lock = [ + " '@objectstack/spec@file:../t/objectstack-spec-19.0.0-next.3.tgz':", + ' /@objectstack/cli@18.6.0:', + " '@objectstack/cli@18.6.0':", + ].join('\n'); + const lr = lockfileResolution(lock, ['@objectstack/spec', '@objectstack/cli', '@objectstack/verify'], ['@objectstack/spec', '@objectstack/cli', '@objectstack/verify']); + check('lockfile-resolution', 'a tarball resolution counts as pinned', !lr.unpinned.includes('@objectstack/spec')); + check('lockfile-resolution', 'a registry resolution is a leak', lr.leaked.includes('@objectstack/cli@18.6.0')); + check('lockfile-resolution', 'a name resolved from neither is unpinned', lr.unpinned.includes('@objectstack/verify') && lr.unpinned.includes('@objectstack/cli')); + const undeclaredLeak = lockfileResolution(" '@objectstack/core@19.0.0':\n", ['@objectstack/core', '@objectstack/spec'], []); + check('lockfile-resolution', 'an override name the project never declares still reds when it leaked to the registry (the whole overrides.json is scanned)', + undeclaredLeak.leaked.includes('@objectstack/core@19.0.0') && undeclaredLeak.scanned === 2); + + check('declared-protocol', "reads '^19'", declaredProtocol("manifest: {\n engines: { protocol: '^19' },\n}") === '^19'); + check('declared-protocol', 'reads a range among other engine keys', declaredProtocol('engines: { node: ">=22", protocol: "^18 || ^19" }') === '^18 || ^19'); + check('declared-protocol', 'no range declared reads null', declaredProtocol('manifest: { id: "x" }') === null); + + const vaf = [{ conversionId: VIEW_ALL_FIELDS, path: 'permissions[0].objects.crm18_contact.viewAllFields' }]; + const driftOut = "\x1b[31m ✗ Access matrix drift (1 changes)\x1b[0m\n • 'crm18_auditor' gains View All Fields on 'crm18_contact'\n"; + check('drift-explanation', 'no drift reported', explainDrift('✓ Build complete', vaf).drift === false); + check('drift-explanation', 'drift on the migration\'s own viewAllFields edit is explained', explainDrift(driftOut, vaf).unexplained.length === 0); + check('drift-explanation', 'a gain on an object the migration did not touch is unexplained', + explainDrift("Access matrix drift (1 changes)\n • 'crm18_auditor' gains View All Fields on 'crm18_account'\n", vaf).unexplained.length === 1); + check('drift-explanation', 'any other kind of drift line is unexplained', + explainDrift("Access matrix drift (1 changes)\n • 'crm18_member' gains Delete on 'crm18_contact'\n", vaf).unexplained.length === 1); + + const helperJson = (manual, range, applied = manual.length) => ({ + applied: Array.from({ length: applied }, (_, i) => ({ path: `p${i}` })), + write: { status: 'written', written: [], manual, unexplained: [], ...(range ? { range } : {}) }, + }); + const named = { path: 'views[0].list.bulkActions', conversionId: 'c', kind: 'helper', reason: '`views` is composed by `composeStacks(…)` from all of its inputs' }; + check('helper-write', 'every site named with its builder is honest', judgeHelperWrite(helperJson([named], { status: 'manual', kind: 'helper', reason: 'built by `createCrmStack(…)`' })).length === 0); + check('helper-write', 'a site left without naming a builder is a problem', judgeHelperWrite(helperJson([{ ...named, kind: 'computed', reason: 'computed' }])).length === 1); + check('helper-write', 'an applied change neither written nor listed is a problem', judgeHelperWrite(helperJson([named], undefined, 2)).length === 1); + check('helper-write', 'a range left without its builder is a problem', judgeHelperWrite(helperJson([named], { status: 'manual', kind: 'spread', reason: 'a spread' })).length === 1); + check('helper-write', 'no write report at all is a problem', judgeHelperWrite({ applied: [] }).length === 1); + + check('rows-envelope', 'a bare array', rowsOf([{ id: 1 }]).length === 1); + check('rows-envelope', 'a records envelope', rowsOf({ records: [{ id: 1 }, { id: 2 }] }).length === 2); + check('rows-envelope', 'an error body reads as no rows', rowsOf({ error: { code: 'X' } }).length === 0); + + const roster = [{ id: 'A', title: 'a' }, { id: 'B', title: 'b', waitsOn: 1 }]; + const open = { 1: 'open' }; + const allPass = verdict(roster, { A: { status: 'pass' }, B: { status: 'pass' } }, open); + check('verdict', 'a waiting assertion that passes is a STALE entry: landed, and the verdict is RED until its waitsOn is dropped', + !allPass.green && allPass.landed.length === 1 && renderSummary(allPass).includes('STALE')); + const noWaits = verdict([{ id: 'A', title: 'a' }], { A: { status: 'pass' } }, {}); + check('verdict', 'with no waitsOn left and every assertion passing, the verdict is green', noWaits.green); + const waitingRed = verdict(roster, { A: { status: 'pass' }, B: { status: 'fail' } }, open); + check('verdict', 'a waiting red on an open card is red, named as waiting, not unexpected', !waitingRed.green && waitingRed.waiting.length === 1 && waitingRed.unexpected.length === 0); + const closedCard = verdict(roster, { A: { status: 'pass' }, B: { status: 'fail' } }, { 1: 'closed' }); + check('verdict', 'a waiting red whose card reads closed is UNEXPECTED', closedCard.waiting.length === 0 && closedCard.unexpected.map((r) => r.id).join() === 'B'); + const unknownCard = verdict(roster, { A: { status: 'pass' }, B: { status: 'fail' } }, {}); + check('verdict', 'a waiting red whose card state could not be read is UNEXPECTED', unknownCard.waiting.length === 0 && unknownCard.unexpected.length === 1); + const otherFailure = verdict(roster, { A: { status: 'pass' }, B: { status: 'fail', unexpected: true } }, open); + check('verdict', 'a red its own step flags as not the card\'s failure is UNEXPECTED even on an open card', + otherFailure.waiting.length === 0 && otherFailure.unexpected.length === 1 && renderSummary(otherFailure).includes('not the failure #1 describes')); + const unexpectedRed = verdict(roster, { A: { status: 'fail' }, B: { status: 'fail' } }, open); + check('verdict', 'a red with no card is unexpected', !unexpectedRed.green && unexpectedRed.unexpected.map((r) => r.id).join() === 'A'); + const unreached = verdict(roster, { B: { status: 'fail' } }, open); + check('verdict', 'an assertion never reached is not-run, and red', !unreached.green && unreached.rows[0].status === 'not-run' + && renderSummary(unreached).includes('NOT RUN')); + + const pinned = [['c1', 'p1'], ['c1', 'p1'], ['c2', 'p2']]; + const same = appliedSetDiff([{ conversionId: 'c2', path: 'p2' }, { conversionId: 'c1', path: 'p1' }, { conversionId: 'c1', path: 'p1' }], pinned); + check('applied-set', 'the pinned multiset, in any order, has nothing missing or extra', same.missing.length === 0 && same.extra.length === 0); + const dropped = appliedSetDiff([{ conversionId: 'c1', path: 'p1' }, { conversionId: 'c2', path: 'p2' }], pinned); + check('applied-set', 'a conversion that fires one time fewer is missing', dropped.missing.join() === 'c1 p1' && dropped.extra.length === 0); + const added = appliedSetDiff([...pinned.map(([c, p]) => ({ conversionId: c, path: p })), { conversionId: 'c3', path: 'p3' }], pinned); + check('applied-set', 'a change the pin does not name is extra', added.extra.join() === 'c3 p3' && added.missing.length === 0); + check('applied-set', 'the template and helper pins are 12 and 15 entries', + EXPECTED_APPLIED.template.length === 12 && EXPECTED_APPLIED.helper.length === 15); + + check('seeded-values', 'equal values, a reference read back as { id }, and a number read back as a string all match', + valueMismatches({ name: 'Ada', account: { id: 'a1' }, salary: '150000' }, { name: 'Ada', account: 'a1', salary: 150000 }).length === 0); + check('seeded-values', 'a changed value and a dropped value are both named', + valueMismatches({ name: 'Ada', salary: 1 }, { name: 'Ada', salary: 150000, email: 'a@x' }).length === 2); + + const prov = { sha256: { 'a.sql': createHash('sha256').update('abc').digest('hex') } }; + check('provenance-hash', 'a file hashing to its recorded sha256 matches', provenanceMismatches(prov, { 'a.sql': 'abc' }).length === 0); + check('provenance-hash', 'an edited file, and a file provenance records nothing for, are both named', + provenanceMismatches(prov, { 'a.sql': 'abd', 'b.json': '{}' }).length === 2); + + const ids = ASSERTIONS.map((a) => a.id); + check('roster', 'assertion ids are unique', new Set(ids).size === ids.length); + check('roster', 'every waitsOn names a card number', ASSERTIONS.every((a) => a.waitsOn === undefined || Number.isInteger(a.waitsOn))); + + // The floor: the batteries that registered EQUAL the ones declared. + const declared = Object.keys(SELF_TEST_BATTERIES); + const floor = (msg) => { console.error(`✗ self-test floor: ${msg}`); failed += 1; }; + if (declared.length < SELF_TEST_BATTERY_FLOOR) floor(`SELF_TEST_BATTERIES declares ${declared.length} batteries, below the pinned ${SELF_TEST_BATTERY_FLOOR}`); + for (const [name, count] of seen) if (!declared.includes(name)) floor(`battery "${name}" registered ${count} case(s) but is not declared`); + for (const name of declared) { + const count = seen.get(name) ?? 0; + if (count < SELF_TEST_BATTERIES[name]) floor(`battery "${name}" registered ${count} case(s), below its pinned ${SELF_TEST_BATTERIES[name]}`); + } + + if (failed > 0) { + console.error(`\n✗ upgrade-source run.mjs self-test: ${failed} failure(s).`); + process.exit(1); + } + console.log(`\n✓ upgrade-source run.mjs self-test: ${[...seen.values()].reduce((a, b) => a + b, 0)} cases in ${seen.size} batteries pass.`); + selfTestReachedVerdict = true; +} + +// ── Entry ────────────────────────────────────────────────────────────────── + +/** + * Each declared `waitsOn` card's state, read from the GitHub REST API (with + * GITHUB_TOKEN when the environment has one). Anything but a clean `open` or + * `closed` reads `unknown`, which the verdict counts as UNEXPECTED: an expected + * red is excused only by a card read as open in this run. + */ +async function readCardStates(assertions) { + const cards = [...new Set(assertions.map((a) => a.waitsOn).filter(Boolean))]; + const out = {}; + for (const n of cards) { + try { + const res = await fetch(`https://api.github.com/repos/objectstack-ai/objectstack/issues/${n}`, { + headers: { Accept: 'application/vnd.github+json', ...(process.env.GITHUB_TOKEN ? { Authorization: `Bearer ${process.env.GITHUB_TOKEN}` } : {}) }, + }); + const body = res.ok ? await res.json() : null; + out[n] = body?.state === 'open' || body?.state === 'closed' ? body.state : 'unknown'; + } catch { + out[n] = 'unknown'; + } + console.log(`card #${n}: ${out[n]}`); + } + return out; +} + +function arg(name) { + const i = process.argv.indexOf(name); + return i > 0 ? process.argv[i + 1] : undefined; +} + +async function main() { + if (process.argv.includes('--self-test')) { + selfTest(); + if (!selfTestReachedVerdict) { + console.error('\n✗ upgrade-source run.mjs self-test: selfTest() returned without reaching its verdict; refusing to exit 0.'); + process.exit(1); + } + return; + } + const tarballs = arg('--tarballs'); + const work = arg('--work'); + if (!tarballs || !work) { + console.error('usage: node packages/qa/upgrade-source/run.mjs --tarballs --work | --self-test'); + process.exit(2); + } + try { + await walk({ tarballs: resolve(tarballs), work: resolve(work) }); + } catch (e) { + console.error(`\nthe walk stopped: ${e?.stack ?? e}`); + } + const v = verdict(ASSERTIONS, results, await readCardStates(ASSERTIONS)); + const summary = renderSummary(v); + console.log(`\n${summary}`); + writeFileSync(join(resolve(work), 'results.json'), `${JSON.stringify(v.rows, null, 2)}\n`); + if (process.env.GITHUB_STEP_SUMMARY) appendFileSync(process.env.GITHUB_STEP_SUMMARY, summary); + process.exit(v.green ? 0 : 1); +} + +if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + main(); +} diff --git a/scripts/pm/dispatch-gates.self-test.mjs b/scripts/pm/dispatch-gates.self-test.mjs index 94dbac62587..7cbc999664c 100644 --- a/scripts/pm/dispatch-gates.self-test.mjs +++ b/scripts/pm/dispatch-gates.self-test.mjs @@ -9375,7 +9375,7 @@ export function selfTest({ tier = 'full' } = {}) { } const censusRows = liveMarkerCensus.map((r) => `${r.file}:${r.line} ${r.key}`).sort(); t( - `the live tree carries the eleven declarations measured for this census, and no others (${censusRows.join(' · ') || 'none'})`, + `the live tree carries the twelve declarations measured for this census, and no others (${censusRows.join(' · ') || 'none'})`, censusRows.join(' · ') === [ // Seventh row, added with the declaration it names: `checklist-status.yml` // is paths-filtered (its `pull_request:` trigger is filtered to itself) and @@ -9397,6 +9397,11 @@ export function selfTest({ tier = 'full' } = {}) { // is paths-filtered (its own file and the three ui scripts it loads) and // runs a generator's select and merge, so it discovers no `check:` family. '.github/workflows/ui-test-timings-refresh.yml:64 no-check-families', + // Twelfth row, added with the declaration it names: `upgrade-source-gate.yml` + // is paths-filtered (the migration tool, the conversion entries, the template + // and its own files) and runs one install/build/migrate/boot walk, so it + // discovers no `check:` family. + '.github/workflows/upgrade-source-gate.yml:28 no-check-families', // Eighth row, added with the declaration it names (#20278): the checker's // bare diff-scoped run declares the two step-`env:` values it does not need. 'scripts/check-issue-citations.mjs:204 local-env', @@ -9423,7 +9428,7 @@ export function selfTest({ tier = 'full' } = {}) { const censusCut = liveMarkerCensus.filter((r) => !r.whole).map((r) => `${r.file}:${r.line} ${r.key}`); t( `every live reason on those markers ENDS on its own marker line (cut: ${censusCut.join(', ') || 'none'})`, - censusCut.length === 0 && liveMarkerCensus.length === 11, + censusCut.length === 0 && liveMarkerCensus.length === 12, ); t( 'and every one of them carries a non-empty reason — whole is not the same claim as present, and both are owed',