@intentius/chant-lexicon-sql 0.0.0-stage → 0.112.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -2
- package/dist/clickhouse/apply/apply.d.ts +82 -0
- package/dist/clickhouse/apply/apply.d.ts.map +1 -0
- package/dist/clickhouse/apply/mutations.d.ts +46 -0
- package/dist/clickhouse/apply/mutations.d.ts.map +1 -0
- package/dist/clickhouse/apply/statements.d.ts +99 -0
- package/dist/clickhouse/apply/statements.d.ts.map +1 -0
- package/dist/clickhouse/catalog-types.d.ts +76 -0
- package/dist/clickhouse/catalog-types.d.ts.map +1 -0
- package/dist/clickhouse/container.d.ts +63 -0
- package/dist/clickhouse/container.d.ts.map +1 -0
- package/dist/clickhouse/engine-syntax.d.ts +43 -0
- package/dist/clickhouse/engine-syntax.d.ts.map +1 -0
- package/dist/clickhouse/entities.d.ts +183 -0
- package/dist/clickhouse/entities.d.ts.map +1 -0
- package/dist/clickhouse/http.d.ts +40 -0
- package/dist/clickhouse/http.d.ts.map +1 -0
- package/dist/clickhouse/import/generator.d.ts +16 -0
- package/dist/clickhouse/import/generator.d.ts.map +1 -0
- package/dist/clickhouse/import/ir.d.ts +52 -0
- package/dist/clickhouse/import/ir.d.ts.map +1 -0
- package/dist/clickhouse/import/live-export.d.ts +28 -0
- package/dist/clickhouse/import/live-export.d.ts.map +1 -0
- package/dist/clickhouse/import/parser.d.ts +10 -0
- package/dist/clickhouse/import/parser.d.ts.map +1 -0
- package/dist/clickhouse/live/bind.d.ts +56 -0
- package/dist/clickhouse/live/bind.d.ts.map +1 -0
- package/dist/clickhouse/live/catalog.d.ts +39 -0
- package/dist/clickhouse/live/catalog.d.ts.map +1 -0
- package/dist/clickhouse/live/describe-resources.d.ts +34 -0
- package/dist/clickhouse/live/describe-resources.d.ts.map +1 -0
- package/dist/clickhouse/overlays/codecs.d.ts +28 -0
- package/dist/clickhouse/overlays/codecs.d.ts.map +1 -0
- package/dist/clickhouse/overlays/engines.d.ts +20 -0
- package/dist/clickhouse/overlays/engines.d.ts.map +1 -0
- package/dist/clickhouse/overlays/kinds.d.ts +38 -0
- package/dist/clickhouse/overlays/kinds.d.ts.map +1 -0
- package/dist/clickhouse/overlays/projections.d.ts +27 -0
- package/dist/clickhouse/overlays/projections.d.ts.map +1 -0
- package/dist/clickhouse/overlays/skip-indexes.d.ts +10 -0
- package/dist/clickhouse/overlays/skip-indexes.d.ts.map +1 -0
- package/dist/clickhouse/overlays/ttl.d.ts +35 -0
- package/dist/clickhouse/overlays/ttl.d.ts.map +1 -0
- package/dist/clickhouse/overlays/types.d.ts +21 -0
- package/dist/clickhouse/overlays/types.d.ts.map +1 -0
- package/dist/clickhouse/ownership.d.ts +71 -0
- package/dist/clickhouse/ownership.d.ts.map +1 -0
- package/dist/clickhouse/parser.d.ts +130 -0
- package/dist/clickhouse/parser.d.ts.map +1 -0
- package/dist/clickhouse/plan/commands.d.ts +26 -0
- package/dist/clickhouse/plan/commands.d.ts.map +1 -0
- package/dist/clickhouse/plan/deep.d.ts +32 -0
- package/dist/clickhouse/plan/deep.d.ts.map +1 -0
- package/dist/clickhouse/plan/diff.d.ts +37 -0
- package/dist/clickhouse/plan/diff.d.ts.map +1 -0
- package/dist/clickhouse/plan/disruption.d.ts +17 -0
- package/dist/clickhouse/plan/disruption.d.ts.map +1 -0
- package/dist/clickhouse/plan/normalize.d.ts +97 -0
- package/dist/clickhouse/plan/normalize.d.ts.map +1 -0
- package/dist/clickhouse/plan/rebuild-handoff.d.ts +38 -0
- package/dist/clickhouse/plan/rebuild-handoff.d.ts.map +1 -0
- package/dist/clickhouse/plan/report.d.ts +6 -0
- package/dist/clickhouse/plan/report.d.ts.map +1 -0
- package/dist/clickhouse/plan/rules.d.ts +60 -0
- package/dist/clickhouse/plan/rules.d.ts.map +1 -0
- package/dist/clickhouse/plan/schema.d.ts +23 -0
- package/dist/clickhouse/plan/schema.d.ts.map +1 -0
- package/dist/clickhouse/plan/server-format.d.ts +12 -0
- package/dist/clickhouse/plan/server-format.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/backfill.d.ts +70 -0
- package/dist/clickhouse/rebuild/backfill.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/observe.d.ts +157 -0
- package/dist/clickhouse/rebuild/observe.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/op.d.ts +108 -0
- package/dist/clickhouse/rebuild/op.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/partitions.d.ts +24 -0
- package/dist/clickhouse/rebuild/partitions.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/receipts.d.ts +76 -0
- package/dist/clickhouse/rebuild/receipts.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/replicas.d.ts +78 -0
- package/dist/clickhouse/rebuild/replicas.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/steps.d.ts +151 -0
- package/dist/clickhouse/rebuild/steps.d.ts.map +1 -0
- package/dist/clickhouse/rebuild/verify.d.ts +51 -0
- package/dist/clickhouse/rebuild/verify.d.ts.map +1 -0
- package/dist/clickhouse/testing/fake-server.d.ts +27 -0
- package/dist/clickhouse/testing/fake-server.d.ts.map +1 -0
- package/dist/clickhouse/testing/roundtrip-schema.d.ts +3 -0
- package/dist/clickhouse/testing/roundtrip-schema.d.ts.map +1 -0
- package/dist/clickhouse/testing/writable-server.d.ts +35 -0
- package/dist/clickhouse/testing/writable-server.d.ts.map +1 -0
- package/dist/clickhouse/tokens.d.ts +15 -0
- package/dist/clickhouse/tokens.d.ts.map +1 -0
- package/dist/clickhouse.d.ts +24 -0
- package/dist/clickhouse.d.ts.map +1 -0
- package/dist/codegen/classifier-page.d.ts +6 -0
- package/dist/codegen/classifier-page.d.ts.map +1 -0
- package/dist/codegen/clickhouse-module.d.ts +23 -0
- package/dist/codegen/clickhouse-module.d.ts.map +1 -0
- package/dist/codegen/docs-cli.d.ts +3 -0
- package/dist/codegen/docs-cli.d.ts.map +1 -0
- package/dist/codegen/docs.d.ts +8 -0
- package/dist/codegen/docs.d.ts.map +1 -0
- package/dist/codegen/generate-cli.d.ts +3 -0
- package/dist/codegen/generate-cli.d.ts.map +1 -0
- package/dist/codegen/generate.d.ts +40 -0
- package/dist/codegen/generate.d.ts.map +1 -0
- package/dist/codegen/package.d.ts +7 -0
- package/dist/codegen/package.d.ts.map +1 -0
- package/dist/codegen/postgres-classifier-page.d.ts +7 -0
- package/dist/codegen/postgres-classifier-page.d.ts.map +1 -0
- package/dist/codegen/postgres-module.d.ts +30 -0
- package/dist/codegen/postgres-module.d.ts.map +1 -0
- package/dist/codegen/registry.d.ts +12 -0
- package/dist/codegen/registry.d.ts.map +1 -0
- package/dist/composites/audit-log-table.d.ts +31 -0
- package/dist/composites/audit-log-table.d.ts.map +1 -0
- package/dist/composites/catalog.d.ts +3 -0
- package/dist/composites/catalog.d.ts.map +1 -0
- package/dist/composites/cdc-mirror.d.ts +32 -0
- package/dist/composites/cdc-mirror.d.ts.map +1 -0
- package/dist/composites/clickhouse.d.ts +7 -0
- package/dist/composites/clickhouse.d.ts.map +1 -0
- package/dist/composites/events-table.d.ts +32 -0
- package/dist/composites/events-table.d.ts.map +1 -0
- package/dist/composites/index.d.ts +9 -0
- package/dist/composites/index.d.ts.map +1 -0
- package/dist/composites/join-table.d.ts +41 -0
- package/dist/composites/join-table.d.ts.map +1 -0
- package/dist/composites/postgres.d.ts +7 -0
- package/dist/composites/postgres.d.ts.map +1 -0
- package/dist/composites/refreshed-view.d.ts +32 -0
- package/dist/composites/refreshed-view.d.ts.map +1 -0
- package/dist/composites/replacing-table.d.ts +34 -0
- package/dist/composites/replacing-table.d.ts.map +1 -0
- package/dist/composites/rollup-view.d.ts +39 -0
- package/dist/composites/rollup-view.d.ts.map +1 -0
- package/dist/composites/sharded-table.d.ts +35 -0
- package/dist/composites/sharded-table.d.ts.map +1 -0
- package/dist/composites/soft-delete-table.d.ts +40 -0
- package/dist/composites/soft-delete-table.d.ts.map +1 -0
- package/dist/composites/tenant-table.d.ts +34 -0
- package/dist/composites/tenant-table.d.ts.map +1 -0
- package/dist/config.d.ts +213 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/core/apply.d.ts +89 -0
- package/dist/core/apply.d.ts.map +1 -0
- package/dist/core/classifier.d.ts +88 -0
- package/dist/core/classifier.d.ts.map +1 -0
- package/dist/core/container.d.ts +45 -0
- package/dist/core/container.d.ts.map +1 -0
- package/dist/core/cursor.d.ts +67 -0
- package/dist/core/cursor.d.ts.map +1 -0
- package/dist/core/diff.d.ts +49 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/core/entity.d.ts +41 -0
- package/dist/core/entity.d.ts.map +1 -0
- package/dist/core/find-templates.d.ts +69 -0
- package/dist/core/find-templates.d.ts.map +1 -0
- package/dist/core/handoff.d.ts +36 -0
- package/dist/core/handoff.d.ts.map +1 -0
- package/dist/core/index.d.ts +61 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/interpolation.d.ts +88 -0
- package/dist/core/interpolation.d.ts.map +1 -0
- package/dist/core/normalize.d.ts +18 -0
- package/dist/core/normalize.d.ts.map +1 -0
- package/dist/core/ownership.d.ts +60 -0
- package/dist/core/ownership.d.ts.map +1 -0
- package/dist/core/receipts.d.ts +28 -0
- package/dist/core/receipts.d.ts.map +1 -0
- package/dist/core/references.d.ts +37 -0
- package/dist/core/references.d.ts.map +1 -0
- package/dist/core/template.d.ts +41 -0
- package/dist/core/template.d.ts.map +1 -0
- package/dist/core/testing/http-stub.d.ts +17 -0
- package/dist/core/testing/http-stub.d.ts.map +1 -0
- package/dist/core/tokens.d.ts +102 -0
- package/dist/core/tokens.d.ts.map +1 -0
- package/dist/coverage.d.ts +25 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/detect.d.ts +15 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/dialects.d.ts +20 -0
- package/dist/dialects.d.ts.map +1 -0
- package/dist/generated/clickhouse-types.d.ts +4380 -0
- package/dist/generated/clickhouse-types.d.ts.map +1 -0
- package/dist/generated/clickhouse.d.ts +11 -0
- package/dist/generated/clickhouse.d.ts.map +1 -0
- package/dist/generated/postgres-types.d.ts +1579 -0
- package/dist/generated/postgres-types.d.ts.map +1 -0
- package/dist/generated/postgres.d.ts +9 -0
- package/dist/generated/postgres.d.ts.map +1 -0
- package/dist/import-generator.d.ts +8 -0
- package/dist/import-generator.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/init-templates.d.ts +20 -0
- package/dist/init-templates.d.ts.map +1 -0
- package/dist/integrity.json +61 -0
- package/dist/lint/audit-catalog.d.ts +10 -0
- package/dist/lint/audit-catalog.d.ts.map +1 -0
- package/dist/lint/audit-lineage.d.ts +25 -0
- package/dist/lint/audit-lineage.d.ts.map +1 -0
- package/dist/lint/post-synth/audit-entries.d.ts +8 -0
- package/dist/lint/post-synth/audit-entries.d.ts.map +1 -0
- package/dist/lint/post-synth/clickhouse-helpers.d.ts +85 -0
- package/dist/lint/post-synth/clickhouse-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/index.d.ts +3 -0
- package/dist/lint/post-synth/index.d.ts.map +1 -0
- package/dist/lint/post-synth/postgres-audit-entries.d.ts +9 -0
- package/dist/lint/post-synth/postgres-audit-entries.d.ts.map +1 -0
- package/dist/lint/post-synth/postgres-helpers.d.ts +89 -0
- package/dist/lint/post-synth/postgres-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/sql-helpers.d.ts +27 -0
- package/dist/lint/post-synth/sql-helpers.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch101.d.ts +12 -0
- package/dist/lint/post-synth/sqlch101.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch102.d.ts +9 -0
- package/dist/lint/post-synth/sqlch102.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch103.d.ts +10 -0
- package/dist/lint/post-synth/sqlch103.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch104.d.ts +9 -0
- package/dist/lint/post-synth/sqlch104.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch105.d.ts +10 -0
- package/dist/lint/post-synth/sqlch105.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch106.d.ts +11 -0
- package/dist/lint/post-synth/sqlch106.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch107.d.ts +10 -0
- package/dist/lint/post-synth/sqlch107.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch108.d.ts +11 -0
- package/dist/lint/post-synth/sqlch108.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch109.d.ts +10 -0
- package/dist/lint/post-synth/sqlch109.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch110.d.ts +12 -0
- package/dist/lint/post-synth/sqlch110.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch111.d.ts +11 -0
- package/dist/lint/post-synth/sqlch111.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch112.d.ts +12 -0
- package/dist/lint/post-synth/sqlch112.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch113.d.ts +9 -0
- package/dist/lint/post-synth/sqlch113.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch114.d.ts +8 -0
- package/dist/lint/post-synth/sqlch114.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch115.d.ts +13 -0
- package/dist/lint/post-synth/sqlch115.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch116.d.ts +10 -0
- package/dist/lint/post-synth/sqlch116.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch117.d.ts +9 -0
- package/dist/lint/post-synth/sqlch117.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch118.d.ts +10 -0
- package/dist/lint/post-synth/sqlch118.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch119.d.ts +11 -0
- package/dist/lint/post-synth/sqlch119.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlch120.d.ts +10 -0
- package/dist/lint/post-synth/sqlch120.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg101.d.ts +12 -0
- package/dist/lint/post-synth/sqlpg101.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg102.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg102.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg103.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg103.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg104.d.ts +10 -0
- package/dist/lint/post-synth/sqlpg104.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg105.d.ts +10 -0
- package/dist/lint/post-synth/sqlpg105.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg106.d.ts +9 -0
- package/dist/lint/post-synth/sqlpg106.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg107.d.ts +10 -0
- package/dist/lint/post-synth/sqlpg107.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg108.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg108.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg109.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg109.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg110.d.ts +12 -0
- package/dist/lint/post-synth/sqlpg110.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg111.d.ts +10 -0
- package/dist/lint/post-synth/sqlpg111.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg112.d.ts +10 -0
- package/dist/lint/post-synth/sqlpg112.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg113.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg113.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg114.d.ts +13 -0
- package/dist/lint/post-synth/sqlpg114.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg115.d.ts +13 -0
- package/dist/lint/post-synth/sqlpg115.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg116.d.ts +11 -0
- package/dist/lint/post-synth/sqlpg116.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg117.d.ts +12 -0
- package/dist/lint/post-synth/sqlpg117.d.ts.map +1 -0
- package/dist/lint/post-synth/sqlpg118.d.ts +12 -0
- package/dist/lint/post-synth/sqlpg118.d.ts.map +1 -0
- package/dist/lint/rules/index.d.ts +12 -0
- package/dist/lint/rules/index.d.ts.map +1 -0
- package/dist/lint/rules/postgres-templates.d.ts +18 -0
- package/dist/lint/rules/postgres-templates.d.ts.map +1 -0
- package/dist/lint/rules/sqlch001.d.ts +12 -0
- package/dist/lint/rules/sqlch001.d.ts.map +1 -0
- package/dist/lint/rules/sqlch002.d.ts +11 -0
- package/dist/lint/rules/sqlch002.d.ts.map +1 -0
- package/dist/lint/rules/sqlch003.d.ts +12 -0
- package/dist/lint/rules/sqlch003.d.ts.map +1 -0
- package/dist/lint/rules/sqlpg001.d.ts +16 -0
- package/dist/lint/rules/sqlpg001.d.ts.map +1 -0
- package/dist/lint/rules/sqlpg002.d.ts +12 -0
- package/dist/lint/rules/sqlpg002.d.ts.map +1 -0
- package/dist/lint/rules/sqlpg003.d.ts +16 -0
- package/dist/lint/rules/sqlpg003.d.ts.map +1 -0
- package/dist/lint/rules/sqlpg004.d.ts +21 -0
- package/dist/lint/rules/sqlpg004.d.ts.map +1 -0
- package/dist/lint/rules/templates.d.ts +23 -0
- package/dist/lint/rules/templates.d.ts.map +1 -0
- package/dist/live-dialect.d.ts +25 -0
- package/dist/live-dialect.d.ts.map +1 -0
- package/dist/lsp/catalog.d.ts +22 -0
- package/dist/lsp/catalog.d.ts.map +1 -0
- package/dist/lsp/completions.d.ts +13 -0
- package/dist/lsp/completions.d.ts.map +1 -0
- package/dist/lsp/hover.d.ts +12 -0
- package/dist/lsp/hover.d.ts.map +1 -0
- package/dist/lsp/postgres-catalog.d.ts +85 -0
- package/dist/lsp/postgres-catalog.d.ts.map +1 -0
- package/dist/lsp/postgres-template.d.ts +35 -0
- package/dist/lsp/postgres-template.d.ts.map +1 -0
- package/dist/lsp/postgres.d.ts +20 -0
- package/dist/lsp/postgres.d.ts.map +1 -0
- package/dist/lsp/refs.d.ts +8 -0
- package/dist/lsp/refs.d.ts.map +1 -0
- package/dist/lsp/registry.d.ts +4 -0
- package/dist/lsp/registry.d.ts.map +1 -0
- package/dist/lsp/template.d.ts +34 -0
- package/dist/lsp/template.d.ts.map +1 -0
- package/dist/manifest.json +8 -0
- package/dist/mcp/index.d.ts +13 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/postgres.d.ts +32 -0
- package/dist/mcp/postgres.d.ts.map +1 -0
- package/dist/meta.json +67 -0
- package/dist/okf/index.md +67 -0
- package/dist/okf/rules/SQLCH001.md +11 -0
- package/dist/okf/rules/SQLCH002.md +11 -0
- package/dist/okf/rules/SQLCH003.md +11 -0
- package/dist/okf/rules/SQLCH101.md +15 -0
- package/dist/okf/rules/SQLCH102.md +11 -0
- package/dist/okf/rules/SQLCH103.md +11 -0
- package/dist/okf/rules/SQLCH104.md +11 -0
- package/dist/okf/rules/SQLCH105.md +11 -0
- package/dist/okf/rules/SQLCH106.md +11 -0
- package/dist/okf/rules/SQLCH107.md +11 -0
- package/dist/okf/rules/SQLCH108.md +15 -0
- package/dist/okf/rules/SQLCH109.md +11 -0
- package/dist/okf/rules/SQLCH110.md +11 -0
- package/dist/okf/rules/SQLCH111.md +11 -0
- package/dist/okf/rules/SQLCH112.md +11 -0
- package/dist/okf/rules/SQLCH113.md +11 -0
- package/dist/okf/rules/SQLCH114.md +11 -0
- package/dist/okf/rules/SQLCH115.md +11 -0
- package/dist/okf/rules/SQLCH116.md +11 -0
- package/dist/okf/rules/SQLCH117.md +15 -0
- package/dist/okf/rules/SQLCH118.md +15 -0
- package/dist/okf/rules/SQLCH119.md +15 -0
- package/dist/okf/rules/SQLCH120.md +15 -0
- package/dist/okf/rules/SQLPG001.md +11 -0
- package/dist/okf/rules/SQLPG002.md +11 -0
- package/dist/okf/rules/SQLPG003.md +11 -0
- package/dist/okf/rules/SQLPG004.md +11 -0
- package/dist/okf/rules/SQLPG101.md +11 -0
- package/dist/okf/rules/SQLPG102.md +11 -0
- package/dist/okf/rules/SQLPG103.md +11 -0
- package/dist/okf/rules/SQLPG104.md +11 -0
- package/dist/okf/rules/SQLPG105.md +11 -0
- package/dist/okf/rules/SQLPG106.md +11 -0
- package/dist/okf/rules/SQLPG107.md +11 -0
- package/dist/okf/rules/SQLPG108.md +11 -0
- package/dist/okf/rules/SQLPG109.md +11 -0
- package/dist/okf/rules/SQLPG110.md +11 -0
- package/dist/okf/rules/SQLPG111.md +11 -0
- package/dist/okf/rules/SQLPG112.md +11 -0
- package/dist/okf/rules/SQLPG113.md +24 -0
- package/dist/okf/rules/SQLPG114.md +11 -0
- package/dist/okf/rules/SQLPG115.md +11 -0
- package/dist/okf/rules/SQLPG116.md +15 -0
- package/dist/okf/rules/SQLPG117.md +11 -0
- package/dist/okf/rules/SQLPG118.md +11 -0
- package/dist/okf/types/Database.md +15 -0
- package/dist/okf/types/MaterializedView.md +14 -0
- package/dist/okf/types/PostgresDomain.md +13 -0
- package/dist/okf/types/PostgresEnum.md +13 -0
- package/dist/okf/types/PostgresExtension.md +13 -0
- package/dist/okf/types/PostgresIndex.md +9 -0
- package/dist/okf/types/PostgresMaterializedView.md +13 -0
- package/dist/okf/types/PostgresSchema.md +13 -0
- package/dist/okf/types/PostgresSequence.md +13 -0
- package/dist/okf/types/PostgresTable.md +13 -0
- package/dist/okf/types/PostgresView.md +13 -0
- package/dist/okf/types/Table.md +15 -0
- package/dist/okf/types/View.md +13 -0
- package/dist/op/activities/clickhouse-apply.d.ts +56 -0
- package/dist/op/activities/clickhouse-apply.d.ts.map +1 -0
- package/dist/op/activities/clickhouse-emulator.d.ts +26 -0
- package/dist/op/activities/clickhouse-emulator.d.ts.map +1 -0
- package/dist/op/activities/clickhouse-rebuild.d.ts +43 -0
- package/dist/op/activities/clickhouse-rebuild.d.ts.map +1 -0
- package/dist/op/activities/index.d.ts +19 -0
- package/dist/op/activities/index.d.ts.map +1 -0
- package/dist/op/activities/postgres-apply.d.ts +69 -0
- package/dist/op/activities/postgres-apply.d.ts.map +1 -0
- package/dist/op/activities/postgres-emulator.d.ts +33 -0
- package/dist/op/activities/postgres-emulator.d.ts.map +1 -0
- package/dist/op/activities/postgres-migration.d.ts +48 -0
- package/dist/op/activities/postgres-migration.d.ts.map +1 -0
- package/dist/op/activity-contracts.d.ts +464 -0
- package/dist/op/activity-contracts.d.ts.map +1 -0
- package/dist/package-cli.d.ts +3 -0
- package/dist/package-cli.d.ts.map +1 -0
- package/dist/plugin.d.ts +12 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/postgres/apply/apply.d.ts +163 -0
- package/dist/postgres/apply/apply.d.ts.map +1 -0
- package/dist/postgres/apply/statements.d.ts +138 -0
- package/dist/postgres/apply/statements.d.ts.map +1 -0
- package/dist/postgres/catalog-types.d.ts +50 -0
- package/dist/postgres/catalog-types.d.ts.map +1 -0
- package/dist/postgres/container.d.ts +23 -0
- package/dist/postgres/container.d.ts.map +1 -0
- package/dist/postgres/entities.d.ts +322 -0
- package/dist/postgres/entities.d.ts.map +1 -0
- package/dist/postgres/entity-types.d.ts +17 -0
- package/dist/postgres/entity-types.d.ts.map +1 -0
- package/dist/postgres/import/generator.d.ts +28 -0
- package/dist/postgres/import/generator.d.ts.map +1 -0
- package/dist/postgres/import/ir.d.ts +24 -0
- package/dist/postgres/import/ir.d.ts.map +1 -0
- package/dist/postgres/import/live-export.d.ts +26 -0
- package/dist/postgres/import/live-export.d.ts.map +1 -0
- package/dist/postgres/keywords.d.ts +22 -0
- package/dist/postgres/keywords.d.ts.map +1 -0
- package/dist/postgres/live/bind.d.ts +76 -0
- package/dist/postgres/live/bind.d.ts.map +1 -0
- package/dist/postgres/live/catalog.d.ts +98 -0
- package/dist/postgres/live/catalog.d.ts.map +1 -0
- package/dist/postgres/live/client.d.ts +32 -0
- package/dist/postgres/live/client.d.ts.map +1 -0
- package/dist/postgres/live/describe-resources.d.ts +41 -0
- package/dist/postgres/live/describe-resources.d.ts.map +1 -0
- package/dist/postgres/migrate/backfill.d.ts +103 -0
- package/dist/postgres/migrate/backfill.d.ts.map +1 -0
- package/dist/postgres/migrate/batches.d.ts +90 -0
- package/dist/postgres/migrate/batches.d.ts.map +1 -0
- package/dist/postgres/migrate/carry.d.ts +196 -0
- package/dist/postgres/migrate/carry.d.ts.map +1 -0
- package/dist/postgres/migrate/handoff.d.ts +46 -0
- package/dist/postgres/migrate/handoff.d.ts.map +1 -0
- package/dist/postgres/migrate/names.d.ts +55 -0
- package/dist/postgres/migrate/names.d.ts.map +1 -0
- package/dist/postgres/migrate/observe.d.ts +139 -0
- package/dist/postgres/migrate/observe.d.ts.map +1 -0
- package/dist/postgres/migrate/op.d.ts +128 -0
- package/dist/postgres/migrate/op.d.ts.map +1 -0
- package/dist/postgres/migrate/receipts.d.ts +63 -0
- package/dist/postgres/migrate/receipts.d.ts.map +1 -0
- package/dist/postgres/migrate/replication.d.ts +80 -0
- package/dist/postgres/migrate/replication.d.ts.map +1 -0
- package/dist/postgres/migrate/steps.d.ts +225 -0
- package/dist/postgres/migrate/steps.d.ts.map +1 -0
- package/dist/postgres/overlays/columns.d.ts +6 -0
- package/dist/postgres/overlays/columns.d.ts.map +1 -0
- package/dist/postgres/overlays/constraints.d.ts +8 -0
- package/dist/postgres/overlays/constraints.d.ts.map +1 -0
- package/dist/postgres/overlays/indexes.d.ts +8 -0
- package/dist/postgres/overlays/indexes.d.ts.map +1 -0
- package/dist/postgres/overlays/kinds.d.ts +48 -0
- package/dist/postgres/overlays/kinds.d.ts.map +1 -0
- package/dist/postgres/overlays/partitioning.d.ts +5 -0
- package/dist/postgres/overlays/partitioning.d.ts.map +1 -0
- package/dist/postgres/overlays/relations.d.ts +6 -0
- package/dist/postgres/overlays/relations.d.ts.map +1 -0
- package/dist/postgres/overlays/storage.d.ts +28 -0
- package/dist/postgres/overlays/storage.d.ts.map +1 -0
- package/dist/postgres/overlays/type-ddl.d.ts +7 -0
- package/dist/postgres/overlays/type-ddl.d.ts.map +1 -0
- package/dist/postgres/overlays/types.d.ts +24 -0
- package/dist/postgres/overlays/types.d.ts.map +1 -0
- package/dist/postgres/parser.d.ts +216 -0
- package/dist/postgres/parser.d.ts.map +1 -0
- package/dist/postgres/plan/commands.d.ts +61 -0
- package/dist/postgres/plan/commands.d.ts.map +1 -0
- package/dist/postgres/plan/deep.d.ts +33 -0
- package/dist/postgres/plan/deep.d.ts.map +1 -0
- package/dist/postgres/plan/diff.d.ts +45 -0
- package/dist/postgres/plan/diff.d.ts.map +1 -0
- package/dist/postgres/plan/disruption.d.ts +14 -0
- package/dist/postgres/plan/disruption.d.ts.map +1 -0
- package/dist/postgres/plan/normalize.d.ts +108 -0
- package/dist/postgres/plan/normalize.d.ts.map +1 -0
- package/dist/postgres/plan/report.d.ts +6 -0
- package/dist/postgres/plan/report.d.ts.map +1 -0
- package/dist/postgres/plan/rules.d.ts +84 -0
- package/dist/postgres/plan/rules.d.ts.map +1 -0
- package/dist/postgres/plan/schema.d.ts +50 -0
- package/dist/postgres/plan/schema.d.ts.map +1 -0
- package/dist/postgres/plan/server-normalize.d.ts +26 -0
- package/dist/postgres/plan/server-normalize.d.ts.map +1 -0
- package/dist/postgres/providers/aurora.d.ts +12 -0
- package/dist/postgres/providers/aurora.d.ts.map +1 -0
- package/dist/postgres/providers/azure.d.ts +14 -0
- package/dist/postgres/providers/azure.d.ts.map +1 -0
- package/dist/postgres/providers/cloud-sql.d.ts +11 -0
- package/dist/postgres/providers/cloud-sql.d.ts.map +1 -0
- package/dist/postgres/providers/index.d.ts +35 -0
- package/dist/postgres/providers/index.d.ts.map +1 -0
- package/dist/postgres/providers/neon.d.ts +13 -0
- package/dist/postgres/providers/neon.d.ts.map +1 -0
- package/dist/postgres/providers/rds.d.ts +10 -0
- package/dist/postgres/providers/rds.d.ts.map +1 -0
- package/dist/postgres/providers/supabase.d.ts +12 -0
- package/dist/postgres/providers/supabase.d.ts.map +1 -0
- package/dist/postgres/providers/types.d.ts +59 -0
- package/dist/postgres/providers/types.d.ts.map +1 -0
- package/dist/postgres/testing/fake-client.d.ts +38 -0
- package/dist/postgres/testing/fake-client.d.ts.map +1 -0
- package/dist/postgres/testing/migration.d.ts +25 -0
- package/dist/postgres/testing/migration.d.ts.map +1 -0
- package/dist/postgres/testing/roundtrip-schema.d.ts +11 -0
- package/dist/postgres/testing/roundtrip-schema.d.ts.map +1 -0
- package/dist/postgres/testing/server.d.ts +17 -0
- package/dist/postgres/testing/server.d.ts.map +1 -0
- package/dist/postgres/testing/writable-server.d.ts +45 -0
- package/dist/postgres/testing/writable-server.d.ts.map +1 -0
- package/dist/postgres/tokens.d.ts +26 -0
- package/dist/postgres/tokens.d.ts.map +1 -0
- package/dist/postgres.d.ts +13 -0
- package/dist/postgres.d.ts.map +1 -0
- package/dist/rules/audit-entries.ts +29 -0
- package/dist/rules/clickhouse-helpers.ts +206 -0
- package/dist/rules/postgres-audit-entries.ts +29 -0
- package/dist/rules/postgres-helpers.ts +126 -0
- package/dist/rules/postgres-templates.ts +36 -0
- package/dist/rules/sql-helpers.ts +53 -0
- package/dist/rules/sqlch001.ts +53 -0
- package/dist/rules/sqlch002.ts +115 -0
- package/dist/rules/sqlch003.ts +68 -0
- package/dist/rules/sqlch101.ts +35 -0
- package/dist/rules/sqlch102.ts +23 -0
- package/dist/rules/sqlch103.ts +45 -0
- package/dist/rules/sqlch104.ts +42 -0
- package/dist/rules/sqlch105.ts +35 -0
- package/dist/rules/sqlch106.ts +27 -0
- package/dist/rules/sqlch107.ts +35 -0
- package/dist/rules/sqlch108.ts +27 -0
- package/dist/rules/sqlch109.ts +21 -0
- package/dist/rules/sqlch110.ts +29 -0
- package/dist/rules/sqlch111.ts +40 -0
- package/dist/rules/sqlch112.ts +30 -0
- package/dist/rules/sqlch113.ts +20 -0
- package/dist/rules/sqlch114.ts +26 -0
- package/dist/rules/sqlch115.ts +31 -0
- package/dist/rules/sqlch116.ts +22 -0
- package/dist/rules/sqlch117.ts +25 -0
- package/dist/rules/sqlch118.ts +26 -0
- package/dist/rules/sqlch119.ts +31 -0
- package/dist/rules/sqlch120.ts +21 -0
- package/dist/rules/sqlpg001.ts +88 -0
- package/dist/rules/sqlpg002.ts +68 -0
- package/dist/rules/sqlpg003.ts +59 -0
- package/dist/rules/sqlpg004.ts +73 -0
- package/dist/rules/sqlpg101.ts +24 -0
- package/dist/rules/sqlpg102.ts +30 -0
- package/dist/rules/sqlpg103.ts +23 -0
- package/dist/rules/sqlpg104.ts +23 -0
- package/dist/rules/sqlpg105.ts +22 -0
- package/dist/rules/sqlpg106.ts +22 -0
- package/dist/rules/sqlpg107.ts +22 -0
- package/dist/rules/sqlpg108.ts +27 -0
- package/dist/rules/sqlpg109.ts +37 -0
- package/dist/rules/sqlpg110.ts +33 -0
- package/dist/rules/sqlpg111.ts +23 -0
- package/dist/rules/sqlpg112.ts +25 -0
- package/dist/rules/sqlpg113.ts +28 -0
- package/dist/rules/sqlpg114.ts +37 -0
- package/dist/rules/sqlpg115.ts +38 -0
- package/dist/rules/sqlpg116.ts +25 -0
- package/dist/rules/sqlpg117.ts +24 -0
- package/dist/rules/sqlpg118.ts +22 -0
- package/dist/rules/templates.ts +35 -0
- package/dist/serializer.d.ts +37 -0
- package/dist/serializer.d.ts.map +1 -0
- package/dist/skill-defs.d.ts +3 -0
- package/dist/skill-defs.d.ts.map +1 -0
- package/dist/spec/catalog.d.ts +125 -0
- package/dist/spec/catalog.d.ts.map +1 -0
- package/dist/spec/fetch.d.ts +43 -0
- package/dist/spec/fetch.d.ts.map +1 -0
- package/dist/spec/pin.d.ts +39 -0
- package/dist/spec/pin.d.ts.map +1 -0
- package/dist/spec/postgres-catalog.d.ts +108 -0
- package/dist/spec/postgres-catalog.d.ts.map +1 -0
- package/dist/spec/postgres-fetch.d.ts +46 -0
- package/dist/spec/postgres-fetch.d.ts.map +1 -0
- package/dist/spec/postgres-pin.d.ts +67 -0
- package/dist/spec/postgres-pin.d.ts.map +1 -0
- package/dist/types/index.d.ts +4386 -0
- package/dist/validate-cli.d.ts +3 -0
- package/dist/validate-cli.d.ts.map +1 -0
- package/dist/validate.d.ts +15 -0
- package/dist/validate.d.ts.map +1 -0
- package/package.json +74 -4
- package/src/clickhouse/apply/apply.ts +288 -0
- package/src/clickhouse/apply/mutations.ts +90 -0
- package/src/clickhouse/apply/statements.ts +393 -0
- package/src/clickhouse/catalog-types.ts +84 -0
- package/src/clickhouse/container.ts +176 -0
- package/src/clickhouse/engine-syntax.test.ts +53 -0
- package/src/clickhouse/engine-syntax.ts +173 -0
- package/src/clickhouse/entities.test.ts +188 -0
- package/src/clickhouse/entities.ts +425 -0
- package/src/clickhouse/http.ts +76 -0
- package/src/clickhouse/import/generator.ts +153 -0
- package/src/clickhouse/import/import.test.ts +157 -0
- package/src/clickhouse/import/ir.ts +171 -0
- package/src/clickhouse/import/live-export.ts +53 -0
- package/src/clickhouse/import/parser.ts +27 -0
- package/src/clickhouse/import/roundtrip.test.ts +90 -0
- package/src/clickhouse/live/bind.ts +126 -0
- package/src/clickhouse/live/catalog.ts +96 -0
- package/src/clickhouse/live/describe-resources.ts +98 -0
- package/src/clickhouse/live/live.test.ts +143 -0
- package/src/clickhouse/live/roundtrip.e2e.test.ts +93 -0
- package/src/clickhouse/overlays/codecs.ts +68 -0
- package/src/clickhouse/overlays/engines.ts +108 -0
- package/src/clickhouse/overlays/kinds.ts +38 -0
- package/src/clickhouse/overlays/projections.ts +36 -0
- package/src/clickhouse/overlays/skip-indexes.ts +44 -0
- package/src/clickhouse/overlays/ttl.ts +55 -0
- package/src/clickhouse/overlays/types.ts +58 -0
- package/src/clickhouse/ownership.test.ts +20 -0
- package/src/clickhouse/ownership.ts +103 -0
- package/src/clickhouse/parser.test.ts +166 -0
- package/src/clickhouse/parser.ts +459 -0
- package/src/clickhouse/plan/commands.ts +101 -0
- package/src/clickhouse/plan/deep.ts +124 -0
- package/src/clickhouse/plan/diff.ts +203 -0
- package/src/clickhouse/plan/disruption.ts +61 -0
- package/src/clickhouse/plan/normalize.ts +352 -0
- package/src/clickhouse/plan/plan-wiring.test.ts +77 -0
- package/src/clickhouse/plan/plan.e2e.test.ts +77 -0
- package/src/clickhouse/plan/plan.test.ts +201 -0
- package/src/clickhouse/plan/rebuild-handoff.ts +59 -0
- package/src/clickhouse/plan/report.ts +19 -0
- package/src/clickhouse/plan/rules.ts +241 -0
- package/src/clickhouse/plan/schema.ts +56 -0
- package/src/clickhouse/plan/server-format.ts +39 -0
- package/src/clickhouse/rebuild/backfill.ts +186 -0
- package/src/clickhouse/rebuild/observe.ts +380 -0
- package/src/clickhouse/rebuild/op.ts +206 -0
- package/src/clickhouse/rebuild/partitions.ts +62 -0
- package/src/clickhouse/rebuild/rebuild-replicated.e2e.test.ts +513 -0
- package/src/clickhouse/rebuild/rebuild.e2e.test.ts +351 -0
- package/src/clickhouse/rebuild/rebuild.test.ts +190 -0
- package/src/clickhouse/rebuild/receipts.ts +143 -0
- package/src/clickhouse/rebuild/replicas.test.ts +70 -0
- package/src/clickhouse/rebuild/replicas.ts +148 -0
- package/src/clickhouse/rebuild/steps.ts +382 -0
- package/src/clickhouse/rebuild/verify.ts +124 -0
- package/src/clickhouse/testdata/NOTICE +5 -0
- package/src/clickhouse/testdata/clickhouse-tests-corpus.json +302 -0
- package/src/clickhouse/testing/fake-server.ts +65 -0
- package/src/clickhouse/testing/roundtrip-schema.ts +25 -0
- package/src/clickhouse/testing/writable-server.ts +141 -0
- package/src/clickhouse/tokens.ts +28 -0
- package/src/clickhouse.ts +63 -0
- package/src/codegen/classifier-page.test.ts +16 -0
- package/src/codegen/classifier-page.ts +76 -0
- package/src/codegen/clickhouse-module.test.ts +63 -0
- package/src/codegen/clickhouse-module.ts +269 -0
- package/src/codegen/docs-cli.ts +4 -0
- package/src/codegen/docs.ts +225 -0
- package/src/codegen/generate-cli.ts +13 -0
- package/src/codegen/generate.ts +126 -0
- package/src/codegen/package.ts +36 -0
- package/src/codegen/postgres-classifier-page.ts +81 -0
- package/src/codegen/postgres-module.test.ts +77 -0
- package/src/codegen/postgres-module.ts +434 -0
- package/src/codegen/registry.ts +36 -0
- package/src/composites/audit-log-table.ts +54 -0
- package/src/composites/catalog.test.ts +61 -0
- package/src/composites/catalog.ts +529 -0
- package/src/composites/cdc-mirror.ts +54 -0
- package/src/composites/clickhouse.ts +7 -0
- package/src/composites/composites.test.ts +758 -0
- package/src/composites/events-table.ts +49 -0
- package/src/composites/index.ts +9 -0
- package/src/composites/join-table.ts +57 -0
- package/src/composites/postgres.ts +7 -0
- package/src/composites/refreshed-view.ts +46 -0
- package/src/composites/replacing-table.ts +49 -0
- package/src/composites/rollup-view.ts +55 -0
- package/src/composites/sharded-table.ts +49 -0
- package/src/composites/soft-delete-table.ts +61 -0
- package/src/composites/tenant-table.ts +50 -0
- package/src/config.ts +157 -0
- package/src/core/apply.ts +153 -0
- package/src/core/classifier.ts +186 -0
- package/src/core/container.ts +93 -0
- package/src/core/core.test.ts +254 -0
- package/src/core/cursor.ts +189 -0
- package/src/core/diff.ts +72 -0
- package/src/core/entity.ts +85 -0
- package/src/core/find-templates.ts +158 -0
- package/src/core/handoff.ts +44 -0
- package/src/core/index.ts +61 -0
- package/src/core/interpolation.ts +225 -0
- package/src/core/normalize.ts +39 -0
- package/src/core/ownership.test.ts +36 -0
- package/src/core/ownership.ts +133 -0
- package/src/core/receipts.ts +29 -0
- package/src/core/references.ts +74 -0
- package/src/core/template.ts +83 -0
- package/src/core/testing/http-stub.ts +33 -0
- package/src/core/tokens.ts +252 -0
- package/src/coverage.ts +64 -0
- package/src/detect.ts +32 -0
- package/src/dialects.ts +21 -0
- package/src/generated/clickhouse-types.ts +4386 -0
- package/src/generated/clickhouse.ts +2476 -0
- package/src/generated/index.d.ts +4386 -0
- package/src/generated/lexicon-sql.json +67 -0
- package/src/generated/postgres-types.ts +1190 -0
- package/src/generated/postgres.ts +1039 -0
- package/src/import-generator.ts +18 -0
- package/src/index.ts +21 -0
- package/src/init-templates.test.ts +108 -0
- package/src/init-templates.ts +327 -0
- package/src/lint/audit-catalog.ts +73 -0
- package/src/lint/audit-lineage.ts +47 -0
- package/src/lint/post-synth/audit-entries.ts +29 -0
- package/src/lint/post-synth/clickhouse-checks.test.ts +278 -0
- package/src/lint/post-synth/clickhouse-helpers.ts +206 -0
- package/src/lint/post-synth/index.ts +81 -0
- package/src/lint/post-synth/post-synth.test.ts +33 -0
- package/src/lint/post-synth/postgres-audit-entries.ts +29 -0
- package/src/lint/post-synth/postgres-checks.test.ts +257 -0
- package/src/lint/post-synth/postgres-helpers.ts +126 -0
- package/src/lint/post-synth/sql-helpers.ts +53 -0
- package/src/lint/post-synth/sqlch101.ts +35 -0
- package/src/lint/post-synth/sqlch102.ts +23 -0
- package/src/lint/post-synth/sqlch103.ts +45 -0
- package/src/lint/post-synth/sqlch104.ts +42 -0
- package/src/lint/post-synth/sqlch105.ts +35 -0
- package/src/lint/post-synth/sqlch106.ts +27 -0
- package/src/lint/post-synth/sqlch107.ts +35 -0
- package/src/lint/post-synth/sqlch108.ts +27 -0
- package/src/lint/post-synth/sqlch109.ts +21 -0
- package/src/lint/post-synth/sqlch110.ts +29 -0
- package/src/lint/post-synth/sqlch111.ts +40 -0
- package/src/lint/post-synth/sqlch112.ts +30 -0
- package/src/lint/post-synth/sqlch113.ts +20 -0
- package/src/lint/post-synth/sqlch114.ts +26 -0
- package/src/lint/post-synth/sqlch115.ts +31 -0
- package/src/lint/post-synth/sqlch116.ts +22 -0
- package/src/lint/post-synth/sqlch117.ts +25 -0
- package/src/lint/post-synth/sqlch118.ts +26 -0
- package/src/lint/post-synth/sqlch119.ts +31 -0
- package/src/lint/post-synth/sqlch120.ts +21 -0
- package/src/lint/post-synth/sqlpg101.ts +24 -0
- package/src/lint/post-synth/sqlpg102.ts +30 -0
- package/src/lint/post-synth/sqlpg103.ts +23 -0
- package/src/lint/post-synth/sqlpg104.ts +23 -0
- package/src/lint/post-synth/sqlpg105.ts +22 -0
- package/src/lint/post-synth/sqlpg106.ts +22 -0
- package/src/lint/post-synth/sqlpg107.ts +22 -0
- package/src/lint/post-synth/sqlpg108.ts +27 -0
- package/src/lint/post-synth/sqlpg109.ts +37 -0
- package/src/lint/post-synth/sqlpg110.ts +33 -0
- package/src/lint/post-synth/sqlpg111.ts +23 -0
- package/src/lint/post-synth/sqlpg112.ts +25 -0
- package/src/lint/post-synth/sqlpg113.ts +28 -0
- package/src/lint/post-synth/sqlpg114.ts +37 -0
- package/src/lint/post-synth/sqlpg115.ts +38 -0
- package/src/lint/post-synth/sqlpg116.ts +25 -0
- package/src/lint/post-synth/sqlpg117.ts +24 -0
- package/src/lint/post-synth/sqlpg118.ts +22 -0
- package/src/lint/rules/index.ts +13 -0
- package/src/lint/rules/postgres-templates.ts +36 -0
- package/src/lint/rules/rules.test.ts +228 -0
- package/src/lint/rules/sqlch001.ts +53 -0
- package/src/lint/rules/sqlch002.ts +115 -0
- package/src/lint/rules/sqlch003.ts +68 -0
- package/src/lint/rules/sqlpg001.ts +88 -0
- package/src/lint/rules/sqlpg002.ts +68 -0
- package/src/lint/rules/sqlpg003.ts +59 -0
- package/src/lint/rules/sqlpg004.ts +73 -0
- package/src/lint/rules/templates.ts +35 -0
- package/src/live-dialect.ts +37 -0
- package/src/lsp/catalog.ts +60 -0
- package/src/lsp/completions.test.ts +111 -0
- package/src/lsp/completions.ts +128 -0
- package/src/lsp/diagnostics.test.ts +26 -0
- package/src/lsp/hover.test.ts +90 -0
- package/src/lsp/hover.ts +113 -0
- package/src/lsp/postgres-catalog.ts +234 -0
- package/src/lsp/postgres-template.ts +161 -0
- package/src/lsp/postgres.test.ts +150 -0
- package/src/lsp/postgres.ts +270 -0
- package/src/lsp/refs.ts +53 -0
- package/src/lsp/registry.ts +19 -0
- package/src/lsp/template.ts +166 -0
- package/src/mcp/index.ts +304 -0
- package/src/mcp/mcp.test.ts +184 -0
- package/src/mcp/postgres.ts +125 -0
- package/src/op/activities/clickhouse-apply.e2e.test.ts +150 -0
- package/src/op/activities/clickhouse-apply.test.ts +265 -0
- package/src/op/activities/clickhouse-apply.ts +113 -0
- package/src/op/activities/clickhouse-emulator.test.ts +23 -0
- package/src/op/activities/clickhouse-emulator.ts +37 -0
- package/src/op/activities/clickhouse-rebuild.ts +136 -0
- package/src/op/activities/index.ts +50 -0
- package/src/op/activities/postgres-apply.e2e.test.ts +184 -0
- package/src/op/activities/postgres-apply.test.ts +304 -0
- package/src/op/activities/postgres-apply.ts +170 -0
- package/src/op/activities/postgres-emulator.test.ts +26 -0
- package/src/op/activities/postgres-emulator.ts +44 -0
- package/src/op/activities/postgres-migration.ts +182 -0
- package/src/op/activity-contracts.ts +210 -0
- package/src/package-cli.ts +17 -0
- package/src/plugin.test.ts +74 -0
- package/src/plugin.ts +242 -0
- package/src/postgres/apply/apply.ts +582 -0
- package/src/postgres/apply/statements.test.ts +155 -0
- package/src/postgres/apply/statements.ts +603 -0
- package/src/postgres/catalog-types.ts +59 -0
- package/src/postgres/container.ts +72 -0
- package/src/postgres/entities.test.ts +170 -0
- package/src/postgres/entities.ts +1016 -0
- package/src/postgres/entity-types.ts +18 -0
- package/src/postgres/import/generator.ts +176 -0
- package/src/postgres/import/import.test.ts +71 -0
- package/src/postgres/import/ir.ts +67 -0
- package/src/postgres/import/live-export.ts +53 -0
- package/src/postgres/import/live-warnings.test.ts +45 -0
- package/src/postgres/keywords.ts +40 -0
- package/src/postgres/live/bind.ts +146 -0
- package/src/postgres/live/catalog.ts +581 -0
- package/src/postgres/live/client.ts +84 -0
- package/src/postgres/live/describe-resources.ts +111 -0
- package/src/postgres/live/live.test.ts +198 -0
- package/src/postgres/live/roundtrip.e2e.test.ts +111 -0
- package/src/postgres/migrate/backfill.ts +233 -0
- package/src/postgres/migrate/batches.e2e.test.ts +163 -0
- package/src/postgres/migrate/batches.test.ts +36 -0
- package/src/postgres/migrate/batches.ts +159 -0
- package/src/postgres/migrate/carry.e2e.test.ts +335 -0
- package/src/postgres/migrate/carry.test.ts +103 -0
- package/src/postgres/migrate/carry.ts +653 -0
- package/src/postgres/migrate/handoff.ts +73 -0
- package/src/postgres/migrate/kinds.e2e.test.ts +204 -0
- package/src/postgres/migrate/migrate.e2e.test.ts +362 -0
- package/src/postgres/migrate/migrate.test.ts +322 -0
- package/src/postgres/migrate/names.ts +93 -0
- package/src/postgres/migrate/observe.ts +521 -0
- package/src/postgres/migrate/op.ts +242 -0
- package/src/postgres/migrate/receipts.ts +135 -0
- package/src/postgres/migrate/replication.ts +151 -0
- package/src/postgres/migrate/steps.ts +657 -0
- package/src/postgres/overlays/columns.ts +34 -0
- package/src/postgres/overlays/constraints.ts +56 -0
- package/src/postgres/overlays/indexes.ts +27 -0
- package/src/postgres/overlays/kinds.ts +53 -0
- package/src/postgres/overlays/partitioning.ts +26 -0
- package/src/postgres/overlays/relations.ts +29 -0
- package/src/postgres/overlays/storage.ts +75 -0
- package/src/postgres/overlays/type-ddl.ts +38 -0
- package/src/postgres/overlays/types.ts +56 -0
- package/src/postgres/parser.test.ts +214 -0
- package/src/postgres/parser.ts +1062 -0
- package/src/postgres/plan/commands.ts +124 -0
- package/src/postgres/plan/deep.ts +177 -0
- package/src/postgres/plan/diff.ts +323 -0
- package/src/postgres/plan/disruption.ts +52 -0
- package/src/postgres/plan/normalize.test.ts +148 -0
- package/src/postgres/plan/normalize.ts +542 -0
- package/src/postgres/plan/plan.e2e.test.ts +117 -0
- package/src/postgres/plan/plan.test.ts +244 -0
- package/src/postgres/plan/report.ts +24 -0
- package/src/postgres/plan/rules.ts +276 -0
- package/src/postgres/plan/schema.ts +114 -0
- package/src/postgres/plan/server-normalize.ts +123 -0
- package/src/postgres/providers/aurora.ts +45 -0
- package/src/postgres/providers/azure.ts +54 -0
- package/src/postgres/providers/cloud-sql.ts +42 -0
- package/src/postgres/providers/index.ts +90 -0
- package/src/postgres/providers/neon.ts +45 -0
- package/src/postgres/providers/providers.test.ts +136 -0
- package/src/postgres/providers/rds.ts +48 -0
- package/src/postgres/providers/supabase.ts +46 -0
- package/src/postgres/providers/types.ts +70 -0
- package/src/postgres/testdata/NOTICE +31 -0
- package/src/postgres/testdata/postgres-regress-corpus.json +460 -0
- package/src/postgres/testing/fake-client.ts +42 -0
- package/src/postgres/testing/migration.ts +52 -0
- package/src/postgres/testing/roundtrip-schema.ts +46 -0
- package/src/postgres/testing/server.ts +58 -0
- package/src/postgres/testing/writable-server.ts +188 -0
- package/src/postgres/tokens.ts +46 -0
- package/src/postgres.ts +75 -0
- package/src/serializer.test.ts +128 -0
- package/src/serializer.ts +148 -0
- package/src/skill-defs.test.ts +81 -0
- package/src/skill-defs.ts +102 -0
- package/src/skills/chant-sql-plan.md +123 -0
- package/src/skills/chant-sql-postgres-migration.md +126 -0
- package/src/skills/chant-sql-postgres-plan.md +194 -0
- package/src/skills/chant-sql-postgres.md +165 -0
- package/src/skills/chant-sql-rebuild.md +68 -0
- package/src/skills/chant-sql.md +123 -0
- package/src/spec/catalog.e2e.test.ts +29 -0
- package/src/spec/catalog.test.ts +56 -0
- package/src/spec/catalog.ts +311 -0
- package/src/spec/clickhouse-catalog.snapshot.json +5246 -0
- package/src/spec/fetch.test.ts +77 -0
- package/src/spec/fetch.ts +112 -0
- package/src/spec/pin.ts +47 -0
- package/src/spec/postgres-catalog-14.snapshot.json +3494 -0
- package/src/spec/postgres-catalog-15.snapshot.json +3529 -0
- package/src/spec/postgres-catalog-16.snapshot.json +3597 -0
- package/src/spec/postgres-catalog-17.snapshot.json +3656 -0
- package/src/spec/postgres-catalog-18.snapshot.json +3747 -0
- package/src/spec/postgres-catalog.test.ts +43 -0
- package/src/spec/postgres-catalog.ts +301 -0
- package/src/spec/postgres-fetch.test.ts +75 -0
- package/src/spec/postgres-fetch.ts +112 -0
- package/src/spec/postgres-pin.test.ts +64 -0
- package/src/spec/postgres-pin.ts +101 -0
- package/src/typecheck.test.ts +104 -0
- package/src/validate-cli.ts +6 -0
- package/src/validate.ts +149 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What uses the migrated column, carried over to the new one (#3322).
|
|
3
|
+
*
|
|
4
|
+
* An index, a constraint or a view on the column binds the column by its
|
|
5
|
+
* attribute number, not its name, so a swap of names at the switch would
|
|
6
|
+
* leave it on the old column, and the contract could not drop that column
|
|
7
|
+
* while something uses it. Each is made again on the new column before the
|
|
8
|
+
* switch, under a working name, and the switch swaps the names:
|
|
9
|
+
*
|
|
10
|
+
* | On the old column | Before the switch | In the switch's transaction |
|
|
11
|
+
* |---|---|---|
|
|
12
|
+
* | an index | `CREATE INDEX CONCURRENTLY` on the new column | the old one dropped (a type change) or kept as `<name>__chant_old` (a rename), the new one renamed to the name |
|
|
13
|
+
* | a primary key or unique constraint | its unique index built `CONCURRENTLY` | the old constraint dropped (or a rename's unique one kept as `__chant_old`), `ADD CONSTRAINT ... USING INDEX` |
|
|
14
|
+
* | a check or foreign key, this table's or another's that references the column | added `NOT VALID`, then `VALIDATE` | the old one dropped, the new one renamed to the name |
|
|
15
|
+
* | a view (and the views that read it) | nothing | dropped, then created again from its declaration once the columns are swapped, with its grants and owner |
|
|
16
|
+
*
|
|
17
|
+
* `CREATE INDEX CONCURRENTLY` reads the table without blocking writes, and
|
|
18
|
+
* `VALIDATE CONSTRAINT` holds SHARE UPDATE EXCLUSIVE, so both run while the
|
|
19
|
+
* application keeps writing; the dual-write trigger keeps the new column
|
|
20
|
+
* equal to the old one, so the index and the constraints hold the same rows
|
|
21
|
+
* as the old ones. A foreign key from another table is added against the
|
|
22
|
+
* new column's working unique index, which the switch then attaches to the
|
|
23
|
+
* key constraint. Everything in the switch changes only the catalog.
|
|
24
|
+
*
|
|
25
|
+
* Working objects carry chant's trailer with `migration=<key>` and
|
|
26
|
+
* `role=carry`, so the catalog read leaves them out of plans until the
|
|
27
|
+
* switch, and onFailure drops them (`./steps.ts`). The switch gives each its
|
|
28
|
+
* old comment back.
|
|
29
|
+
*
|
|
30
|
+
* Names: a type change keeps every name. A rename keeps a name the
|
|
31
|
+
* declaration does not give otherwise, except one Postgres made from the
|
|
32
|
+
* old column (`users_email_key` becomes `users_login_key`); a key, foreign
|
|
33
|
+
* key or index the build declares on the new column takes the declared name.
|
|
34
|
+
*
|
|
35
|
+
* Refused, each named with what to do: exclusion constraints and constraint
|
|
36
|
+
* triggers (no `USING INDEX` form), materialized views (made again only by
|
|
37
|
+
* a full scan in the switch), rules, triggers, policies and statistics on the
|
|
38
|
+
* column, a generated column computed from it, an INVALID index on it, a view
|
|
39
|
+
* the build does not declare, a view something other than a view depends on.
|
|
40
|
+
*/
|
|
41
|
+
import type { OwnershipMarker } from "@intentius/chant/ownership";
|
|
42
|
+
import type { PostgresClient } from "../live/client.js";
|
|
43
|
+
import { type Token } from "../tokens.js";
|
|
44
|
+
import { type DeclaredPgObject } from "../apply/statements.js";
|
|
45
|
+
import type { ColumnDef } from "../entities.js";
|
|
46
|
+
import { type MigrationNames } from "./names.js";
|
|
47
|
+
export type CarriedKind = "index" | "key" | "check" | "foreign-key";
|
|
48
|
+
/** One index or constraint on the old column, and how it is made on the new one. */
|
|
49
|
+
export interface CarriedObject {
|
|
50
|
+
kind: CarriedKind;
|
|
51
|
+
/** Its name now. */
|
|
52
|
+
name: string;
|
|
53
|
+
/** The table it is on, quoted and qualified (the referencing table for a foreign key). */
|
|
54
|
+
table: string;
|
|
55
|
+
/** The same, as `schema.table`, for messages. */
|
|
56
|
+
tableName: string;
|
|
57
|
+
tableOid: string;
|
|
58
|
+
/** The schema an index lives in (its table's). */
|
|
59
|
+
schema: string;
|
|
60
|
+
/** Its name on the new column until the switch. */
|
|
61
|
+
working: string;
|
|
62
|
+
/** Its name after the switch. */
|
|
63
|
+
target: string;
|
|
64
|
+
/**
|
|
65
|
+
* What makes the working object: for an index or a key, the `CREATE INDEX
|
|
66
|
+
* CONCURRENTLY` statement; for a check or a foreign key, the constraint's
|
|
67
|
+
* body (`CHECK (...)`, `FOREIGN KEY ... REFERENCES ...`), added `NOT VALID`.
|
|
68
|
+
*/
|
|
69
|
+
definition: string;
|
|
70
|
+
/** A key: `PRIMARY KEY` or `UNIQUE`, and its deferral. */
|
|
71
|
+
primary?: boolean;
|
|
72
|
+
deferral?: string;
|
|
73
|
+
/** A constraint: validated on the server, so validated on the new column before the switch. */
|
|
74
|
+
validated: boolean;
|
|
75
|
+
comment?: string;
|
|
76
|
+
/** A key: the comment of its index. */
|
|
77
|
+
indexComment?: string;
|
|
78
|
+
replicaIdentity?: boolean;
|
|
79
|
+
clustered?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/** A view on the old column (or on such a view), made again at the switch from its declaration. */
|
|
82
|
+
export interface CarriedView {
|
|
83
|
+
/** `schema.name`. */
|
|
84
|
+
name: string;
|
|
85
|
+
/** Quoted and qualified. */
|
|
86
|
+
ident: string;
|
|
87
|
+
materialized: false;
|
|
88
|
+
/** How many views lie between it and the table: dropped deepest first, created shallowest first. */
|
|
89
|
+
depth: number;
|
|
90
|
+
declared: DeclaredPgObject;
|
|
91
|
+
owner: string;
|
|
92
|
+
grants: Array<{
|
|
93
|
+
grantee: string;
|
|
94
|
+
privilege: string;
|
|
95
|
+
grantable: boolean;
|
|
96
|
+
}>;
|
|
97
|
+
}
|
|
98
|
+
/** The sequence that belongs to the column: its identity's, or a `serial` column's. A type change moves it to the new column at the switch. */
|
|
99
|
+
export interface ColumnSequence {
|
|
100
|
+
kind: "identity" | "serial";
|
|
101
|
+
schema: string;
|
|
102
|
+
name: string;
|
|
103
|
+
/** Quoted and qualified. */
|
|
104
|
+
ident: string;
|
|
105
|
+
}
|
|
106
|
+
export interface Dependents {
|
|
107
|
+
carried: CarriedObject[];
|
|
108
|
+
views: CarriedView[];
|
|
109
|
+
sequence?: ColumnSequence;
|
|
110
|
+
/** What the Op does not carry, each as a sentence naming the object. */
|
|
111
|
+
refused: string[];
|
|
112
|
+
}
|
|
113
|
+
/** The working name of a carried object, and the name a rename keeps the old one under. */
|
|
114
|
+
export declare const carriedWorkingName: (name: string) => string;
|
|
115
|
+
export declare const carriedOldName: (name: string) => string;
|
|
116
|
+
/**
|
|
117
|
+
* `sql` with every reference to the column `from` replaced by `to`: an
|
|
118
|
+
* identifier token naming it, not a qualifier (`x.`), a qualified name's
|
|
119
|
+
* last part, a function's name, a cast's type or an access method. Within
|
|
120
|
+
* `[start, end)` token indexes when given.
|
|
121
|
+
*/
|
|
122
|
+
export declare function replaceColumn(sql: string, from: string, to: string, range?: (tokens: readonly Token[]) => Array<[number, number]>): string;
|
|
123
|
+
/** A foreign key's body with the column replaced on the side(s) that are the migrated table. */
|
|
124
|
+
export declare function replaceInForeignKey(def: string, from: string, to: string, sides: {
|
|
125
|
+
local: boolean;
|
|
126
|
+
referenced: boolean;
|
|
127
|
+
}): string;
|
|
128
|
+
/**
|
|
129
|
+
* `CREATE [UNIQUE] INDEX <name> ON ...` as `pg_get_indexdef` prints it, as
|
|
130
|
+
* the `CONCURRENTLY` build of `working` on the new column.
|
|
131
|
+
*/
|
|
132
|
+
export declare function carriedIndexStatement(def: string, working: string, from: string, to: string): string;
|
|
133
|
+
/**
|
|
134
|
+
* The name Postgres gives an object it names after its columns
|
|
135
|
+
* (`users_email_key`, `orders_user_id_fkey`, `users_email_idx`), when `name`
|
|
136
|
+
* is that name for the old columns: the same name for the new ones. Only a
|
|
137
|
+
* name that fits untruncated; any other name is kept.
|
|
138
|
+
*/
|
|
139
|
+
export declare function renamedDefault(name: string, table: string, oldCols: readonly string[], newCols: readonly string[], suffix: string): string | undefined;
|
|
140
|
+
interface DiscoverInput {
|
|
141
|
+
client: PostgresClient;
|
|
142
|
+
names: MigrationNames;
|
|
143
|
+
oid: string;
|
|
144
|
+
attnum: number;
|
|
145
|
+
/** Every object the build declares: views are made again from theirs, and a declared name wins on a rename. */
|
|
146
|
+
objects: readonly DeclaredPgObject[];
|
|
147
|
+
/** The declared table. */
|
|
148
|
+
declared: DeclaredPgObject;
|
|
149
|
+
defaultSchema: string;
|
|
150
|
+
/** The table is partitioned: its indexes cannot be built CONCURRENTLY, nor its keys attached USING INDEX. */
|
|
151
|
+
partitioned?: boolean;
|
|
152
|
+
}
|
|
153
|
+
/** What uses the column the values come from, sorted into what the Op carries over and what it refuses. */
|
|
154
|
+
export declare function discoverDependents(input: DiscoverInput): Promise<Dependents>;
|
|
155
|
+
/** `ALTER TABLE ... ADD CONSTRAINT <working> <body> NOT VALID`: a check or foreign key on the new column. */
|
|
156
|
+
export declare const addCarriedConstraint: (c: CarriedObject) => string;
|
|
157
|
+
/**
|
|
158
|
+
* The switch's statements for the carried objects, around the swap of the
|
|
159
|
+
* columns: `before` drops the views and swaps every index and constraint;
|
|
160
|
+
* `after` creates the views again from their declarations once the column
|
|
161
|
+
* they read has its name.
|
|
162
|
+
*
|
|
163
|
+
* Foreign keys that reference the column go first: the old key constraint
|
|
164
|
+
* cannot be dropped while one depends on its index.
|
|
165
|
+
*/
|
|
166
|
+
export declare function carriedSwitchStatements(carried: readonly CarriedObject[], views: readonly CarriedView[], change: "rename" | "type", oldComment: (c: CarriedObject) => string, marker: OwnershipMarker | undefined): {
|
|
167
|
+
before: string[];
|
|
168
|
+
after: string[];
|
|
169
|
+
};
|
|
170
|
+
/** What the gate binds about the carried objects: each one's kind, names and definition, and each view. */
|
|
171
|
+
export declare function carriedSubject(d: Pick<Dependents, "carried" | "views" | "sequence">): unknown;
|
|
172
|
+
/** Whether a declared column is NOT NULL once it is switched: declared so, an identity column, or part of a carried primary key. */
|
|
173
|
+
export declare const requiresNotNull: (column: ColumnDef, carried: readonly CarriedObject[]) => boolean;
|
|
174
|
+
/** The integer type of each `serial` spelling: what the column holds, and the sequence's type. */
|
|
175
|
+
export declare const SERIAL_TYPES: Readonly<Record<string, string>>;
|
|
176
|
+
/** A declared column's type as the server holds it: a `serial` spelling is its integer type. */
|
|
177
|
+
export declare const storedType: (type: string | undefined) => string | undefined;
|
|
178
|
+
/** How far a carried object's working copy has got on the server. */
|
|
179
|
+
export interface CarriedState {
|
|
180
|
+
/** The working object is there. */
|
|
181
|
+
present: boolean;
|
|
182
|
+
/** An index: valid (its CONCURRENTLY build finished). A constraint: validated. */
|
|
183
|
+
ready: boolean;
|
|
184
|
+
/** It carries this migration's trailer; an index built and killed before its comment is adopted when its definition is the one expected. */
|
|
185
|
+
marked: boolean;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The working copies of the carried objects on the server, by working name.
|
|
189
|
+
* One under a working name that is somebody else's is refused, as for the
|
|
190
|
+
* other working objects (`./observe.ts`).
|
|
191
|
+
*/
|
|
192
|
+
export declare function carriedStates(client: PostgresClient, carried: readonly CarriedObject[], ours: (comment: string | undefined) => "ours" | "theirs" | "none", refuse: (what: string) => never): Promise<Map<string, CarriedState>>;
|
|
193
|
+
/** The carried objects whose working copy is not there, not marked, or not yet valid. */
|
|
194
|
+
export declare const carriedNotReady: (carried: readonly CarriedObject[], states: ReadonlyMap<string, CarriedState>) => CarriedObject[];
|
|
195
|
+
export {};
|
|
196
|
+
//# sourceMappingURL=carry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carry.d.ts","sourceRoot":"","sources":["../../../src/postgres/migrate/carry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,WAAW,CAAC;AAErD,OAAO,EAAyB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,KAAK,EAAE,SAAS,EAAyB,MAAM,aAAa,CAAC;AAGpE,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAEtD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,aAAa,CAAC;AAEpE,oFAAoF;AACpF,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,WAAW,CAAC;IAClB,oBAAoB;IACpB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WAAW,YAAY;IAC3B,mCAAmC;IACnC,OAAO,EAAE,OAAO,CAAC;IACjB,kFAAkF;IAClF,KAAK,EAAE,OAAO,CAAC;IACf,4IAA4I;IAC5I,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,MAAM,GAAG,QAAQ,GAAG,MAAM,EACjE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,GAC9B,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAiCpC;AAED,yFAAyF;AACzF,eAAO,MAAM,eAAe,GAAI,SAAS,SAAS,aAAa,EAAE,EAAE,QAAQ,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,KAAG,aAAa,EAIxH,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a Postgres plan hands an expand-and-contract change to the migration
|
|
3
|
+
* Op (#3281), as the ClickHouse plan hands a rebuild to its Op (#3250).
|
|
4
|
+
*
|
|
5
|
+
* `chant sql plan`, `chant sql diff`, the `classify-change` MCP tool and the
|
|
6
|
+
* applier refuse an expand-and-contract change in place. For a column
|
|
7
|
+
* rename (SQLPG205) and a type change across kinds (SQLPG208) what they hand
|
|
8
|
+
* on is a `PostgresMigrationOp` declaration per column, ready to put in an
|
|
9
|
+
* `*.op.ts` file, reviewed in the pull request like the schema change it
|
|
10
|
+
* carries out. The Op's own Plan phase classifies the change again against
|
|
11
|
+
* the server. The other expand-and-contract rules (a NOT NULL column with no
|
|
12
|
+
* default, partitioning, an object rename, a view's columns, enum labels, a
|
|
13
|
+
* domain's type, an object's kind) have no Op yet, and get none.
|
|
14
|
+
*
|
|
15
|
+
* Nothing is written for the user. The hand-off's shape is the shared
|
|
16
|
+
* core's (`../../core/handoff.ts`).
|
|
17
|
+
*/
|
|
18
|
+
import { type MigrationOpSuggestion } from "../../core/handoff.js";
|
|
19
|
+
import type { PgChange } from "../plan/diff.js";
|
|
20
|
+
import type { PgDiffObject } from "../plan/schema.js";
|
|
21
|
+
export interface PostgresMigrationOpSuggestion extends MigrationOpSuggestion {
|
|
22
|
+
/** `schema.table`, the Op's `table`. */
|
|
23
|
+
table: string;
|
|
24
|
+
/** The declared column, the Op's `column`. */
|
|
25
|
+
column: string;
|
|
26
|
+
/** The rule the Op makes the change for. */
|
|
27
|
+
rule: "SQLPG205" | "SQLPG208";
|
|
28
|
+
}
|
|
29
|
+
/** The rules a refused change is handed to the Op for. */
|
|
30
|
+
export declare const HANDED_OFF: Set<string>;
|
|
31
|
+
/** The table and column a refused change is about, when the Op makes it. */
|
|
32
|
+
export declare function migrationTarget(c: PgChange, declared: Pick<PgDiffObject, "kind" | "schema" | "name"> | undefined, defaultSchema?: string): {
|
|
33
|
+
table: string;
|
|
34
|
+
column: string;
|
|
35
|
+
} | undefined;
|
|
36
|
+
/** The Op's declaration for one column. */
|
|
37
|
+
export declare function migrationDeclaration(name: string, env: string, table: string, column: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* One suggestion per column the diff refuses for a rename or a type change
|
|
40
|
+
* across kinds. `declared` maps the diff's object keys to the declared
|
|
41
|
+
* definitions.
|
|
42
|
+
*/
|
|
43
|
+
export declare function migrationOpSuggestions(refused: readonly PgChange[], declared: ReadonlyMap<string, PgDiffObject>, env: string, defaultSchema?: string): PostgresMigrationOpSuggestion[];
|
|
44
|
+
/** The suggestions as text, for the report. */
|
|
45
|
+
export declare function renderMigrationOpSuggestions(ops: readonly PostgresMigrationOpSuggestion[]): string[];
|
|
46
|
+
//# sourceMappingURL=handoff.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handoff.d.ts","sourceRoot":"","sources":["../../../src/postgres/migrate/handoff.ts"],"names":[],"mappings":"AAAA;;;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ration of one column uses (#3281), and
|
|
3
|
+
* the trailer that marks its working objects.
|
|
4
|
+
*
|
|
5
|
+
* A migration is keyed by `<schema>.<table>.<column>`, the column as the
|
|
6
|
+
* build declares it. Its working objects are:
|
|
7
|
+
*
|
|
8
|
+
* - the new column: the declared name for a rename (`login`), or
|
|
9
|
+
* `<column>__chant_new` for a type change, until the switch;
|
|
10
|
+
* - the old column after the switch: the old name for a rename (`email`,
|
|
11
|
+
* still written by the dual-write trigger), or `<column>__chant_old` for a
|
|
12
|
+
* type change (no longer written);
|
|
13
|
+
* - the dual-write trigger `<column>__chant_sync` on the table and its
|
|
14
|
+
* function `<table>__<column>__chant_sync` in the table's schema;
|
|
15
|
+
* - the check `<new>__chant_nn` that proves NOT NULL before it is set.
|
|
16
|
+
*
|
|
17
|
+
* Each carries chant's ownership trailer (`../../core/ownership.ts`) with
|
|
18
|
+
* `migration=<key>` and its role in its comment. The catalog read
|
|
19
|
+
* (`../live/catalog.ts`) leaves out a column or a constraint whose comment
|
|
20
|
+
* carries the `migration` key, so a plan, an import and a prune see the table
|
|
21
|
+
* as it was before the migration until the switch, and as declared after it.
|
|
22
|
+
*/
|
|
23
|
+
/** The trailer key on a migration's working objects. */
|
|
24
|
+
export declare const MIGRATION_TRAILER_KEY = "migration";
|
|
25
|
+
/** A name Postgres keeps whole: `base`, or its first bytes and a short hash of all of it when it is longer than 63 bytes. */
|
|
26
|
+
export declare function pgName(base: string): string;
|
|
27
|
+
/** What the migration changes about the column. */
|
|
28
|
+
export type MigrationChange = "rename" | "type";
|
|
29
|
+
export interface MigrationNames {
|
|
30
|
+
/** `<schema>.<table>.<column>`: the migration's identity. */
|
|
31
|
+
key: string;
|
|
32
|
+
schema: string;
|
|
33
|
+
table: string;
|
|
34
|
+
/** The column as declared. */
|
|
35
|
+
column: string;
|
|
36
|
+
change: MigrationChange;
|
|
37
|
+
/** The column the values come from: the old name for a rename, the column itself for a type change. */
|
|
38
|
+
source: string;
|
|
39
|
+
/** The column being filled until the switch. */
|
|
40
|
+
newColumn: string;
|
|
41
|
+
/** The old column's name after the switch. */
|
|
42
|
+
oldColumn: string;
|
|
43
|
+
trigger: string;
|
|
44
|
+
/** The trigger function's name, unqualified. */
|
|
45
|
+
fn: string;
|
|
46
|
+
/** The check that proves the new column NOT NULL before SET NOT NULL. */
|
|
47
|
+
check: string;
|
|
48
|
+
/** Quoted, qualified: the table and the function. */
|
|
49
|
+
qualifiedTable: string;
|
|
50
|
+
qualifiedFn: string;
|
|
51
|
+
}
|
|
52
|
+
export declare function migrationNames(schema: string, table: string, column: string, change: MigrationChange, source: string): MigrationNames;
|
|
53
|
+
/** A quoted column name. */
|
|
54
|
+
export declare const col: (name: string) => string;
|
|
55
|
+
//# sourceMappingURL=names.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"names.d.ts","sourceRoot":"","sources":["../../../src/postgres/migrate/names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,wDAAwD;AACxD,eAAO,MAAM,qBAAqB,cAAc,CAAC;AAKjD,6HAA6H;AAC7H,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM3C;AAED,mDAAmD;AACnD,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,eAAe,CAAC;IACxB,uGAAuG;IACvG,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAkBrI;AAKD,4BAA4B;AAC5B,eAAO,MAAM,GAAG,GAAI,MAAM,MAAM,KAAG,MAA0B,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The expand-and-contract migration's view of the server (#3281): which
|
|
3
|
+
* column of which table is migrated, how far the migration has got, and
|
|
4
|
+
* what it will do.
|
|
5
|
+
*
|
|
6
|
+
* Every step of the Op re-observes from here rather than trusting what an
|
|
7
|
+
* earlier run or step said, so the Op converges: run it again after a crash,
|
|
8
|
+
* a gate or an approval, and each step finds its work done or still to do.
|
|
9
|
+
* The progress is read off the table itself: its columns, the dual-write
|
|
10
|
+
* trigger and its function, and the NOT NULL check, each carrying chant's
|
|
11
|
+
* trailer with `migration=<key>` and a role (`./names.ts`).
|
|
12
|
+
*
|
|
13
|
+
* The change is found the way `chant sql plan` finds it: the declared table
|
|
14
|
+
* against what the catalog read prints (`../plan/commands.ts`), which leaves
|
|
15
|
+
* the working columns out. So the plan shows the change refused until the
|
|
16
|
+
* switch, and the declaration held after it.
|
|
17
|
+
*
|
|
18
|
+
* States:
|
|
19
|
+
*
|
|
20
|
+
* - `migrate`: the declared column differs from the server's by a rename
|
|
21
|
+
* (SQLPG205) or a type change (SQLPG207, SQLPG208), and the switch has not
|
|
22
|
+
* run.
|
|
23
|
+
* - `switched`: the switch ran; the old column is kept until its date.
|
|
24
|
+
* - `done`: the server holds the declared column and nothing of the
|
|
25
|
+
* migration is left.
|
|
26
|
+
*
|
|
27
|
+
* Anything else is refused with a {@link MigrationRefusal}, naming what to
|
|
28
|
+
* do: a table that is not there, a partition (run it on the partitioned
|
|
29
|
+
* table) or an inheritance tree; no primary key to batch by; a column in the
|
|
30
|
+
* partition key; a generated column; a column change the Op does not make
|
|
31
|
+
* (a rename and a type change at once, a rename of a column with a default
|
|
32
|
+
* or a sequence); something that uses the column and is
|
|
33
|
+
* not carried over to the new one (`./carry.ts`: indexes, key, check and
|
|
34
|
+
* foreign key constraints and declared views are); a publication that sends
|
|
35
|
+
* it; a working object chant did not make.
|
|
36
|
+
*/
|
|
37
|
+
import type { OwnershipMarker } from "@intentius/chant/ownership";
|
|
38
|
+
import type { PostgresClient } from "../live/client.js";
|
|
39
|
+
import type { PostgresTarget } from "../live/bind.js";
|
|
40
|
+
import type { PgChange } from "../plan/diff.js";
|
|
41
|
+
import type { ColumnDef } from "../entities.js";
|
|
42
|
+
import type { DeclaredPgObject } from "../apply/statements.js";
|
|
43
|
+
import { MIGRATION_TRAILER_KEY, type MigrationNames } from "./names.js";
|
|
44
|
+
import { type PublicationHit } from "./replication.js";
|
|
45
|
+
import { type KeyColumn } from "./batches.js";
|
|
46
|
+
import { type CarriedObject, type CarriedState, type CarriedView, type ColumnSequence } from "./carry.js";
|
|
47
|
+
/** A refusal: the migration cannot start, or cannot go on, for a reason a person has to act on. */
|
|
48
|
+
export declare class MigrationRefusal extends Error {
|
|
49
|
+
constructor(message: string);
|
|
50
|
+
}
|
|
51
|
+
/** The rules the Op makes: a rename, and a type change with or without a rewrite in place. */
|
|
52
|
+
export declare const MIGRATION_RULES: Set<string>;
|
|
53
|
+
/** One column as the catalog holds it. */
|
|
54
|
+
export interface ServerColumn {
|
|
55
|
+
attnum: number;
|
|
56
|
+
name: string;
|
|
57
|
+
type: string;
|
|
58
|
+
notNull: boolean;
|
|
59
|
+
default?: string;
|
|
60
|
+
comment?: string;
|
|
61
|
+
generated: boolean;
|
|
62
|
+
identity: boolean;
|
|
63
|
+
/** The trailer pairs of its comment, when it is a working column. */
|
|
64
|
+
pairs?: Map<string, string>;
|
|
65
|
+
}
|
|
66
|
+
/** A working object other than a column: the trigger, its function, the check. */
|
|
67
|
+
export interface WorkingObject {
|
|
68
|
+
name: string;
|
|
69
|
+
comment?: string;
|
|
70
|
+
pairs?: Map<string, string>;
|
|
71
|
+
}
|
|
72
|
+
export interface MigrationObservation {
|
|
73
|
+
state: "migrate" | "switched" | "done";
|
|
74
|
+
names: MigrationNames;
|
|
75
|
+
declared: DeclaredPgObject;
|
|
76
|
+
/** The declared column. */
|
|
77
|
+
column: ColumnDef;
|
|
78
|
+
/** The table's oid. */
|
|
79
|
+
oid: string;
|
|
80
|
+
/** Its primary key, which the backfill batches by: `id`, or `(tenant_id, id)`. */
|
|
81
|
+
batchKey: string;
|
|
82
|
+
/** The primary key's columns, in its order (`./batches.ts`). */
|
|
83
|
+
keyColumns: KeyColumn[];
|
|
84
|
+
/** The indexes and constraints on the old column, carried over to the new one before the switch (`./carry.ts`). */
|
|
85
|
+
carried: CarriedObject[];
|
|
86
|
+
/** Their working copies on the server, by working name. */
|
|
87
|
+
carriedStates: Map<string, CarriedState>;
|
|
88
|
+
/** The views that read the old column, made again at the switch. */
|
|
89
|
+
views: CarriedView[];
|
|
90
|
+
/** The sequence that gives the old column its values (identity or serial), moved to the new column at the switch. */
|
|
91
|
+
sequence?: ColumnSequence;
|
|
92
|
+
/** The table is partitioned: every step runs on it, and its partitions follow. */
|
|
93
|
+
partitioned: boolean;
|
|
94
|
+
columns: Map<string, ServerColumn>;
|
|
95
|
+
/** The column the values come from, while there is one. */
|
|
96
|
+
source?: ServerColumn;
|
|
97
|
+
newColumn?: ServerColumn;
|
|
98
|
+
old?: ServerColumn;
|
|
99
|
+
trigger?: WorkingObject;
|
|
100
|
+
fn?: WorkingObject;
|
|
101
|
+
check?: WorkingObject & {
|
|
102
|
+
validated: boolean;
|
|
103
|
+
};
|
|
104
|
+
/** The changes the classifier reports for the column. */
|
|
105
|
+
changes: PgChange[];
|
|
106
|
+
/** The expression the new column's value is computed with, over the old row's columns. */
|
|
107
|
+
expression: string;
|
|
108
|
+
publications: PublicationHit[];
|
|
109
|
+
major: number;
|
|
110
|
+
}
|
|
111
|
+
export interface ObserveInput {
|
|
112
|
+
client: PostgresClient;
|
|
113
|
+
target: PostgresTarget;
|
|
114
|
+
declared: DeclaredPgObject;
|
|
115
|
+
column: string;
|
|
116
|
+
marker?: OwnershipMarker;
|
|
117
|
+
/** Every object the build declares; the views the switch makes again come from here. Default: the table alone. */
|
|
118
|
+
objects?: readonly DeclaredPgObject[];
|
|
119
|
+
/** The type change's expression, over the old row's columns. Default: `CAST(<column> AS <declared type>)`. */
|
|
120
|
+
using?: string;
|
|
121
|
+
/** The major the build targets; the server's own wins. */
|
|
122
|
+
major?: number;
|
|
123
|
+
}
|
|
124
|
+
/** The declared table with the given key (`schema.table`) or export name, or a refusal naming what is declared. */
|
|
125
|
+
export declare function declaredTable(declared: readonly DeclaredPgObject[], key: string): DeclaredPgObject;
|
|
126
|
+
/** The server's major, from `server_version_num`. */
|
|
127
|
+
export declare function serverMajor(client: PostgresClient): Promise<number>;
|
|
128
|
+
/** Observe the migration of the declared table's column on the server. */
|
|
129
|
+
export declare function observeMigration(input: ObserveInput): Promise<MigrationObservation>;
|
|
130
|
+
/**
|
|
131
|
+
* What the migration will do, independent of how far it has got: the
|
|
132
|
+
* change, the column on both sides, the expression, the batch key. The
|
|
133
|
+
* Plan phase publishes its digest; the gate binds a digest of this and the
|
|
134
|
+
* verification.
|
|
135
|
+
*/
|
|
136
|
+
export declare function migrationPlanSubject(o: MigrationObservation): Record<string, unknown>;
|
|
137
|
+
export declare const migrationPlanDigest: (o: MigrationObservation) => string;
|
|
138
|
+
export { MIGRATION_TRAILER_KEY };
|
|
139
|
+
//# sourceMappingURL=observe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../../src/postgres/migrate/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;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;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,cAAc,CAAC;IACvB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,kHAAkH;IAClH,OAAO,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;IACtC,8GAA8G;IAC9G,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0DAA0D;IAC1D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,mHAAmH;AACnH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAOlG;AAsCD,qDAAqD;AACrD,wBAAsB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,CAGzE;AAmED,0EAA0E;AAC1E,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAwKzF;AA2ED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAWrF;AAED,eAAO,MAAM,mBAAmB,GAAI,GAAG,oBAAoB,KAAG,MAA0E,CAAC;AAEzI,OAAO,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `PostgresMigrationOp` (#3281): the column change Postgres cannot make in
|
|
3
|
+
* place without breaking readers (a rename, SQLPG205; a type change across
|
|
4
|
+
* kinds, SQLPG208), run as expand and contract in a gated composite Op. A
|
|
5
|
+
* type change within a kind that rewrites the table under ACCESS EXCLUSIVE
|
|
6
|
+
* (SQLPG207) can run as the same Op, which fills the new column in batches
|
|
7
|
+
* instead.
|
|
8
|
+
*
|
|
9
|
+
* export const { op } = PostgresMigrationOp({
|
|
10
|
+
* name: "migrate-app-users-login",
|
|
11
|
+
* env: "prod",
|
|
12
|
+
* table: "app.users",
|
|
13
|
+
* column: "login",
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* | Phase | Step |
|
|
17
|
+
* |---|---|
|
|
18
|
+
* | Build | `chant build` (`build: false` skips it) |
|
|
19
|
+
* | Plan | classify the column's change against the server; refuse what the Op does not make |
|
|
20
|
+
* | Expand | add the new column, nullable, no default (a catalog change) |
|
|
21
|
+
* | Dual write | a trigger that keeps the new column written: computed from the old one for a type change, both ways for a rename |
|
|
22
|
+
* | Backfill | `UPDATE` per key range, each batch with its receipt in its own transaction, under `lock_timeout`, pausing while a replica is behind |
|
|
23
|
+
* | Carry over | each index on the old column built again on the new one `CONCURRENTLY`, each check and foreign key (another table's too) added `NOT VALID` and validated (`./carry.ts`) |
|
|
24
|
+
* | Verify | rows, mismatches and checksums of the new column against the old |
|
|
25
|
+
* | Approve | a gate bound to the plan and the verified new column |
|
|
26
|
+
* | Switch | NOT NULL proven by a validated check; then one short transaction: a type change swaps the columns by name, a rename finishes the new column; the carried indexes and constraints take their names (keys `USING INDEX`), and the views that read the column are made again from their declarations |
|
|
27
|
+
* | Retain | the old column, until `retain` has passed |
|
|
28
|
+
* | Approve contract | a gate bound to that old column |
|
|
29
|
+
* | Contract | drop the old column (and a rename's trigger) once its date has passed |
|
|
30
|
+
* | onFailure | drop what the expand added: the trigger, its function, the check, the new column, the receipts |
|
|
31
|
+
*
|
|
32
|
+
* Run it until it is done: each run goes as far as the next gate. Every step
|
|
33
|
+
* re-reads the server, so a run after a gate, a crash or an approval picks up
|
|
34
|
+
* where the last stopped. A run killed during the backfill (Ctrl-C, a lost
|
|
35
|
+
* machine) is not a failure, runs no onFailure, and the next run resumes the
|
|
36
|
+
* backfill from its receipts; a step that fails runs onFailure, and the next
|
|
37
|
+
* run starts again from a new column.
|
|
38
|
+
*/
|
|
39
|
+
import { type GateApproval } from "@intentius/chant/op";
|
|
40
|
+
import type { OpResource } from "@intentius/chant/op";
|
|
41
|
+
export interface PostgresMigrationOpConfig {
|
|
42
|
+
/** Op name (kebab-case). */
|
|
43
|
+
name: string;
|
|
44
|
+
/** The chant environment: selects `sql.profiles.<env>`. */
|
|
45
|
+
env: string;
|
|
46
|
+
/** The table, `schema.name` as the server knows it (or its export name). */
|
|
47
|
+
table: string;
|
|
48
|
+
/** The column as the build declares it: the new name for a rename. */
|
|
49
|
+
column: string;
|
|
50
|
+
/**
|
|
51
|
+
* A type change: the SQL expression that computes the new value from the
|
|
52
|
+
* old row's columns, as `ALTER COLUMN ... TYPE ... USING` takes it. Default:
|
|
53
|
+
* `CAST(<column> AS <declared type>)`. The backfill, the dual-write trigger
|
|
54
|
+
* and the verification all use it.
|
|
55
|
+
*/
|
|
56
|
+
using?: string;
|
|
57
|
+
/** The build output the declaration is read from. Default: `dist/schema.json`. */
|
|
58
|
+
output?: string;
|
|
59
|
+
/** Project directory to build. Default: `.`. */
|
|
60
|
+
path?: string;
|
|
61
|
+
/** Run `chant build` first (the project's `build` script). Default: true. */
|
|
62
|
+
build?: boolean;
|
|
63
|
+
/** How long the old column is kept after the switch, as a duration (`7d`, `36h`). Default: `7d`. */
|
|
64
|
+
retain?: string;
|
|
65
|
+
/**
|
|
66
|
+
* Rows per batch: the width of a batch's range of a primary key of one
|
|
67
|
+
* integer column, or how many keys lie between two recorded boundaries of
|
|
68
|
+
* any other key (uuid, text, several columns). Default: 1000.
|
|
69
|
+
*/
|
|
70
|
+
batchSize?: number;
|
|
71
|
+
/**
|
|
72
|
+
* Pause the backfill while a replica's replay lag is above `max`, for up to
|
|
73
|
+
* `wait` at a time. Default: `{ max: "10s", wait: "30m" }`. `false` turns
|
|
74
|
+
* the check off.
|
|
75
|
+
*/
|
|
76
|
+
replicationLag?: {
|
|
77
|
+
max?: string;
|
|
78
|
+
wait?: string;
|
|
79
|
+
} | false;
|
|
80
|
+
/** `lock_timeout` for every statement, in ms. Default: the profile's `lockTimeoutMs`, else 5000. */
|
|
81
|
+
lockTimeoutMs?: number;
|
|
82
|
+
/** `statement_timeout` for every statement but the scans (validation, verification), in ms. Default: the profile's `statementTimeoutMs`, else 60000. */
|
|
83
|
+
statementTimeoutMs?: number;
|
|
84
|
+
/** The gate before the switch. Default name `approve-<name>`. */
|
|
85
|
+
gate?: {
|
|
86
|
+
gate?: string;
|
|
87
|
+
timeout?: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
/** Quorum, roles and a policy (#2508). With a policy, the verification's counts are added to its context. */
|
|
90
|
+
approval?: GateApproval;
|
|
91
|
+
};
|
|
92
|
+
/** The gate before the old column is dropped. Default name `approve-<name>-contract`. */
|
|
93
|
+
contractGate?: {
|
|
94
|
+
gate?: string;
|
|
95
|
+
timeout?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
};
|
|
98
|
+
/** One attempt of the backfill step. Default: `6h`, the longest a step may run. */
|
|
99
|
+
backfillTimeout?: string;
|
|
100
|
+
/** Ownership stack. Default: `ownership.stack` in `chant.config.ts`. */
|
|
101
|
+
stack?: string;
|
|
102
|
+
/** Ownership env. Default: `ownership.env` in `chant.config.ts`. */
|
|
103
|
+
ownershipEnv?: string;
|
|
104
|
+
}
|
|
105
|
+
export interface PostgresMigrationOpResources {
|
|
106
|
+
op: InstanceType<typeof OpResource>;
|
|
107
|
+
}
|
|
108
|
+
/** The arguments every migration activity takes. */
|
|
109
|
+
export interface PostgresMigrationArgs {
|
|
110
|
+
table: string;
|
|
111
|
+
column: string;
|
|
112
|
+
buildPath: string;
|
|
113
|
+
environment?: string;
|
|
114
|
+
using?: string;
|
|
115
|
+
retain?: string;
|
|
116
|
+
batchSize?: number;
|
|
117
|
+
replicationLag?: {
|
|
118
|
+
max?: string;
|
|
119
|
+
wait?: string;
|
|
120
|
+
} | false;
|
|
121
|
+
lockTimeoutMs?: number;
|
|
122
|
+
statementTimeoutMs?: number;
|
|
123
|
+
stack?: string;
|
|
124
|
+
ownershipEnv?: string;
|
|
125
|
+
cwd?: string;
|
|
126
|
+
}
|
|
127
|
+
export declare function PostgresMigrationOp(config: PostgresMigrationOpConfig): PostgresMigrationOpResources;
|
|
128
|
+
//# sourceMappingURL=op.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op.d.ts","sourceRoot":"","sources":["../../../src/postgres/migrate/op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAyC,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAItD,MAAM,WAAW,yBAAyB;IACxC,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oGAAoG;IACpG,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,cAAc,CAAC,EAAE;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,KAAK,CAAC;IACzD,oGAAoG;IACpG,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wJAAwJ;IACxJ,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,iEAAiE;IACjE,IAAI,CAAC,EAAE;QACL,IAAI,CAAC,EAAE,MAAM,C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