@prisma-next/target-sqlite 0.16.0-dev.3 → 0.16.0-dev.30

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.
Files changed (68) hide show
  1. package/dist/codecs-DGgo--O0.d.mts.map +1 -1
  2. package/dist/codecs.mjs +25 -6
  3. package/dist/codecs.mjs.map +1 -1
  4. package/dist/control.d.mts.map +1 -1
  5. package/dist/control.mjs +10 -5
  6. package/dist/control.mjs.map +1 -1
  7. package/dist/errors-B1JPoWDh.mjs +38 -0
  8. package/dist/errors-B1JPoWDh.mjs.map +1 -0
  9. package/dist/migration.d.mts +1 -1
  10. package/dist/migration.mjs +2 -2
  11. package/dist/{op-factory-call-8pTnIHhR.mjs → op-factory-call-BkqsWGiy.mjs} +39 -13
  12. package/dist/op-factory-call-BkqsWGiy.mjs.map +1 -0
  13. package/dist/op-factory-call.d.mts.map +1 -1
  14. package/dist/op-factory-call.mjs +1 -1
  15. package/dist/{planner-D4B8Rugz.mjs → planner-Cdl1Lziz.mjs} +19 -15
  16. package/dist/planner-Cdl1Lziz.mjs.map +1 -0
  17. package/dist/{planner-produced-sqlite-migration-hyDa7QK-.mjs → planner-produced-sqlite-migration-BGcreGfL.mjs} +22 -12
  18. package/dist/planner-produced-sqlite-migration-BGcreGfL.mjs.map +1 -0
  19. package/dist/{planner-produced-sqlite-migration-C9k0q8Il.d.mts → planner-produced-sqlite-migration-fd_Jw-mL.d.mts} +3 -3
  20. package/dist/planner-produced-sqlite-migration-fd_Jw-mL.d.mts.map +1 -0
  21. package/dist/planner-produced-sqlite-migration.d.mts +1 -1
  22. package/dist/planner-produced-sqlite-migration.mjs +1 -1
  23. package/dist/planner.d.mts +7 -1
  24. package/dist/planner.d.mts.map +1 -1
  25. package/dist/planner.mjs +1 -1
  26. package/dist/{render-ops-BDW2tUeR.mjs → render-ops-BAw6MQWl.mjs} +7 -2
  27. package/dist/render-ops-BAw6MQWl.mjs.map +1 -0
  28. package/dist/render-ops.d.mts.map +1 -1
  29. package/dist/render-ops.mjs +1 -1
  30. package/dist/runtime.mjs +1 -1
  31. package/dist/{sql-utils-CV8Bdgtc.mjs → sql-utils-BMteAbKH.mjs} +15 -15
  32. package/dist/sql-utils-BMteAbKH.mjs.map +1 -0
  33. package/dist/sql-utils.d.mts +1 -6
  34. package/dist/sql-utils.d.mts.map +1 -1
  35. package/dist/sql-utils.mjs +2 -2
  36. package/dist/{sqlite-contract-view-B8qeCczc.mjs → sqlite-contract-view-DthhfCpb.mjs} +3 -2
  37. package/dist/sqlite-contract-view-DthhfCpb.mjs.map +1 -0
  38. package/dist/{sqlite-migration-BbSrmBAa.d.mts → sqlite-migration-CBXynqeE.d.mts} +4 -3
  39. package/dist/sqlite-migration-CBXynqeE.d.mts.map +1 -0
  40. package/dist/{sqlite-migration-BcFf2OFa.mjs → sqlite-migration-DrZIdg3i.mjs} +7 -36
  41. package/dist/sqlite-migration-DrZIdg3i.mjs.map +1 -0
  42. package/package.json +18 -18
  43. package/src/core/codecs.ts +33 -6
  44. package/src/core/control-target.ts +3 -1
  45. package/src/core/errors.ts +24 -0
  46. package/src/core/migrations/column-ddl-rendering.ts +4 -2
  47. package/src/core/migrations/issue-planner.ts +5 -6
  48. package/src/core/migrations/op-factory-call.ts +41 -8
  49. package/src/core/migrations/planner-ddl-builders.ts +10 -3
  50. package/src/core/migrations/planner-produced-sqlite-migration.ts +4 -0
  51. package/src/core/migrations/planner-strategies.ts +2 -3
  52. package/src/core/migrations/planner.ts +8 -0
  53. package/src/core/migrations/render-ops.ts +4 -1
  54. package/src/core/migrations/render-typescript.ts +20 -8
  55. package/src/core/migrations/runner.ts +6 -2
  56. package/src/core/migrations/sqlite-migration.ts +3 -2
  57. package/src/core/sql-utils.ts +10 -21
  58. package/src/core/sqlite-unbound-database.ts +4 -1
  59. package/src/exports/sql-utils.ts +1 -1
  60. package/dist/op-factory-call-8pTnIHhR.mjs.map +0 -1
  61. package/dist/planner-D4B8Rugz.mjs.map +0 -1
  62. package/dist/planner-produced-sqlite-migration-C9k0q8Il.d.mts.map +0 -1
  63. package/dist/planner-produced-sqlite-migration-hyDa7QK-.mjs.map +0 -1
  64. package/dist/render-ops-BDW2tUeR.mjs.map +0 -1
  65. package/dist/sql-utils-CV8Bdgtc.mjs.map +0 -1
  66. package/dist/sqlite-contract-view-B8qeCczc.mjs.map +0 -1
  67. package/dist/sqlite-migration-BbSrmBAa.d.mts.map +0 -1
  68. package/dist/sqlite-migration-BcFf2OFa.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"sql-utils-CV8Bdgtc.mjs","names":[],"sources":["../src/core/sql-utils.ts"],"sourcesContent":["/**\n * Shared SQL utility functions for the SQLite target.\n *\n * These functions handle safe SQL identifier and literal escaping. They\n * live in `target-sqlite` (mirroring `target-postgres/src/core/sql-utils.ts`)\n * so both the control adapter (used at emit time) and the runtime adapter\n * (used at execute time) can depend on them through a single one-way edge:\n * `adapter-sqlite → target-sqlite`. Hosting them target-side avoids the\n * cyclic workspace dependency that would arise if `target-sqlite` reached\n * back into `adapter-sqlite` for these primitives.\n */\n\nexport class SqlEscapeError extends Error {\n constructor(\n message: string,\n public readonly value: string,\n public readonly kind: 'identifier' | 'literal',\n ) {\n super(message);\n this.name = 'SqlEscapeError';\n }\n}\n\nexport function quoteIdentifier(identifier: string): string {\n if (identifier.length === 0) {\n throw new SqlEscapeError('Identifier cannot be empty', identifier, 'identifier');\n }\n if (identifier.includes('\\0')) {\n throw new SqlEscapeError(\n 'Identifier cannot contain null bytes',\n identifier.replace(/\\0/g, '\\\\0'),\n 'identifier',\n );\n }\n return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n\nexport function escapeLiteral(value: string): string {\n if (value.includes('\\0')) {\n throw new SqlEscapeError(\n 'Literal value cannot contain null bytes',\n value.replace(/\\0/g, '\\\\0'),\n 'literal',\n );\n }\n return value.replace(/'/g, \"''\");\n}\n"],"mappings":";;;;;;;;;;;;AAYA,IAAa,iBAAb,cAAoC,MAAM;CAGtB;CACA;CAHlB,YACE,SACA,OACA,MACA;EACA,MAAM,OAAO;EAHG,KAAA,QAAA;EACA,KAAA,OAAA;EAGhB,KAAK,OAAO;CACd;AACF;AAEA,SAAgB,gBAAgB,YAA4B;CAC1D,IAAI,WAAW,WAAW,GACxB,MAAM,IAAI,eAAe,8BAA8B,YAAY,YAAY;CAEjF,IAAI,WAAW,SAAS,IAAI,GAC1B,MAAM,IAAI,eACR,wCACA,WAAW,QAAQ,OAAO,KAAK,GAC/B,YACF;CAEF,OAAO,IAAI,WAAW,QAAQ,MAAM,MAAI,EAAE;AAC5C;AAEA,SAAgB,cAAc,OAAuB;CACnD,IAAI,MAAM,SAAS,IAAI,GACrB,MAAM,IAAI,eACR,2CACA,MAAM,QAAQ,OAAO,KAAK,GAC1B,SACF;CAEF,OAAO,MAAM,QAAQ,MAAM,IAAI;AACjC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sqlite-contract-view-B8qeCczc.mjs","names":[],"sources":["../src/core/sqlite-unbound-database.ts","../src/core/sqlite-contract-serializer.ts","../src/core/sqlite-contract-view.ts"],"sourcesContent":["import {\n freezeNode,\n hydrateNamespaceEntities,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport { tableEntityKind } from '@prisma-next/sql-contract/entity-kinds';\nimport {\n SqlNamespaceBase,\n type SqlNamespaceEntries,\n type SqlNamespaceInput,\n type StorageTable,\n} from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\n\nexport type SqliteDatabaseInput = {\n readonly id: string;\n readonly entries: SqlNamespaceEntries;\n};\n\nconst SQLITE_NAMESPACE_KIND = 'sqlite-namespace' as const;\n\n/**\n * SQLite namespace concretion carrying table metadata under\n * `entries.table` and unqualified `qualifyTable()` emission for runtime\n * SQL rendering.\n */\nexport class SqliteDatabase extends SqlNamespaceBase {\n declare readonly kind: string;\n\n readonly id: string;\n readonly entries: SqlNamespaceEntries;\n\n constructor(input: SqliteDatabaseInput) {\n super();\n this.id = input.id;\n\n const dispatched = hydrateNamespaceEntities(\n input.entries,\n new Map([['table', tableEntityKind]]),\n 'carry',\n );\n\n this.entries = Object.freeze(\n blindCast<\n SqlNamespaceEntries,\n \"SQLite's table-only descriptor map hydrates table→StorageTable and carries every other kind raw, so this open-dict result satisfies SqlNamespaceEntries; the descriptor Map erases the per-kind Node type from the return.\"\n >(dispatched),\n );\n Object.defineProperty(this, 'kind', {\n value: SQLITE_NAMESPACE_KIND,\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n get table(): Readonly<Record<string, StorageTable>> {\n return this.entries.table ?? Object.freeze({});\n }\n\n qualifier(): string {\n return '';\n }\n\n qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n}\n\n/**\n * SQLite target `Namespace` concretion. SQLite has no schema or\n * database-namespacing concept at the SQL level — there is exactly one\n * effective namespace per connection, so the target ships a single\n * singleton bound to the framework's `UNBOUND_NAMESPACE_ID` slot.\n *\n * Qualifier emission elides the prefix entirely: rendered DDL and\n * queries look unqualified (`CREATE TABLE \"users\" (...)`), matching\n * SQLite's native dialect. Call sites stay polymorphic — they ask the\n * namespace for its qualifier and consume the empty/unqualified result\n * the same way Postgres consumes a `\"schema\"` prefix.\n *\n * The SQLite PSL interpreter rejects every explicit `namespace { … }`\n * block with a diagnostic naming SQLite; only the implicit\n * `__unspecified__` AST bucket reaches the SQLite interpreter, which\n * lowers it to this singleton.\n */\nexport class SqliteUnboundDatabase extends SqliteDatabase {\n static readonly instance: SqliteUnboundDatabase = new SqliteUnboundDatabase();\n\n private constructor() {\n super({ id: UNBOUND_NAMESPACE_ID, entries: { table: {} } });\n }\n}\n\nexport function buildSqliteNamespace(\n input: SqlNamespaceInput,\n): SqliteDatabase | SqliteUnboundDatabase {\n if (input.id !== UNBOUND_NAMESPACE_ID) {\n throw new Error(\n `buildSqliteNamespace: SQLite has no schema concept; the only valid namespace id is \"${UNBOUND_NAMESPACE_ID}\" (received \"${input.id}\").`,\n );\n }\n const tableKind = input.entries['table'];\n const tableCount = tableKind !== undefined ? Object.keys(tableKind).length : 0;\n const hasUnknownKinds = Object.keys(input.entries).some((kind) => kind !== 'table');\n if (tableCount === 0 && !hasUnknownKinds) {\n return SqliteUnboundDatabase.instance;\n }\n return new SqliteDatabase({ id: input.id, entries: input.entries });\n}\n\n/**\n * Target-supplied `Namespace` factory the SQLite target plumbs through\n * `defineContract({ createNamespace })`. SQLite has only one\n * effective namespace slot — the framework `UNBOUND_NAMESPACE_ID`\n * sentinel — so the factory always returns the singleton or a fresh\n * `SqliteDatabase` for the unbound slot with tables. The SQL family's\n * defensive validation in `defineContract` already rejects\n * user-declared SQLite namespaces, so this throw is a structural\n * safety net rather than a user-facing surface.\n */\nexport function sqliteCreateNamespace(\n input: SqlNamespaceInput,\n): SqliteDatabase | SqliteUnboundDatabase {\n return buildSqliteNamespace(input);\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport { SqlContractSerializerBase } from '@prisma-next/family-sql/ir';\nimport type { Namespace } from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport { buildSqliteNamespace } from './sqlite-unbound-database';\n\n/**\n * SQLite target `ContractSerializer` concretion. Mirrors the Postgres\n * shape: inherits the full SQL-family deserialization pipeline and\n * materialises namespace entries as SQLite database concretions that\n * expose `qualifyTable()` for runtime SQL rendering.\n */\nexport class SqliteContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n super(new Map());\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Record<string, unknown>,\n ): Namespace | SqlNamespaceInput {\n const hydrated = blindCast<\n SqlNamespaceInput,\n 'raw is always plain JSON, so super.hydrateSqlNamespaceEntry returns SqlNamespaceInput'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n return buildSqliteNamespace(hydrated);\n }\n\n override serializeContract(contract: Contract<SqlStorage>): JsonObject {\n const { storage, ...rest } = contract;\n const namespacesJson: Record<string, JsonObject> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n namespacesJson[nsId] = {\n id: ns.id,\n entries: this.serializeNamespaceEntries(ns.entries),\n };\n }\n return blindCast<\n JsonObject,\n 'rest + storage are serialized plain values; spread preserves JSON-clean contract envelope'\n >({\n ...rest,\n storage: {\n storageHash: String(storage.storageHash),\n namespaces: namespacesJson,\n ...(storage.types !== undefined ? { types: this.serializeJsonObject(storage.types) } : {}),\n },\n });\n }\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport {\n buildSqlSingleNamespaceView,\n type SqlSingleNamespaceView,\n} from '@prisma-next/sql-contract/contract-view';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { SqliteContractSerializer } from './sqlite-contract-serializer';\n\n/**\n * A SQLite contract view: the deserialized contract intersected with by-name\n * accessors. It is substitutable for `Contract` (carries `storage`, `domain`,\n * …) and also exposes the single default namespace unwrapped with the SQL\n * built-in kinds promoted:\n *\n * ```ts\n * const view = SqliteContractView.fromJson<Contract>(contractJson);\n * view.table.users // typed table leaf\n * view.entries.policy.X // pack-contributed kind (singular key)\n * view.storage // the full contract is still present\n * ```\n *\n * SQLite has `sql.enums: false`, so it never emits `valueSet` entries; the\n * `valueSet` slot is therefore an empty map.\n */\nexport type SqliteContractView<TContract extends Contract<SqlStorage> = Contract<SqlStorage>> =\n SqlSingleNamespaceView<TContract>;\n\nexport const SqliteContractView = {\n /** Wrap an already-deserialized SQLite contract in a view. */\n from<TContract extends Contract<SqlStorage>>(contract: TContract): SqliteContractView<TContract> {\n return buildSqlSingleNamespaceView(contract);\n },\n\n /** Deserialize a SQLite contract JSON envelope and wrap it in a view. */\n fromJson<TContract extends Contract<SqlStorage> = Contract<SqlStorage>>(\n json: unknown,\n ): SqliteContractView<TContract> {\n const contract = new SqliteContractSerializer().deserializeContract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MAQlC,iBAAiB,mBAAmB;YAI9B,YAAY;aACX;aACA;aACA,kBAAkB;aAClB,uBAAuB;MAC9B,QAAQ;YAMF,UAAU;aAAoB;MAAkB,QAAQ;YAIxD,UAAU;aACT;aACA,QAAQ;MACf,QAAQ;YAMF,WAAW;aAAoB;aAAwB;MAAmB,QAAQ;YAMlF,YAAY;aACX;aACA;aACA;MACP,QAAQ;YAMF,UAAU;aAAoB;aAAwB;MAAkB,QAAQ;YAMhF,cAAc;aACb;aACA,eAAe;aACf;aACA,kBAAkB;aAClB;aACA;eAAgC;eAA8B;;aAC9D,gBAAgB;MACvB,QAAQ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"sqlite-migration-BcFf2OFa.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/errors.ts","../src/core/migrations/sqlite-migration.ts"],"sourcesContent":["import { CliStructuredError } from '@prisma-next/errors/control';\n\n/**\n * A `SqliteMigration` operation that needs the materialized control adapter\n * — named by `operation` (e.g. `createTable`, `dropColumn`, `recreateTable`) —\n * was invoked, but the migration was constructed without a `ControlStack`.\n * Concrete authoring usage always goes through the migration CLI entrypoint,\n * which assembles a stack from the loaded `prisma-next.config.ts`; reaching this\n * error means a test fixture or ad-hoc consumer instantiated `SqliteMigration`\n * with the no-arg form (legal for `operations` / `describe` introspection only).\n *\n * The `operation` argument is required so every throw site names the operation\n * that actually failed; a new operation cannot inherit a misattributed message.\n *\n * Distinct from `MIGRATION.UNFILLED_PLACEHOLDER` (placeholder not filled)\n * because the missing input is the stack itself, not the per-operation\n * contract.\n *\n * Lives in `@prisma-next/target-sqlite/errors` rather than the shared\n * framework migration errors module because the failure is target-specific:\n * the contract it talks about (`SqliteMigration`, the SQLite control\n * adapter, the SQLite-target stack) only exists in this package.\n */\nexport function errorSqliteMigrationStackMissing(operation: string): CliStructuredError {\n return new CliStructuredError(\n 'MIGRATION.SQLITE_CONTROL_STACK_MISSING',\n `SqliteMigration.${operation} requires a control adapter`,\n {\n why: `SqliteMigration.${operation} was invoked on an instance constructed without a ControlStack, so the stored controlAdapter is undefined and the operation cannot lower its DDL node.`,\n fix: 'Construct the migration via the migration CLI entrypoint (which assembles a ControlStack from the loaded prisma-next.config.ts), or pass a ControlStack containing a SQLite adapter to the migration constructor in test fixtures.',\n meta: { operation },\n },\n );\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationClass,\n SqlMigrationPlanOperation,\n} from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { errorSqliteMigrationStackMissing } from '../errors';\nimport { SqliteContractView } from '../sqlite-contract-view';\nimport {\n AddColumnCall,\n CreateIndexCall,\n CreateTableCall,\n DropColumnCall,\n DropIndexCall,\n DropTableCall,\n RecreateTableCall,\n} from './op-factory-call';\nimport type { SqliteColumnSpec, SqliteIndexSpec, SqliteTableSpec } from './operations/shared';\nimport type { SqlitePlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;\n\n/**\n * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`\n * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the\n * SQLite literal, so both user-authored migrations and renderer-generated\n * scaffolds can extend `SqliteMigration` directly without redeclaring\n * target-local identity.\n *\n * The constructor materializes a single SQLite `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected instance methods\n * forward to the corresponding `*Call` with that stored adapter, so user\n * migrations can write `this.createTable({...})` without threading the adapter\n * through every call.\n *\n * Binds the framework base's `Start` / `End` contract generics so a subclass\n * that assigns its `start-contract.json` / `end-contract.json` imports gets\n * fully-typed view accessors: `this.endContract` is a `SqliteContractView<End>`\n * (sole namespace unwrapped to the root — `this.endContract.table.<name>`),\n * built lazily from the JSON fields via the shared `MigrationContractViews`\n * helper. Mirrors `MongoMigration`'s view getters; the framework base derives\n * `describe()` from the same JSON.\n */\nexport abstract class SqliteMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<SqlitePlanTargetDetails, 'sqlite', Start, End> {\n readonly targetId = 'sqlite' as const;\n\n /**\n * Materialized SQLite control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `controlAdapterFor`\n * throws a MIGRATION.SQLITE_CONTROL_STACK_MISSING in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'sqlite'> | undefined;\n\n #endView = new MigrationContractViews<SqliteContractView<End>>(this, 'SqliteMigration', (json) =>\n SqliteContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<SqliteContractView<Start>>(\n this,\n 'SqliteMigration',\n (json) => SqliteContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'sqlite'>) {\n super(stack);\n this.controlAdapter = stack?.adapter\n ? blindCast<\n SqlControlAdapter<'sqlite'>,\n 'The SQLite descriptor create() returns SqlControlAdapter<sqlite>; typed as wider ControlAdapterInstance at the framework boundary'\n >(stack.adapter.create(stack))\n : undefined;\n }\n\n /**\n * Returns the materialized control adapter, or throws a MIGRATION.SQLITE_CONTROL_STACK_MISSING naming\n * `operation` when the migration was constructed without a `ControlStack`.\n * Single home for the null-check that every DDL/DML method shares.\n */\n private controlAdapterFor(operation: string): SqlControlAdapter<'sqlite'> {\n if (!this.controlAdapter) {\n throw errorSqliteMigrationStackMissing(operation);\n }\n return this.controlAdapter;\n }\n\n /**\n * The typed SQLite view over this migration's end-state contract — sole\n * namespace unwrapped to the root, so `this.endContract.table.<name>` etc.\n * Throws if no `endContractJson` was provided.\n */\n get endContract(): SqliteContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed SQLite view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): SqliteContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n protected createTable(options: {\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<Op> {\n return new CreateTableCall(options.table, options.columns, options.constraints).toOp(\n this.controlAdapterFor('createTable'),\n );\n }\n\n protected dropTable(options: { readonly table: string }): Promise<Op> {\n return new DropTableCall(options.table).toOp(this.controlAdapterFor('dropTable'));\n }\n\n protected addColumn(options: {\n readonly table: string;\n readonly column: SqliteColumnSpec;\n }): Promise<Op> {\n return new AddColumnCall(options.table, options.column).toOp(\n this.controlAdapterFor('addColumn'),\n );\n }\n\n protected dropColumn(options: { readonly table: string; readonly column: string }): Promise<Op> {\n return new DropColumnCall(options.table, options.column).toOp(\n this.controlAdapterFor('dropColumn'),\n );\n }\n\n protected createIndex(options: {\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n }): Promise<Op> {\n return new CreateIndexCall(options.table, options.index, options.columns).toOp(\n this.controlAdapterFor('createIndex'),\n );\n }\n\n protected dropIndex(options: { readonly table: string; readonly index: string }): Promise<Op> {\n return new DropIndexCall(options.table, options.index).toOp(\n this.controlAdapterFor('dropIndex'),\n );\n }\n\n protected recreateTable(options: {\n readonly tableName: string;\n readonly contractTable: SqliteTableSpec;\n readonly schemaColumnNames: readonly string[];\n readonly indexes: readonly SqliteIndexSpec[];\n readonly summary: string;\n readonly postchecks: readonly { readonly description: string; readonly sql: string }[];\n readonly operationClass: MigrationOperationClass;\n }): Promise<Op> {\n return new RecreateTableCall(options).toOp(this.controlAdapterFor('recreateTable'));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,iCAAiC,WAAuC;CACtF,OAA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