@prisma-next/target-sqlite 0.13.0-dev.34 → 0.13.0-dev.36

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 (51) hide show
  1. package/dist/contract-free.d.mts +35 -2
  2. package/dist/contract-free.d.mts.map +1 -1
  3. package/dist/contract-free.mjs +3 -3
  4. package/dist/control.d.mts.map +1 -1
  5. package/dist/control.mjs +3 -3
  6. package/dist/ddl-DrtjQMFK.mjs +68 -0
  7. package/dist/ddl-DrtjQMFK.mjs.map +1 -0
  8. package/dist/migration.d.mts +3 -45
  9. package/dist/migration.d.mts.map +1 -1
  10. package/dist/migration.mjs +3 -3
  11. package/dist/{op-factory-call-z4TT72k3.mjs → op-factory-call-DmdfD1yd.mjs} +143 -104
  12. package/dist/op-factory-call-DmdfD1yd.mjs.map +1 -0
  13. package/dist/op-factory-call.d.mts +12 -6
  14. package/dist/op-factory-call.d.mts.map +1 -1
  15. package/dist/op-factory-call.mjs +1 -1
  16. package/dist/{planner-jMHqfl1A.mjs → planner-Ciq8p_dL.mjs} +3 -3
  17. package/dist/{planner-jMHqfl1A.mjs.map → planner-Ciq8p_dL.mjs.map} +1 -1
  18. package/dist/{planner-produced-sqlite-migration-CyyvoPmm.mjs → planner-produced-sqlite-migration-0xPEm3R1.mjs} +2 -2
  19. package/dist/{planner-produced-sqlite-migration-CyyvoPmm.mjs.map → planner-produced-sqlite-migration-0xPEm3R1.mjs.map} +1 -1
  20. package/dist/{planner-produced-sqlite-migration-BWpnDmhM.d.mts → planner-produced-sqlite-migration-CpgsY-M9.d.mts} +2 -2
  21. package/dist/{planner-produced-sqlite-migration-BWpnDmhM.d.mts.map → planner-produced-sqlite-migration-CpgsY-M9.d.mts.map} +1 -1
  22. package/dist/planner-produced-sqlite-migration.d.mts +1 -1
  23. package/dist/planner-produced-sqlite-migration.mjs +1 -1
  24. package/dist/planner.d.mts +1 -1
  25. package/dist/planner.mjs +1 -1
  26. package/dist/runtime.mjs +1 -1
  27. package/dist/shared-Dhc8mLK1.d.mts.map +1 -1
  28. package/dist/{sqlite-contract-serializer-B_Cu0o3G.mjs → sqlite-contract-serializer-Cq9mXdXi.mjs} +5 -14
  29. package/dist/sqlite-contract-serializer-Cq9mXdXi.mjs.map +1 -0
  30. package/dist/{sqlite-migration-DhW4ycZV.mjs → sqlite-migration-A0rwqPOG.mjs} +32 -13
  31. package/dist/sqlite-migration-A0rwqPOG.mjs.map +1 -0
  32. package/dist/sqlite-migration-DVfhQwN_.d.mts +75 -0
  33. package/dist/sqlite-migration-DVfhQwN_.d.mts.map +1 -0
  34. package/package.json +18 -18
  35. package/src/contract-free/checks.ts +75 -0
  36. package/src/core/migrations/op-factory-call.ts +191 -43
  37. package/src/core/migrations/operations/columns.ts +32 -26
  38. package/src/core/migrations/operations/indexes.ts +31 -27
  39. package/src/core/migrations/operations/shared.ts +11 -3
  40. package/src/core/migrations/operations/tables.ts +39 -37
  41. package/src/core/migrations/sqlite-migration.ts +82 -14
  42. package/src/core/sqlite-unbound-database.ts +16 -23
  43. package/src/exports/contract-free.ts +8 -0
  44. package/src/exports/migration.ts +0 -3
  45. package/dist/ddl-CH8V_qcd.mjs +0 -23
  46. package/dist/ddl-CH8V_qcd.mjs.map +0 -1
  47. package/dist/op-factory-call-z4TT72k3.mjs.map +0 -1
  48. package/dist/sqlite-contract-serializer-B_Cu0o3G.mjs.map +0 -1
  49. package/dist/sqlite-migration-CJrASAxf.d.mts +0 -46
  50. package/dist/sqlite-migration-CJrASAxf.d.mts.map +0 -1
  51. package/dist/sqlite-migration-DhW4ycZV.mjs.map +0 -1
@@ -1,52 +1,56 @@
1
- import { escapeLiteral } from '../../sql-utils';
1
+ import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';
2
+ import { indexExistsAst } from '../../../contract-free/checks';
2
3
  import { buildCreateIndexSql, buildDropIndexSql } from '../planner-ddl-builders';
3
4
  import { buildTargetDetails } from '../planner-target-details';
4
5
  import { type Op, step } from './shared';
5
6
 
6
- export function createIndex(tableName: string, indexName: string, columns: readonly string[]): Op {
7
+ type CheckStep = { sql: string; params?: readonly unknown[] };
8
+
9
+ async function indexExistsSteps(
10
+ lowerer: ExecuteRequestLowerer,
11
+ indexName: string,
12
+ ): Promise<{ present: CheckStep; absent: CheckStep }> {
13
+ const checks = indexExistsAst(indexName);
14
+ const present = await lowerer.lowerToExecuteRequest(checks.indexPresent());
15
+ const absent = await lowerer.lowerToExecuteRequest(checks.indexAbsent());
16
+ return { present, absent };
17
+ }
18
+
19
+ export async function createIndex(
20
+ tableName: string,
21
+ indexName: string,
22
+ columns: readonly string[],
23
+ lowerer: ExecuteRequestLowerer,
24
+ ): Promise<Op> {
25
+ const { present, absent } = await indexExistsSteps(lowerer, indexName);
7
26
  return {
8
27
  id: `index.${tableName}.${indexName}`,
9
28
  label: `Create index ${indexName} on ${tableName}`,
10
29
  summary: `Creates index ${indexName} on ${tableName}`,
11
30
  operationClass: 'additive',
12
31
  target: { id: 'sqlite', details: buildTargetDetails('index', indexName, tableName) },
13
- precheck: [
14
- step(
15
- `ensure index "${indexName}" is missing`,
16
- `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`,
17
- ),
18
- ],
32
+ precheck: [step(`ensure index "${indexName}" is missing`, absent.sql, absent.params)],
19
33
  execute: [
20
34
  step(`create index "${indexName}"`, buildCreateIndexSql(tableName, indexName, columns)),
21
35
  ],
22
- postcheck: [
23
- step(
24
- `verify index "${indexName}" exists`,
25
- `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`,
26
- ),
27
- ],
36
+ postcheck: [step(`verify index "${indexName}" exists`, present.sql, present.params)],
28
37
  };
29
38
  }
30
39
 
31
- export function dropIndex(tableName: string, indexName: string): Op {
40
+ export async function dropIndex(
41
+ tableName: string,
42
+ indexName: string,
43
+ lowerer: ExecuteRequestLowerer,
44
+ ): Promise<Op> {
45
+ const { present, absent } = await indexExistsSteps(lowerer, indexName);
32
46
  return {
33
47
  id: `dropIndex.${tableName}.${indexName}`,
34
48
  label: `Drop index ${indexName} on ${tableName}`,
35
49
  summary: `Drops index ${indexName} on ${tableName} which is not in the contract`,
36
50
  operationClass: 'destructive',
37
51
  target: { id: 'sqlite', details: buildTargetDetails('index', indexName, tableName) },
38
- precheck: [
39
- step(
40
- `ensure index "${indexName}" exists`,
41
- `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`,
42
- ),
43
- ],
52
+ precheck: [step(`ensure index "${indexName}" exists`, present.sql, present.params)],
44
53
  execute: [step(`drop index "${indexName}"`, buildDropIndexSql(indexName))],
45
- postcheck: [
46
- step(
47
- `verify index "${indexName}" is gone`,
48
- `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'index' AND name = '${escapeLiteral(indexName)}'`,
49
- ),
50
- ],
54
+ postcheck: [step(`verify index "${indexName}" is gone`, absent.sql, absent.params)],
51
55
  };
52
56
  }
@@ -1,13 +1,21 @@
1
- import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';
1
+ import type {
2
+ SqlMigrationPlanOperation,
3
+ SqlMigrationPlanOperationStep,
4
+ } from '@prisma-next/family-sql/control';
2
5
  import { REFERENTIAL_ACTION_SQL } from '@prisma-next/sql-contract/referential-action-sql';
3
6
  import type { ReferentialAction } from '@prisma-next/sql-contract/types';
7
+ import { ifDefined } from '@prisma-next/utils/defined';
4
8
  import { quoteIdentifier } from '../../sql-utils';
5
9
  import type { SqlitePlanTargetDetails } from '../planner-target-details';
6
10
 
7
11
  export type Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;
8
12
 
9
- export function step(description: string, sql: string): { description: string; sql: string } {
10
- return { description, sql };
13
+ export function step(
14
+ description: string,
15
+ sql: string,
16
+ params?: readonly unknown[],
17
+ ): SqlMigrationPlanOperationStep {
18
+ return { description, sql, ...ifDefined('params', params) };
11
19
  }
12
20
 
13
21
  /**
@@ -1,5 +1,7 @@
1
1
  import type { MigrationOperationClass } from '@prisma-next/family-sql/control';
2
+ import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';
2
3
  import type { SchemaIssue } from '@prisma-next/framework-components/control';
4
+ import { tableExistsAst } from '../../../contract-free/checks';
3
5
  import { stripOuterParens } from '../../default-normalizer';
4
6
  import { escapeLiteral, quoteIdentifier } from '../../sql-utils';
5
7
  import { buildCreateIndexSql } from '../planner-ddl-builders';
@@ -13,6 +15,18 @@ import {
13
15
  step,
14
16
  } from './shared';
15
17
 
18
+ type CheckStep = { sql: string; params?: readonly unknown[] };
19
+
20
+ async function tableExistsSteps(
21
+ lowerer: ExecuteRequestLowerer,
22
+ tableName: string,
23
+ ): Promise<{ present: CheckStep; absent: CheckStep }> {
24
+ const checks = tableExistsAst(tableName);
25
+ const present = await lowerer.lowerToExecuteRequest(checks.tablePresent());
26
+ const absent = await lowerer.lowerToExecuteRequest(checks.tableAbsent());
27
+ return { present, absent };
28
+ }
29
+
16
30
  /**
17
31
  * Renders the body of a `CREATE TABLE <name> ( … )` statement from a flat
18
32
  * `SqliteTableSpec`. SQLite's `INTEGER PRIMARY KEY AUTOINCREMENT` form is
@@ -42,49 +56,35 @@ function renderCreateTableSql(tableName: string, spec: SqliteTableSpec): string
42
56
  return `CREATE TABLE ${quoteIdentifier(tableName)} (\n ${allDefs.join(',\n ')}\n)`;
43
57
  }
44
58
 
45
- export function createTable(tableName: string, spec: SqliteTableSpec): Op {
59
+ export async function createTable(
60
+ tableName: string,
61
+ spec: SqliteTableSpec,
62
+ lowerer: ExecuteRequestLowerer,
63
+ ): Promise<Op> {
64
+ const { present, absent } = await tableExistsSteps(lowerer, tableName);
46
65
  return {
47
66
  id: `table.${tableName}`,
48
67
  label: `Create table ${tableName}`,
49
68
  summary: `Creates table ${tableName} with required columns`,
50
69
  operationClass: 'additive',
51
70
  target: { id: 'sqlite', details: buildTargetDetails('table', tableName) },
52
- precheck: [
53
- step(
54
- `ensure table "${tableName}" does not exist`,
55
- `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,
56
- ),
57
- ],
71
+ precheck: [step(`ensure table "${tableName}" does not exist`, absent.sql, absent.params)],
58
72
  execute: [step(`create table "${tableName}"`, renderCreateTableSql(tableName, spec))],
59
- postcheck: [
60
- step(
61
- `verify table "${tableName}" exists`,
62
- `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,
63
- ),
64
- ],
73
+ postcheck: [step(`verify table "${tableName}" exists`, present.sql, present.params)],
65
74
  };
66
75
  }
67
76
 
68
- export function dropTable(tableName: string): Op {
77
+ export async function dropTable(tableName: string, lowerer: ExecuteRequestLowerer): Promise<Op> {
78
+ const { present, absent } = await tableExistsSteps(lowerer, tableName);
69
79
  return {
70
80
  id: `dropTable.${tableName}`,
71
81
  label: `Drop table ${tableName}`,
72
82
  summary: `Drops table ${tableName} which is not in the contract`,
73
83
  operationClass: 'destructive',
74
84
  target: { id: 'sqlite', details: buildTargetDetails('table', tableName) },
75
- precheck: [
76
- step(
77
- `ensure table "${tableName}" exists`,
78
- `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,
79
- ),
80
- ],
85
+ precheck: [step(`ensure table "${tableName}" exists`, present.sql, present.params)],
81
86
  execute: [step(`drop table "${tableName}"`, `DROP TABLE ${quoteIdentifier(tableName)}`)],
82
- postcheck: [
83
- step(
84
- `verify table "${tableName}" is gone`,
85
- `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,
86
- ),
87
- ],
87
+ postcheck: [step(`verify table "${tableName}" is gone`, absent.sql, absent.params)],
88
88
  };
89
89
  }
90
90
 
@@ -115,7 +115,10 @@ export interface RecreateTableArgs {
115
115
  readonly operationClass: MigrationOperationClass;
116
116
  }
117
117
 
118
- export function recreateTable(args: RecreateTableArgs): Op {
118
+ export async function recreateTable(
119
+ args: RecreateTableArgs,
120
+ lowerer: ExecuteRequestLowerer,
121
+ ): Promise<Op> {
119
122
  const {
120
123
  tableName,
121
124
  contractTable,
@@ -149,6 +152,9 @@ export function recreateTable(args: RecreateTableArgs): Op {
149
152
  ]
150
153
  : [];
151
154
 
155
+ const tableSteps = await tableExistsSteps(lowerer, tableName);
156
+ const tempSteps = await tableExistsSteps(lowerer, tempName);
157
+
152
158
  return {
153
159
  id: `recreateTable.${tableName}`,
154
160
  label: `Recreate table ${tableName}`,
@@ -156,13 +162,11 @@ export function recreateTable(args: RecreateTableArgs): Op {
156
162
  operationClass,
157
163
  target: { id: 'sqlite', details: buildTargetDetails('table', tableName) },
158
164
  precheck: [
159
- step(
160
- `ensure table "${tableName}" exists`,
161
- `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,
162
- ),
165
+ step(`ensure table "${tableName}" exists`, tableSteps.present.sql, tableSteps.present.params),
163
166
  step(
164
167
  `ensure temp table "${tempName}" does not exist`,
165
- `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tempName)}'`,
168
+ tempSteps.absent.sql,
169
+ tempSteps.absent.params,
166
170
  ),
167
171
  ],
168
172
  execute: [
@@ -179,13 +183,11 @@ export function recreateTable(args: RecreateTableArgs): Op {
179
183
  ...indexStatements,
180
184
  ],
181
185
  postcheck: [
182
- step(
183
- `verify table "${tableName}" exists`,
184
- `SELECT COUNT(*) > 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tableName)}'`,
185
- ),
186
+ step(`verify table "${tableName}" exists`, tableSteps.present.sql, tableSteps.present.params),
186
187
  step(
187
188
  `verify temp table "${tempName}" is gone`,
188
- `SELECT COUNT(*) = 0 FROM sqlite_master WHERE type = 'table' AND name = '${escapeLiteral(tempName)}'`,
189
+ tempSteps.absent.sql,
190
+ tempSteps.absent.params,
189
191
  ),
190
192
  ...postchecks,
191
193
  ],
@@ -1,13 +1,27 @@
1
- import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';
1
+ import type {
2
+ MigrationOperationClass,
3
+ SqlMigrationPlanOperation,
4
+ } from '@prisma-next/family-sql/control';
2
5
  import type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';
3
6
  import { Migration as SqlMigration } from '@prisma-next/family-sql/migration';
4
7
  import type { ControlStack } from '@prisma-next/framework-components/control';
5
8
  import type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';
6
9
  import { blindCast } from '@prisma-next/utils/casts';
7
10
  import { errorSqliteMigrationStackMissing } from '../errors';
8
- import { CreateTableCall } from './op-factory-call';
11
+ import {
12
+ AddColumnCall,
13
+ CreateIndexCall,
14
+ CreateTableCall,
15
+ DropColumnCall,
16
+ DropIndexCall,
17
+ DropTableCall,
18
+ RecreateTableCall,
19
+ } from './op-factory-call';
20
+ import type { SqliteColumnSpec, SqliteIndexSpec, SqliteTableSpec } from './operations/shared';
9
21
  import type { SqlitePlanTargetDetails } from './planner-target-details';
10
22
 
23
+ type Op = SqlMigrationPlanOperation<SqlitePlanTargetDetails>;
24
+
11
25
  /**
12
26
  * Target-owned base class for SQLite migrations. Fixes the `SqlMigration`
13
27
  * generic to `SqlitePlanTargetDetails` and the abstract `targetId` to the
@@ -16,10 +30,10 @@ import type { SqlitePlanTargetDetails } from './planner-target-details';
16
30
  * target-local identity.
17
31
  *
18
32
  * The constructor materializes a single SQLite `SqlControlAdapter` from
19
- * `stack.adapter.create(stack)` and stores it; the protected `createTable`
20
- * instance method forwards to `CreateTableCall` with that stored adapter,
21
- * so user migrations can write `this.createTable({...})` without threading
22
- * the adapter through every call.
33
+ * `stack.adapter.create(stack)` and stores it; the protected instance methods
34
+ * forward to the corresponding `*Call` with that stored adapter, so user
35
+ * migrations can write `this.createTable({...})` without threading the adapter
36
+ * through every call.
23
37
  */
24
38
  export abstract class SqliteMigration extends SqlMigration<SqlitePlanTargetDetails, 'sqlite'> {
25
39
  readonly targetId = 'sqlite' as const;
@@ -27,8 +41,8 @@ export abstract class SqliteMigration extends SqlMigration<SqlitePlanTargetDetai
27
41
  /**
28
42
  * Materialized SQLite control adapter, created once per migration
29
43
  * instance from the injected stack. `undefined` only when the migration
30
- * was instantiated without a stack (test fixtures); `createTable`
31
- * throws in that case to surface the misuse.
44
+ * was instantiated without a stack (test fixtures); the operation methods
45
+ * throw in that case to surface the misuse.
32
46
  */
33
47
  protected readonly controlAdapter: SqlControlAdapter<'sqlite'> | undefined;
34
48
 
@@ -42,17 +56,12 @@ export abstract class SqliteMigration extends SqlMigration<SqlitePlanTargetDetai
42
56
  : undefined;
43
57
  }
44
58
 
45
- /**
46
- * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
47
- * the supplied options and lowers it through the stored control adapter.
48
- * Throws if no adapter is present (i.e. migration instantiated without a stack).
49
- */
50
59
  protected createTable(options: {
51
60
  readonly table: string;
52
61
  readonly ifNotExists?: boolean;
53
62
  readonly columns: readonly DdlColumn[];
54
63
  readonly constraints?: readonly DdlTableConstraint[];
55
- }): Promise<SqlMigrationPlanOperation<SqlitePlanTargetDetails>> {
64
+ }): Promise<Op> {
56
65
  if (!this.controlAdapter) {
57
66
  throw errorSqliteMigrationStackMissing();
58
67
  }
@@ -60,4 +69,63 @@ export abstract class SqliteMigration extends SqlMigration<SqlitePlanTargetDetai
60
69
  this.controlAdapter,
61
70
  );
62
71
  }
72
+
73
+ protected dropTable(options: { readonly table: string }): Promise<Op> {
74
+ if (!this.controlAdapter) {
75
+ throw errorSqliteMigrationStackMissing();
76
+ }
77
+ return new DropTableCall(options.table).toOp(this.controlAdapter);
78
+ }
79
+
80
+ protected addColumn(options: {
81
+ readonly table: string;
82
+ readonly column: SqliteColumnSpec;
83
+ }): Promise<Op> {
84
+ if (!this.controlAdapter) {
85
+ throw errorSqliteMigrationStackMissing();
86
+ }
87
+ return new AddColumnCall(options.table, options.column).toOp(this.controlAdapter);
88
+ }
89
+
90
+ protected dropColumn(options: { readonly table: string; readonly column: string }): Promise<Op> {
91
+ if (!this.controlAdapter) {
92
+ throw errorSqliteMigrationStackMissing();
93
+ }
94
+ return new DropColumnCall(options.table, options.column).toOp(this.controlAdapter);
95
+ }
96
+
97
+ protected createIndex(options: {
98
+ readonly table: string;
99
+ readonly index: string;
100
+ readonly columns: readonly string[];
101
+ }): Promise<Op> {
102
+ if (!this.controlAdapter) {
103
+ throw errorSqliteMigrationStackMissing();
104
+ }
105
+ return new CreateIndexCall(options.table, options.index, options.columns).toOp(
106
+ this.controlAdapter,
107
+ );
108
+ }
109
+
110
+ protected dropIndex(options: { readonly table: string; readonly index: string }): Promise<Op> {
111
+ if (!this.controlAdapter) {
112
+ throw errorSqliteMigrationStackMissing();
113
+ }
114
+ return new DropIndexCall(options.table, options.index).toOp(this.controlAdapter);
115
+ }
116
+
117
+ protected recreateTable(options: {
118
+ readonly tableName: string;
119
+ readonly contractTable: SqliteTableSpec;
120
+ readonly schemaColumnNames: readonly string[];
121
+ readonly indexes: readonly SqliteIndexSpec[];
122
+ readonly summary: string;
123
+ readonly postchecks: readonly { readonly description: string; readonly sql: string }[];
124
+ readonly operationClass: MigrationOperationClass;
125
+ }): Promise<Op> {
126
+ if (!this.controlAdapter) {
127
+ throw errorSqliteMigrationStackMissing();
128
+ }
129
+ return new RecreateTableCall(options).toOp(this.controlAdapter);
130
+ }
63
131
  }
@@ -1,13 +1,14 @@
1
1
  import {
2
2
  freezeNode,
3
+ hydrateNamespaceEntities,
3
4
  NamespaceBase,
4
5
  UNBOUND_NAMESPACE_ID,
5
6
  } from '@prisma-next/framework-components/ir';
6
- import {
7
- type SqlNamespaceEntries,
8
- type SqlNamespaceTablesInput,
7
+ import { tableEntityKind } from '@prisma-next/sql-contract/entity-kinds';
8
+ import type {
9
+ SqlNamespaceEntries,
10
+ SqlNamespaceTablesInput,
9
11
  StorageTable,
10
- type StorageTableInput,
11
12
  } from '@prisma-next/sql-contract/types';
12
13
  import { blindCast } from '@prisma-next/utils/casts';
13
14
 
@@ -33,26 +34,18 @@ export class SqliteDatabase extends NamespaceBase {
33
34
  super();
34
35
  this.id = input.id;
35
36
 
36
- const carried: Record<string, Readonly<Record<string, unknown>>> = {};
37
- let table: Readonly<Record<string, StorageTable>> = Object.freeze({});
38
- for (const [kind, rawMap] of Object.entries(input.entries)) {
39
- if (kind === 'table') {
40
- const tableMap: Record<string, StorageTable> = {};
41
- for (const [name, v] of Object.entries(
42
- blindCast<
43
- Record<string, StorageTableInput>,
44
- 'entries[table] holds StorageTableInput by construction'
45
- >(rawMap),
46
- )) {
47
- tableMap[name] = new StorageTable(v);
48
- }
49
- table = Object.freeze(tableMap);
50
- } else {
51
- carried[kind] = Object.freeze(rawMap);
52
- }
53
- }
37
+ const dispatched = hydrateNamespaceEntities(
38
+ input.entries,
39
+ new Map([['table', tableEntityKind]]),
40
+ 'carry',
41
+ );
54
42
 
55
- this.entries = Object.freeze({ ...carried, table });
43
+ this.entries = Object.freeze(
44
+ blindCast<
45
+ SqlNamespaceEntries,
46
+ "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."
47
+ >(dispatched),
48
+ );
56
49
  Object.defineProperty(this, 'kind', {
57
50
  value: SQLITE_NAMESPACE_KIND,
58
51
  writable: false,
@@ -1,3 +1,11 @@
1
+ export {
2
+ type ColumnExistsCheckBuilder,
3
+ columnExistsAst,
4
+ type IndexExistsCheckBuilder,
5
+ indexExistsAst,
6
+ type TableExistsCheckBuilder,
7
+ tableExistsAst,
8
+ } from '../contract-free/checks';
1
9
  export { datetime, integer, jsonText, sqliteTable, text } from '../contract-free/columns';
2
10
  export {
3
11
  buildControlTableBootstrapQueries,
@@ -17,14 +17,11 @@ export {
17
17
  primaryKey,
18
18
  unique,
19
19
  } from '@prisma-next/sql-relational-core/contract-free';
20
- export { addColumn, dropColumn } from '../core/migrations/operations/columns';
21
20
  export {
22
21
  type DataTransformOptions,
23
22
  dataTransform,
24
23
  } from '../core/migrations/operations/data-transform';
25
- export { createIndex, dropIndex } from '../core/migrations/operations/indexes';
26
24
  export { rawSql } from '../core/migrations/operations/raw';
27
- export { dropTable, recreateTable } from '../core/migrations/operations/tables';
28
25
  // Target-owned base class for migrations. Aliased to `Migration` so
29
26
  // user-edited migration.ts files (and the renderer's scaffold) read as
30
27
  // `class M extends Migration { … }` without having to thread the
@@ -1,23 +0,0 @@
1
- import { t as SqliteCreateTable } from "./nodes-D0k4z7NL.mjs";
2
- //#region src/contract-free/ddl.ts
3
- /**
4
- * Build a SQLite `CREATE TABLE` query node.
5
- *
6
- * Pass `constraints` for table-level composite primary keys, foreign keys, and
7
- * unique constraints — use the {@link PrimaryKeyConstraint}, {@link ForeignKeyConstraint},
8
- * and {@link UniqueConstraint} classes from `@prisma-next/sql-relational-core/ast`.
9
- *
10
- * Precondition: identifiers (`table`, column names/types) are emitted to SQL
11
- * verbatim — they are not quoted or escaped, so callers must pass pre-trusted
12
- * values (e.g. fixed control-plane identifiers). String-literal default values,
13
- * by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.
14
- * Identifier quoting for untrusted identifiers is added when the migration
15
- * planner adopts this lowering path.
16
- */
17
- function createTable(options) {
18
- return new SqliteCreateTable(options);
19
- }
20
- //#endregion
21
- export { createTable as t };
22
-
23
- //# sourceMappingURL=ddl-CH8V_qcd.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ddl-CH8V_qcd.mjs","names":[],"sources":["../src/contract-free/ddl.ts"],"sourcesContent":["import type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { SqliteCreateTable } from '../core/ddl/nodes';\n\n/**\n * Build a SQLite `CREATE TABLE` query node.\n *\n * Pass `constraints` for table-level composite primary keys, foreign keys, and\n * unique constraints — use the {@link PrimaryKeyConstraint}, {@link ForeignKeyConstraint},\n * and {@link UniqueConstraint} classes from `@prisma-next/sql-relational-core/ast`.\n *\n * Precondition: identifiers (`table`, column names/types) are emitted to SQL\n * verbatim — they are not quoted or escaped, so callers must pass pre-trusted\n * values (e.g. fixed control-plane identifiers). String-literal default values,\n * by contrast, are single-quote-escaped (embedded `'` doubled) by the renderer.\n * Identifier quoting for untrusted identifiers is added when the migration\n * planner adopts this lowering path.\n */\nexport function createTable(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n}): SqliteCreateTable {\n return new SqliteCreateTable(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,YAAY,SAMN;CACpB,OAAO,IAAI,kBAAkB,OAAO;AACtC"}