@c9up/atlas 0.1.19 → 0.2.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.
Files changed (121) hide show
  1. package/README.md +55 -14
  2. package/db.darwin-arm64.node +0 -0
  3. package/db.darwin-x64.node +0 -0
  4. package/db.linux-arm64-gnu.node +0 -0
  5. package/db.linux-x64-gnu.node +0 -0
  6. package/db.win32-x64-msvc.node +0 -0
  7. package/dist/AtlasProvider.d.ts +6 -0
  8. package/dist/AtlasProvider.d.ts.map +1 -1
  9. package/dist/AtlasProvider.js +2 -2
  10. package/dist/AtlasProvider.js.map +1 -1
  11. package/dist/BaseEntity.d.ts +164 -5
  12. package/dist/BaseEntity.d.ts.map +1 -1
  13. package/dist/BaseEntity.js +339 -33
  14. package/dist/BaseEntity.js.map +1 -1
  15. package/dist/BaseModel.d.ts +91 -0
  16. package/dist/BaseModel.d.ts.map +1 -0
  17. package/dist/BaseModel.js +193 -0
  18. package/dist/BaseModel.js.map +1 -0
  19. package/dist/BaseRepository.d.ts +71 -15
  20. package/dist/BaseRepository.d.ts.map +1 -1
  21. package/dist/BaseRepository.js +1355 -384
  22. package/dist/BaseRepository.js.map +1 -1
  23. package/dist/ModelQuery.d.ts +341 -18
  24. package/dist/ModelQuery.d.ts.map +1 -1
  25. package/dist/ModelQuery.js +1406 -177
  26. package/dist/ModelQuery.js.map +1 -1
  27. package/dist/Transaction.d.ts +17 -0
  28. package/dist/Transaction.d.ts.map +1 -1
  29. package/dist/Transaction.js +57 -5
  30. package/dist/Transaction.js.map +1 -1
  31. package/dist/adapters/NapiDbAdapter.d.ts +33 -4
  32. package/dist/adapters/NapiDbAdapter.d.ts.map +1 -1
  33. package/dist/adapters/NapiDbAdapter.js +101 -11
  34. package/dist/adapters/NapiDbAdapter.js.map +1 -1
  35. package/dist/console/migrationCommands.d.ts +48 -0
  36. package/dist/console/migrationCommands.d.ts.map +1 -0
  37. package/dist/console/migrationCommands.js +220 -0
  38. package/dist/console/migrationCommands.js.map +1 -0
  39. package/dist/decorators/entity.d.ts +37 -6
  40. package/dist/decorators/entity.d.ts.map +1 -1
  41. package/dist/decorators/entity.js +32 -2
  42. package/dist/decorators/entity.js.map +1 -1
  43. package/dist/events.d.ts +64 -0
  44. package/dist/events.d.ts.map +1 -0
  45. package/dist/events.js +82 -0
  46. package/dist/events.js.map +1 -0
  47. package/dist/index.d.ts +5 -1
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +3 -0
  50. package/dist/index.js.map +1 -1
  51. package/dist/metadata-keys.d.ts +3 -2
  52. package/dist/metadata-keys.d.ts.map +1 -1
  53. package/dist/naming/NamingStrategy.d.ts +7 -0
  54. package/dist/naming/NamingStrategy.d.ts.map +1 -1
  55. package/dist/naming/NamingStrategy.js +16 -0
  56. package/dist/naming/NamingStrategy.js.map +1 -1
  57. package/dist/schema/Migration.d.ts +26 -3
  58. package/dist/schema/Migration.d.ts.map +1 -1
  59. package/dist/schema/Migration.js +33 -24
  60. package/dist/schema/Migration.js.map +1 -1
  61. package/dist/schema/MigrationRunner.d.ts +43 -32
  62. package/dist/schema/MigrationRunner.d.ts.map +1 -1
  63. package/dist/schema/MigrationRunner.js +211 -26
  64. package/dist/schema/MigrationRunner.js.map +1 -1
  65. package/dist/schema/Schema.d.ts +57 -0
  66. package/dist/schema/Schema.d.ts.map +1 -1
  67. package/dist/schema/Schema.js +138 -3
  68. package/dist/schema/Schema.js.map +1 -1
  69. package/dist/schema/TableBuilder.d.ts +247 -8
  70. package/dist/schema/TableBuilder.d.ts.map +1 -1
  71. package/dist/schema/TableBuilder.js +607 -41
  72. package/dist/schema/TableBuilder.js.map +1 -1
  73. package/dist/schema/catalog.d.ts +47 -0
  74. package/dist/schema/catalog.d.ts.map +1 -0
  75. package/dist/schema/catalog.js +111 -0
  76. package/dist/schema/catalog.js.map +1 -0
  77. package/dist/schema/types.d.ts +150 -1
  78. package/dist/schema/types.d.ts.map +1 -1
  79. package/dist/schema/types.js +11 -0
  80. package/dist/schema/types.js.map +1 -1
  81. package/dist/services/db.d.ts +6 -0
  82. package/dist/services/db.d.ts.map +1 -1
  83. package/dist/services/db.js +17 -0
  84. package/dist/services/db.js.map +1 -1
  85. package/dist/testing/DatabaseCleanup.d.ts +7 -4
  86. package/dist/testing/DatabaseCleanup.d.ts.map +1 -1
  87. package/dist/testing/DatabaseCleanup.js +21 -18
  88. package/dist/testing/DatabaseCleanup.js.map +1 -1
  89. package/dist/testing/Factory.d.ts +70 -5
  90. package/dist/testing/Factory.d.ts.map +1 -1
  91. package/dist/testing/Factory.js +209 -10
  92. package/dist/testing/Factory.js.map +1 -1
  93. package/index.darwin-arm64.node +0 -0
  94. package/index.darwin-x64.node +0 -0
  95. package/index.linux-arm64-gnu.node +0 -0
  96. package/index.linux-x64-gnu.node +0 -0
  97. package/index.win32-x64-msvc.node +0 -0
  98. package/package.json +3 -1
  99. package/scripts/guard-publish.mjs +15 -0
  100. package/src/AtlasProvider.ts +8 -1
  101. package/src/BaseEntity.ts +431 -41
  102. package/src/BaseModel.ts +324 -0
  103. package/src/BaseRepository.ts +1589 -419
  104. package/src/ModelQuery.ts +1817 -203
  105. package/src/Transaction.ts +68 -5
  106. package/src/adapters/NapiDbAdapter.ts +159 -10
  107. package/src/console/migrationCommands.ts +258 -0
  108. package/src/decorators/entity.ts +53 -6
  109. package/src/events.ts +112 -0
  110. package/src/index.ts +19 -0
  111. package/src/metadata-keys.ts +3 -2
  112. package/src/naming/NamingStrategy.ts +23 -0
  113. package/src/schema/Migration.ts +42 -3
  114. package/src/schema/MigrationRunner.ts +270 -27
  115. package/src/schema/Schema.ts +210 -3
  116. package/src/schema/TableBuilder.ts +735 -41
  117. package/src/schema/catalog.ts +166 -0
  118. package/src/schema/types.ts +137 -2
  119. package/src/services/db.ts +28 -0
  120. package/src/testing/DatabaseCleanup.ts +23 -22
  121. package/src/testing/Factory.ts +332 -15
@@ -7,28 +7,117 @@
7
7
  * @implements FR34
8
8
  */
9
9
  import { compileStatementNative, getAtlasDialect, } from "../query/native.js";
10
+ import { columnExists, tableExists, } from "./catalog.js";
10
11
  import { TableBuilder } from "./TableBuilder.js";
11
12
  export class Schema {
12
13
  #dialect;
13
14
  #statements = [];
15
+ #connection;
16
+ #schemaName;
14
17
  constructor(dialect = getAtlasDialect()) {
15
18
  this.#dialect = dialect;
16
19
  }
20
+ /**
21
+ * Qualify subsequent table names with `name` (Adonis Lucid/Knex
22
+ * `withSchema`), e.g. `withSchema('reporting').createTable('t', …)` targets
23
+ * `"reporting"."t"`. Applies to every table-taking method until changed; the
24
+ * Rust compiler quotes each dotted segment. Chainable.
25
+ */
26
+ withSchema(name) {
27
+ this.#schemaName = name;
28
+ return this;
29
+ }
30
+ /** Prefix a table name with the active schema, if one was set. */
31
+ #qualify(table) {
32
+ return this.#schemaName ? `${this.#schemaName}.${table}` : table;
33
+ }
34
+ /**
35
+ * Attach a live connection so the async introspection helpers
36
+ * ({@link hasTable}/{@link hasColumn}) can query the catalog. The migration
37
+ * runner calls this before running a migration's `up`/`down`.
38
+ */
39
+ bindConnection(connection) {
40
+ this.#connection = connection;
41
+ }
42
+ /**
43
+ * Does this table exist right now? (Adonis Lucid/Knex `hasTable`.) Runs a
44
+ * live catalog query, so it reflects migrations already applied — but NOT
45
+ * statements this same migration has only buffered (they run after `up`).
46
+ * Requires a bound connection (present inside a migration).
47
+ */
48
+ async hasTable(name) {
49
+ return tableExists(this.#requireConnection("hasTable"), this.#dialect, name);
50
+ }
51
+ /** Does this column exist on this table right now? (Adonis Lucid/Knex `hasColumn`.) */
52
+ async hasColumn(table, column) {
53
+ return columnExists(this.#requireConnection("hasColumn"), this.#dialect, table, column);
54
+ }
55
+ #requireConnection(method) {
56
+ if (!this.#connection) {
57
+ throw new Error(`E_NO_CONNECTION: schema.${method}() needs a live connection — it is available inside a migration, not on a standalone Schema.`);
58
+ }
59
+ return this.#connection;
60
+ }
17
61
  createTable(name, callback) {
18
- const builder = new TableBuilder(name);
62
+ const builder = new TableBuilder(this.#qualify(name));
19
63
  callback(builder);
20
64
  this.#statements.push(...builder.toStatements(this.#dialect));
21
65
  return this;
22
66
  }
67
+ /** `CREATE TABLE IF NOT EXISTS` (Lucid/Knex `createTableIfNotExists`). */
68
+ createTableIfNotExists(name, callback) {
69
+ const builder = new TableBuilder(this.#qualify(name));
70
+ callback(builder);
71
+ this.#statements.push(...builder.toStatements(this.#dialect, { ifNotExists: true }));
72
+ return this;
73
+ }
74
+ /**
75
+ * `ALTER TABLE` (Lucid/Knex `alterTable`, also spelled `table()`). Inside
76
+ * the callback a column-type method adds a column, `.alter()` changes one,
77
+ * and `dropColumn` / `renameColumn` / `setNullable` / `dropNullable` do
78
+ * what they say. Operations compile in call order.
79
+ */
80
+ alterTable(name, callback) {
81
+ const builder = new TableBuilder(this.#qualify(name), "alter");
82
+ callback(builder);
83
+ // An empty callback is a caller bug, not an empty statement list: the
84
+ // Rust compiler rejects a no-op ALTER, so short-circuit with a clearer error.
85
+ if (builder.getOperations().length === 0 &&
86
+ builder.getIndexes().length === 0) {
87
+ throw new Error(`E_ALTER_EMPTY: schema.alterTable('${name}') declared no operations`);
88
+ }
89
+ this.#statements.push(...builder.toStatements(this.#dialect));
90
+ return this;
91
+ }
92
+ /** Alias of {@link alterTable} (Lucid/Knex `table()`). */
93
+ table(name, callback) {
94
+ return this.alterTable(name, callback);
95
+ }
96
+ /** `ALTER TABLE old RENAME TO new` (Lucid/Knex `renameTable`). */
97
+ renameTable(from, to) {
98
+ const { statements } = compileStatementNative({
99
+ kind: "renameTable",
100
+ table: this.#qualify(from),
101
+ to: this.#qualify(to),
102
+ }, this.#dialect);
103
+ this.#statements.push(...statements);
104
+ return this;
105
+ }
23
106
  dropTable(name) {
24
- const { statements } = compileStatementNative({ kind: "dropTable", table: name, ifExists: true }, this.#dialect);
107
+ const { statements } = compileStatementNative({ kind: "dropTable", table: this.#qualify(name), ifExists: true }, this.#dialect);
25
108
  this.#statements.push(...statements);
26
109
  return this;
27
110
  }
28
111
  createIndex(table, columns, name, unique = false) {
29
112
  const cols = Array.isArray(columns) ? columns : [columns];
30
113
  const indexName = name ?? `idx_${table}_${cols.join("_")}`;
31
- const { statements } = compileStatementNative({ kind: "createIndex", table, name: indexName, columns: cols, unique }, this.#dialect);
114
+ const { statements } = compileStatementNative({
115
+ kind: "createIndex",
116
+ table: this.#qualify(table),
117
+ name: indexName,
118
+ columns: cols,
119
+ unique,
120
+ }, this.#dialect);
32
121
  this.#statements.push(...statements);
33
122
  return this;
34
123
  }
@@ -37,6 +126,52 @@ export class Schema {
37
126
  this.#statements.push(...statements);
38
127
  return this;
39
128
  }
129
+ /**
130
+ * `CREATE VIEW name [(cols)] AS <select>` (Lucid/Knex `createView`). The
131
+ * `select` is raw, developer-authored SQL — same trust level as {@link raw} —
132
+ * embedded verbatim; the view name and column list are validated + quoted by
133
+ * the Rust compiler.
134
+ */
135
+ createView(name, select, options = {}) {
136
+ return this.#pushView(name, select, options);
137
+ }
138
+ /** `CREATE OR REPLACE VIEW` (Lucid/Knex `createViewOrReplace`). Rejected on SQLite. */
139
+ createViewOrReplace(name, select, options = {}) {
140
+ return this.#pushView(name, select, { ...options, orReplace: true });
141
+ }
142
+ /** `CREATE MATERIALIZED VIEW` (Lucid/Knex `createMaterializedView`). Postgres-only. */
143
+ createMaterializedView(name, select, options = {}) {
144
+ return this.#pushView(name, select, { ...options, materialized: true });
145
+ }
146
+ /** `DROP VIEW IF EXISTS name` (Lucid/Knex `dropView`/`dropViewIfExists`). */
147
+ dropView(name) {
148
+ const { statements } = compileStatementNative({ kind: "dropView", name: this.#qualify(name), ifExists: true }, this.#dialect);
149
+ this.#statements.push(...statements);
150
+ return this;
151
+ }
152
+ /** `DROP MATERIALIZED VIEW IF EXISTS name` (Lucid/Knex). Postgres-only. */
153
+ dropMaterializedView(name) {
154
+ const { statements } = compileStatementNative({
155
+ kind: "dropView",
156
+ name: this.#qualify(name),
157
+ ifExists: true,
158
+ materialized: true,
159
+ }, this.#dialect);
160
+ this.#statements.push(...statements);
161
+ return this;
162
+ }
163
+ #pushView(name, select, options) {
164
+ const { statements } = compileStatementNative({
165
+ kind: "createView",
166
+ name: this.#qualify(name),
167
+ select,
168
+ orReplace: options.orReplace ?? false,
169
+ materialized: options.materialized ?? false,
170
+ columns: options.columns ?? null,
171
+ }, this.#dialect);
172
+ this.#statements.push(...statements);
173
+ return this;
174
+ }
40
175
  raw(sql) {
41
176
  this.#statements.push(sql);
42
177
  return this;
@@ -1 +1 @@
1
- {"version":3,"file":"Schema.js","sourceRoot":"","sources":["../../src/schema/Schema.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAEN,sBAAsB,EACtB,eAAe,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,OAAO,MAAM;IAClB,QAAQ,CAAe;IACvB,WAAW,GAAa,EAAE,CAAC;IAE3B,YAAY,UAAwB,eAAe,EAAE;QACpD,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,WAAW,CAAC,IAAY,EAAE,QAAuC;QAChE,MAAM,OAAO,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;QACvC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9D,OAAO,IAAI,CAAC;IACb,CAAC;IAED,SAAS,CAAC,IAAY;QACrB,MAAM,EAAE,UAAU,EAAE,GAAG,sBAAsB,CAC5C,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAClD,IAAI,CAAC,QAAQ,CACb,CAAC;QACF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACb,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ED,KAAK;QACJ,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,KAAK;QACJ,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAC9B,CAAC;CACD"}
@@ -8,12 +8,39 @@
8
8
  */
9
9
  import { type AtlasDialect } from "../query/native.js";
10
10
  import { type DefaultValue } from "./raw.js";
11
- import { type ColumnDefinition, type IndexDefinition } from "./types.js";
11
+ import { type AlterOperation, type CheckOperator, type CheckValue, type ColumnDefinition, type ForeignKeyReference, type IndexDefinition, type ReferentialAction, type TextVariant } from "./types.js";
12
+ /**
13
+ * The chainable returned by `table.foreign([...])`, so the target reads in
14
+ * Knex order: `.references([...]).inTable('other').onDelete('cascade')`. It
15
+ * mutates the already-recorded constraint in place.
16
+ */
17
+ export declare class ForeignKeyBuilder {
18
+ #private;
19
+ constructor(references: ForeignKeyReference);
20
+ /** Target column(s) on the referenced table. */
21
+ references(columns: string | readonly string[]): this;
22
+ /**
23
+ * Referenced table. Keeps returning this builder so `.onDelete()` /
24
+ * `.onUpdate()` can follow, as in Knex — the constraint was already
25
+ * recorded on the table when `foreign()` was called, so there is nothing to
26
+ * hand back to.
27
+ */
28
+ inTable(table: string): this;
29
+ onDelete(action: ReferentialAction): this;
30
+ onUpdate(action: ReferentialAction): this;
31
+ }
32
+ /**
33
+ * Whether the builder is filling a `CREATE TABLE` or an `ALTER TABLE`. In
34
+ * `alter` mode a column-type method (`t.string('x')`) becomes `ADD COLUMN`,
35
+ * and `.alter()` turns the pending add into a type change (Lucid/Knex).
36
+ */
37
+ export type TableBuilderMode = "create" | "alter";
12
38
  /** Table builder — used inside `schema.createTable(name, callback)`. */
13
39
  export declare class TableBuilder {
14
40
  #private;
15
41
  readonly tableName: string;
16
- constructor(tableName: string);
42
+ readonly mode: TableBuilderMode;
43
+ constructor(tableName: string, mode?: TableBuilderMode);
17
44
  uuid(name: string): this;
18
45
  /**
19
46
  * Auto-incrementing integer primary key (Lucid `increments()`). The Rust
@@ -25,13 +52,54 @@ export declare class TableBuilder {
25
52
  /** Auto-incrementing 64-bit primary key (Lucid `bigIncrements()`). */
26
53
  bigIncrements(name?: string): this;
27
54
  string(name: string, length?: number): this;
28
- text(name: string): this;
55
+ /**
56
+ * Text column (Lucid/Knex `text(name, textType)`). `textType` widens the
57
+ * MySQL type (`MEDIUMTEXT` / `LONGTEXT`); Postgres and SQLite have a single
58
+ * unbounded `TEXT` and ignore it.
59
+ */
60
+ text(name: string, textType?: TextVariant): this;
29
61
  integer(name: string): this;
62
+ /** 24-bit integer (Lucid/Knex `mediumint`). MySQL `MEDIUMINT`; pg/SQLite widen to `INTEGER`. */
63
+ mediumint(name: string): this;
64
+ /** 8-bit integer (Lucid `tinyint`). MySQL `TINYINT`; Postgres widens to `SMALLINT`; SQLite `INTEGER`. */
65
+ tinyint(name: string): this;
66
+ /** 16-bit integer (Lucid `smallint`). `SMALLINT` on pg/mysql, `INTEGER` on SQLite. */
67
+ smallint(name: string): this;
30
68
  bigInteger(name: string): this;
31
69
  decimal(name: string, precision?: number, scale?: number): this;
70
+ /**
71
+ * Single-precision float (Lucid `float`). `REAL` on pg/sqlite, `FLOAT` on
72
+ * MySQL. `precision`/`scale` render `FLOAT(p, s)` on MySQL only — pg and
73
+ * SQLite have fixed-width floats and ignore them.
74
+ */
75
+ float(name: string, precision?: number, scale?: number): this;
76
+ /** Double-precision float (Lucid `double`). `DOUBLE PRECISION` on pg, `REAL` on SQLite, `DOUBLE` on MySQL. See {@link float} for precision/scale. */
77
+ double(name: string, precision?: number, scale?: number): this;
32
78
  boolean(name: string): this;
33
79
  date(name: string): this;
34
- timestamp(name: string): this;
80
+ /**
81
+ * Time of day (Lucid `time`). `TIME` on pg/mysql, `TEXT` on SQLite.
82
+ * `precision` renders `TIME(p)` fractional seconds (ignored on SQLite,
83
+ * which has no time type to carry it).
84
+ */
85
+ time(name: string, precision?: number): this;
86
+ /**
87
+ * Timestamp column (Lucid `timestamp(name, options)`).
88
+ *
89
+ * `useTz: true` selects the tz-aware type — the same thing
90
+ * {@link timestamptz} does, exposed here for Lucid's option spelling.
91
+ * `precision` renders `TIMESTAMP(p)` (ignored on SQLite, which stores
92
+ * timestamps as TEXT).
93
+ */
94
+ timestamp(name: string, options?: {
95
+ useTz?: boolean;
96
+ precision?: number;
97
+ }): this;
98
+ /** Alias of {@link timestamp} (Lucid `dateTime`). Use `{ useTz: true }` or {@link timestamptz} for a tz-aware column. */
99
+ dateTime(name: string, options?: {
100
+ useTz?: boolean;
101
+ precision?: number;
102
+ }): this;
35
103
  /**
36
104
  * `timestamp WITH time zone` — Postgres normalises every writer (atlas,
37
105
  * `DEFAULT now()`, raw SQL) to UTC, so reads are unambiguous regardless of
@@ -43,7 +111,39 @@ export declare class TableBuilder {
43
111
  */
44
112
  timestamptz(name: string): this;
45
113
  json(name: string): this;
46
- binary(name: string): this;
114
+ /**
115
+ * Binary JSON (Lucid/Knex `jsonb`). `JSONB` on pg, `JSON` on MySQL, `TEXT`
116
+ * on SQLite.
117
+ *
118
+ * Deviation, named: atlas's {@link json} already maps to `JSONB` on
119
+ * Postgres (it predates this method), where Lucid's `json()` maps to
120
+ * `json`. Leaving `json()` alone avoids silently rewriting the physical
121
+ * type of existing columns and desyncing `SchemaCheck`, so on Postgres the
122
+ * two spellings coincide.
123
+ */
124
+ jsonb(name: string): this;
125
+ /**
126
+ * Binary blob (Lucid/Knex `binary(name, length)`). `BYTEA` on pg, `BLOB` on
127
+ * SQLite; on MySQL `length` selects `VARBINARY(n)` over `BLOB`.
128
+ */
129
+ binary(name: string, length?: number): this;
130
+ /**
131
+ * A column typed with a verbatim dialect type (Lucid/Knex `specificType`) —
132
+ * the escape hatch for types atlas has no method for (`inet`, `tsvector`,
133
+ * `geometry(Point, 4326)`…).
134
+ *
135
+ * Deviation, named: Knex passes the string straight through. Atlas cannot —
136
+ * it lands verbatim in DDL, so the Rust compiler validates it against a
137
+ * narrow grammar (letters, digits, spaces, `_`, and one parenthesised
138
+ * argument list) and rejects anything else with `E_UNSAFE_SQL`.
139
+ */
140
+ specificType(name: string, type: string): this;
141
+ /**
142
+ * Fixed value-set column (Lucid `enum`). MySQL renders a native `ENUM(...)`;
143
+ * Postgres and SQLite render `TEXT` plus a `CHECK (col IN (...))` that pins the
144
+ * value set. At least one value is required.
145
+ */
146
+ enum(name: string, values: string[]): this;
47
147
  /**
48
148
  * UUID primary key with Postgres-only `gen_random_uuid()` default.
49
149
  *
@@ -90,22 +190,161 @@ export declare class TableBuilder {
90
190
  * the helper dialect-aware.
91
191
  */
92
192
  timestamps(): this;
93
- primary(): this;
94
193
  notNullable(): this;
95
194
  nullable(): this;
96
- unique(): this;
97
195
  /**
98
196
  * Set a column default. JS literals are quoted/escaped (`'x'`, `123`,
99
197
  * `true` — Lucid/Knex semantics); wrap SQL expressions in {@link raw} (or
100
198
  * use `Migration.now()`) to emit them verbatim.
101
199
  */
102
200
  defaultTo(value: DefaultValue): this;
201
+ /** MySQL `UNSIGNED` numeric modifier (Lucid `unsigned()`). No-op on pg/sqlite. */
202
+ unsigned(): this;
103
203
  references(table: string, column?: string): this;
204
+ /**
205
+ * Referential action for the current column's foreign key `ON DELETE`
206
+ * (Lucid parity). Must follow {@link references}.
207
+ */
208
+ onDelete(action: ReferentialAction): this;
209
+ /** Referential action for the current column's foreign key `ON UPDATE`. Must follow {@link references}. */
210
+ onUpdate(action: ReferentialAction): this;
211
+ /**
212
+ * Comment the current **column** (Lucid/Knex column `comment()`). Inline on
213
+ * MySQL, a separate `COMMENT ON COLUMN` on Postgres, dropped on SQLite.
214
+ *
215
+ * Deviation, named: Knex's `table.comment()` is the TABLE comment, because
216
+ * its column methods return a separate column builder. Atlas flattens the
217
+ * column modifiers onto the table builder (`.notNullable()`, `.unique()`,
218
+ * `.defaultTo()` all work this way), so `comment()` follows that same rule
219
+ * and the table comment is {@link tableComment}. Resolving it by "is a
220
+ * column pending?" would be exactly the kind of guessing that bites later.
221
+ */
222
+ comment(text: string): this;
223
+ /** Collate the current **column** (Lucid/Knex column `collate()`). See {@link comment} for why the table form is {@link tableCollate}. */
224
+ collate(collation: string): this;
225
+ /**
226
+ * Place an added column first (Lucid/Knex `first()`). MySQL-only —
227
+ * Postgres and SQLite always append, and the Rust compiler raises
228
+ * `E_UNSUPPORTED` rather than dropping the instruction silently.
229
+ */
230
+ first(): this;
231
+ /** Place an added column after `column` (Lucid/Knex `after()`). MySQL-only — see {@link first}. */
232
+ after(column: string): this;
233
+ /** `CHECK (col > 0)` on the current column (Lucid/Knex `checkPositive`). */
234
+ checkPositive(constraintName?: string): this;
235
+ /** `CHECK (col < 0)` on the current column (Lucid/Knex `checkNegative`). */
236
+ checkNegative(constraintName?: string): this;
237
+ /** `CHECK (col IN (…))` on the current column (Lucid/Knex `checkIn`). Values are quoted, never interpolated raw. */
238
+ checkIn(values: readonly CheckValue[], constraintName?: string): this;
239
+ /** `CHECK (col NOT IN (…))` on the current column (Lucid/Knex `checkNotIn`). */
240
+ checkNotIn(values: readonly CheckValue[], constraintName?: string): this;
241
+ /**
242
+ * `CHECK (col BETWEEN lo AND hi)` on the current column (Lucid/Knex
243
+ * `checkBetween`). Accepts one `[min, max]` interval or a list of them —
244
+ * several intervals are OR'd together, as in Knex.
245
+ */
246
+ checkBetween(range: readonly CheckValue[] | readonly (readonly CheckValue[])[], constraintName?: string): this;
247
+ /** `CHECK (LENGTH(col) <op> n)` on the current column (Lucid/Knex `checkLength`). The operator is allow-listed by the Rust compiler. */
248
+ checkLength(operator: CheckOperator, length: number, constraintName?: string): this;
249
+ /**
250
+ * `CHECK (col ~ 'pattern')` on the current column (Lucid/Knex `checkRegex`).
251
+ * Postgres spells it `~`; MySQL and SQLite use `REGEXP`.
252
+ *
253
+ * SQLite parses `REGEXP` but ships no implementation — the constraint only
254
+ * works if the connection registers a `regexp` function. Knex behaves the
255
+ * same way, so this is parity rather than a new trap, but it is worth
256
+ * knowing before you rely on it there.
257
+ */
258
+ checkRegex(pattern: string, constraintName?: string): this;
259
+ /**
260
+ * A free-form `CHECK (predicate)` (Lucid/Knex `check`). The predicate is
261
+ * emitted verbatim — exactly as trusted as {@link Schema.raw}, so never
262
+ * build it from user input. Prefer the typed `check*` helpers, which are
263
+ * safe by construction.
264
+ */
265
+ check(predicate: string, constraintName?: string): this;
266
+ /** Drop named CHECK constraints (Lucid/Knex `dropChecks`). */
267
+ dropChecks(...constraintNames: string[]): this;
268
+ /**
269
+ * With no argument, mark the current column as the primary key (the
270
+ * existing column modifier). With a column list, declare a composite
271
+ * `PRIMARY KEY (…)` table constraint (Lucid/Knex `primary([...])`).
272
+ */
273
+ primary(columns?: readonly string[], constraintName?: string): this;
274
+ /**
275
+ * With no argument, mark the current column `UNIQUE` (the existing column
276
+ * modifier). With a column list, declare a composite `UNIQUE (…)` table
277
+ * constraint (Lucid/Knex `unique([...])`).
278
+ *
279
+ * Note this is a real constraint, unlike {@link uniqueIndex}, which creates
280
+ * a separate `CREATE UNIQUE INDEX`.
281
+ */
282
+ unique(columns?: readonly string[], constraintName?: string): this;
283
+ /**
284
+ * Declare a composite foreign key (Lucid/Knex
285
+ * `foreign([...]).references([...]).inTable(…)`). Returns a small chainable
286
+ * so the target reads in Knex order; the constraint is recorded up front
287
+ * and filled in as you chain.
288
+ */
289
+ foreign(columns: string | readonly string[], constraintName?: string): ForeignKeyBuilder;
290
+ /** Drop the primary key (Lucid/Knex `dropPrimary`). MySQL drops it by keyword; Postgres by name (default `<table>_pkey`). */
291
+ dropPrimary(constraintName?: string): this;
292
+ /** Drop a unique constraint by columns (using the default name) or by explicit name (Lucid/Knex `dropUnique`). */
293
+ dropUnique(columns: string | readonly string[], constraintName?: string): this;
294
+ /** Drop a foreign key by columns (using the default name) or by explicit name (Lucid/Knex `dropForeign`). */
295
+ dropForeign(columns: string | readonly string[], constraintName?: string): this;
296
+ /** Drop `created_at` + `updated_at` (Lucid/Knex `dropTimestamps`). */
297
+ dropTimestamps(): this;
298
+ /** MySQL storage engine (Lucid/Knex `engine`). Ignored on pg/sqlite. */
299
+ engine(name: string): this;
300
+ /** MySQL default charset (Lucid/Knex `charset`). Ignored on pg/sqlite. */
301
+ charset(name: string): this;
302
+ /** MySQL default collation for the table. Named `tableCollate` because {@link collate} is the column modifier — see {@link comment}. */
303
+ tableCollate(name: string): this;
304
+ /** Table comment. Named `tableComment` because {@link comment} is the column modifier — see there for why. */
305
+ tableComment(text: string): this;
104
306
  index(columns: string | string[], name?: string): this;
105
307
  uniqueIndex(columns: string | string[], name?: string): this;
308
+ /**
309
+ * Apply the pending column definition as a type change instead of an
310
+ * `ADD COLUMN` (Lucid/Knex `alter()`). Must follow a column-type method.
311
+ *
312
+ * Nullability moves only if `.nullable()` / `.notNullable()` was called
313
+ * before this — a bare `t.string('x').alter()` changes the type and leaves
314
+ * the NOT NULL constraint exactly as it is.
315
+ *
316
+ * SQLite cannot alter a column in place; the Rust compiler rejects it with
317
+ * `E_UNSUPPORTED` rather than emitting a table rebuild behind your back.
318
+ */
319
+ alter(): this;
320
+ /** Drop a column (Lucid/Knex `dropColumn`). */
321
+ dropColumn(name: string): this;
322
+ /** Drop several columns in call order (Lucid/Knex `dropColumns`). */
323
+ dropColumns(...names: string[]): this;
324
+ /** Rename a column (Lucid/Knex `renameColumn`). */
325
+ renameColumn(from: string, to: string): this;
326
+ /**
327
+ * Make an existing column nullable — `DROP NOT NULL` (Lucid/Knex
328
+ * `setNullable`).
329
+ *
330
+ * **Deviation from Knex, named deliberately.** Knex supports this on every
331
+ * dialect by querying `columnInfo()` at runtime to recover the column's
332
+ * type. Atlas compiles SQL synchronously in Rust with no round-trip, so
333
+ * this is Postgres-only — Postgres is the one dialect whose syntax needs no
334
+ * type. On MySQL use `table.<type>('col').nullable().alter()`, which
335
+ * restates the type; SQLite cannot alter a column in place at all. Both
336
+ * raise `E_UNSUPPORTED` with the alternative spelled out.
337
+ */
338
+ setNullable(name: string): this;
339
+ /** Make an existing column `NOT NULL` (Lucid/Knex `dropNullable`). Postgres-only — see {@link setNullable}. */
340
+ dropNullable(name: string): this;
106
341
  getColumns(): ColumnDefinition[];
107
342
  getIndexes(): IndexDefinition[];
343
+ /** Ordered ALTER TABLE operations. Empty in `create` mode. */
344
+ getOperations(): AlterOperation[];
108
345
  /** Compile to SQL statements via the Rust compiler. */
109
- toStatements(dialect?: AtlasDialect): string[];
346
+ toStatements(dialect?: AtlasDialect, options?: {
347
+ ifNotExists?: boolean;
348
+ }): string[];
110
349
  }
111
350
  //# sourceMappingURL=TableBuilder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"TableBuilder.d.ts","sourceRoot":"","sources":["../../src/schema/TableBuilder.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,KAAK,YAAY,EAGjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,UAAU,CAAC;AACjE,OAAO,EACN,KAAK,gBAAgB,EAErB,KAAK,eAAe,EAEpB,MAAM,YAAY,CAAC;AAEpB,wEAAwE;AACxE,qBAAa,YAAY;;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAKf,SAAS,EAAE,MAAM;IAM7B,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIxB;;;;;OAKG;IACH,UAAU,CAAC,IAAI,SAAO,GAAG,IAAI;IAI7B,sEAAsE;IACtE,aAAa,CAAC,IAAI,SAAO,GAAG,IAAI;IAIhC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,SAAM,GAAG,IAAI;IAMxC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAGxB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAG3B,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI9B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,SAAK,EAAE,KAAK,SAAI,GAAG,IAAI;IAStD,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAG3B,IAAI,C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