@remix-run/data-table 0.2.1 → 0.4.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 (113) hide show
  1. package/README.md +251 -123
  2. package/dist/cli.d.ts +54 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +53 -0
  5. package/dist/index.d.ts +5 -4
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +7 -7
  8. package/dist/lib/column.d.ts +1 -1
  9. package/dist/lib/column.d.ts.map +1 -1
  10. package/dist/lib/column.js +10 -1
  11. package/dist/lib/database/execution-context.d.ts +5 -5
  12. package/dist/lib/database/execution-context.d.ts.map +1 -1
  13. package/dist/lib/database/execution-context.js +1 -0
  14. package/dist/lib/database/helpers.js +6 -6
  15. package/dist/lib/database/query-execution.d.ts.map +1 -1
  16. package/dist/lib/database/query-execution.js +17 -17
  17. package/dist/lib/database/relations.js +5 -5
  18. package/dist/lib/database/write-lifecycle.d.ts +2 -2
  19. package/dist/lib/database/write-lifecycle.d.ts.map +1 -1
  20. package/dist/lib/database/write-lifecycle.js +5 -5
  21. package/dist/lib/database.d.ts +74 -59
  22. package/dist/lib/database.d.ts.map +1 -1
  23. package/dist/lib/database.js +176 -83
  24. package/dist/lib/driver.d.ts +287 -0
  25. package/dist/lib/driver.d.ts.map +1 -0
  26. package/dist/lib/errors.d.ts +2 -2
  27. package/dist/lib/errors.d.ts.map +1 -1
  28. package/dist/lib/errors.js +4 -4
  29. package/dist/lib/migrations/directive.d.ts +12 -0
  30. package/dist/lib/migrations/directive.d.ts.map +1 -0
  31. package/dist/lib/migrations/directive.js +28 -0
  32. package/dist/lib/migrations/directory-name.d.ts +12 -0
  33. package/dist/lib/migrations/directory-name.d.ts.map +1 -0
  34. package/dist/lib/migrations/directory-name.js +18 -0
  35. package/dist/lib/migrations/journal-store.d.ts +7 -7
  36. package/dist/lib/migrations/journal-store.d.ts.map +1 -1
  37. package/dist/lib/migrations/journal-store.js +37 -28
  38. package/dist/lib/migrations/registry.d.ts +1 -1
  39. package/dist/lib/migrations/registry.js +1 -1
  40. package/dist/lib/migrations/runner.d.ts +12 -19
  41. package/dist/lib/migrations/runner.d.ts.map +1 -1
  42. package/dist/lib/migrations/runner.js +170 -175
  43. package/dist/lib/migrations-node.d.ts +26 -5
  44. package/dist/lib/migrations-node.d.ts.map +1 -1
  45. package/dist/lib/migrations-node.js +73 -41
  46. package/dist/lib/migrations.d.ts +63 -209
  47. package/dist/lib/migrations.d.ts.map +1 -1
  48. package/dist/lib/migrations.js +1 -38
  49. package/dist/lib/operators.d.ts +1 -1
  50. package/dist/lib/operators.js +1 -1
  51. package/dist/lib/query.d.ts +34 -1
  52. package/dist/lib/query.d.ts.map +1 -1
  53. package/dist/lib/query.js +32 -4
  54. package/dist/lib/sql-helpers.d.ts +1 -7
  55. package/dist/lib/sql-helpers.d.ts.map +1 -1
  56. package/dist/lib/sql-helpers.js +0 -16
  57. package/dist/lib/sql.d.ts +1 -1
  58. package/dist/lib/sql.js +1 -1
  59. package/dist/lib/table.d.ts +1 -1
  60. package/dist/lib/table.d.ts.map +1 -1
  61. package/dist/lib/table.js +5 -5
  62. package/dist/migrations/node.d.ts +1 -1
  63. package/dist/migrations/node.d.ts.map +1 -1
  64. package/dist/migrations/node.js +1 -1
  65. package/dist/migrations.d.ts +2 -6
  66. package/dist/migrations.d.ts.map +1 -1
  67. package/dist/migrations.js +2 -5
  68. package/dist/operators.js +1 -1
  69. package/dist/sql-helpers.d.ts +1 -1
  70. package/dist/sql-helpers.d.ts.map +1 -1
  71. package/dist/sql-helpers.js +1 -1
  72. package/package.json +13 -9
  73. package/src/cli.ts +120 -0
  74. package/src/index.ts +20 -54
  75. package/src/lib/column.ts +14 -2
  76. package/src/lib/database/execution-context.ts +10 -6
  77. package/src/lib/database/helpers.ts +1 -1
  78. package/src/lib/database/query-execution.ts +15 -11
  79. package/src/lib/database/write-lifecycle.ts +4 -4
  80. package/src/lib/database.ts +223 -96
  81. package/src/lib/driver.ts +333 -0
  82. package/src/lib/errors.ts +4 -4
  83. package/src/lib/migrations/directive.ts +38 -0
  84. package/src/lib/migrations/directory-name.ts +23 -0
  85. package/src/lib/migrations/journal-store.ts +42 -28
  86. package/src/lib/migrations/registry.ts +1 -1
  87. package/src/lib/migrations/runner.ts +224 -205
  88. package/src/lib/migrations-node.ts +80 -38
  89. package/src/lib/migrations.ts +62 -228
  90. package/src/lib/operators.ts +1 -1
  91. package/src/lib/query.ts +34 -1
  92. package/src/lib/sql-helpers.ts +1 -22
  93. package/src/lib/sql.ts +1 -1
  94. package/src/lib/table.ts +1 -1
  95. package/src/migrations/node.ts +1 -1
  96. package/src/migrations.ts +5 -16
  97. package/src/sql-helpers.ts +0 -1
  98. package/dist/lib/adapter.d.ts +0 -550
  99. package/dist/lib/adapter.d.ts.map +0 -1
  100. package/dist/lib/migrations/filename.d.ts +0 -12
  101. package/dist/lib/migrations/filename.d.ts.map +0 -1
  102. package/dist/lib/migrations/filename.js +0 -20
  103. package/dist/lib/migrations/helpers.d.ts +0 -11
  104. package/dist/lib/migrations/helpers.d.ts.map +0 -1
  105. package/dist/lib/migrations/helpers.js +0 -77
  106. package/dist/lib/migrations/schema-api.d.ts +0 -7
  107. package/dist/lib/migrations/schema-api.d.ts.map +0 -1
  108. package/dist/lib/migrations/schema-api.js +0 -326
  109. package/src/lib/adapter.ts +0 -653
  110. package/src/lib/migrations/filename.ts +0 -25
  111. package/src/lib/migrations/helpers.ts +0 -108
  112. package/src/lib/migrations/schema-api.ts +0 -417
  113. /package/dist/lib/{adapter.js → driver.js} +0 -0
@@ -1,653 +0,0 @@
1
- import type { AnyTable, OrderByClause } from './table.ts'
2
- import type { Predicate } from './operators.ts'
3
- import type { SqlStatement } from './sql.ts'
4
- import type { Pretty } from './types.ts'
5
-
6
- /**
7
- * Supported SQL join kinds.
8
- */
9
- export type JoinType = 'inner' | 'left' | 'right'
10
-
11
- /**
12
- * Join configuration used in compiled select statements.
13
- */
14
- export type JoinClause = {
15
- type: JoinType
16
- table: AnyTable
17
- on: Predicate
18
- }
19
-
20
- /**
21
- * Selected output column with optional alias.
22
- */
23
- export type SelectColumn = {
24
- column: string
25
- alias: string
26
- }
27
-
28
- /**
29
- * Returning selection for write statements.
30
- */
31
- export type ReturningSelection = '*' | string[]
32
-
33
- /**
34
- * Canonical select statement shape consumed by adapters.
35
- */
36
- export type SelectOperation<table extends AnyTable = AnyTable> = {
37
- kind: 'select'
38
- table: table
39
- select: '*' | SelectColumn[]
40
- distinct: boolean
41
- joins: JoinClause[]
42
- where: Predicate[]
43
- groupBy: string[]
44
- having: Predicate[]
45
- orderBy: OrderByClause[]
46
- limit?: number
47
- offset?: number
48
- }
49
-
50
- /**
51
- * Canonical count statement shape consumed by adapters.
52
- */
53
- export type CountOperation<table extends AnyTable = AnyTable> = {
54
- kind: 'count'
55
- table: table
56
- joins: JoinClause[]
57
- where: Predicate[]
58
- groupBy: string[]
59
- having: Predicate[]
60
- }
61
-
62
- /**
63
- * Canonical exists statement shape consumed by adapters.
64
- */
65
- export type ExistsOperation<table extends AnyTable = AnyTable> = {
66
- kind: 'exists'
67
- table: table
68
- joins: JoinClause[]
69
- where: Predicate[]
70
- groupBy: string[]
71
- having: Predicate[]
72
- }
73
-
74
- /**
75
- * Canonical insert statement shape consumed by adapters.
76
- */
77
- export type InsertOperation<table extends AnyTable = AnyTable> = {
78
- kind: 'insert'
79
- table: table
80
- values: Record<string, unknown>
81
- returning?: ReturningSelection
82
- }
83
-
84
- /**
85
- * Canonical bulk-insert statement shape consumed by adapters.
86
- */
87
- export type InsertManyOperation<table extends AnyTable = AnyTable> = {
88
- kind: 'insertMany'
89
- table: table
90
- values: Record<string, unknown>[]
91
- returning?: ReturningSelection
92
- }
93
-
94
- /**
95
- * Canonical update statement shape consumed by adapters.
96
- */
97
- export type UpdateOperation<table extends AnyTable = AnyTable> = {
98
- kind: 'update'
99
- table: table
100
- changes: Record<string, unknown>
101
- where: Predicate[]
102
- returning?: ReturningSelection
103
- }
104
-
105
- /**
106
- * Canonical delete statement shape consumed by adapters.
107
- */
108
- export type DeleteOperation<table extends AnyTable = AnyTable> = {
109
- kind: 'delete'
110
- table: table
111
- where: Predicate[]
112
- returning?: ReturningSelection
113
- }
114
-
115
- /**
116
- * Canonical upsert statement shape consumed by adapters.
117
- */
118
- export type UpsertOperation<table extends AnyTable = AnyTable> = {
119
- kind: 'upsert'
120
- table: table
121
- values: Record<string, unknown>
122
- conflictTarget?: string[]
123
- update?: Record<string, unknown>
124
- returning?: ReturningSelection
125
- }
126
-
127
- /**
128
- * Raw SQL statement execution descriptor.
129
- */
130
- export type RawOperation = {
131
- kind: 'raw'
132
- sql: SqlStatement
133
- }
134
-
135
- /**
136
- * Union of all data-manipulation statement shapes.
137
- */
138
- export type DataManipulationOperation =
139
- | SelectOperation
140
- | CountOperation
141
- | ExistsOperation
142
- | InsertOperation
143
- | InsertManyOperation
144
- | UpdateOperation
145
- | DeleteOperation
146
- | UpsertOperation
147
- | RawOperation
148
-
149
- /**
150
- * Qualified table reference used in migration operations.
151
- */
152
- export type TableRef = {
153
- name: string
154
- schema?: string
155
- }
156
-
157
- /**
158
- * Referential actions supported by foreign key constraints.
159
- */
160
- export type ForeignKeyAction = 'cascade' | 'restrict' | 'set null' | 'set default' | 'no action'
161
-
162
- /**
163
- * Logical column type names used by schema definitions.
164
- */
165
- export type ColumnTypeName =
166
- | 'varchar'
167
- | 'text'
168
- | 'integer'
169
- | 'bigint'
170
- | 'decimal'
171
- | 'boolean'
172
- | 'uuid'
173
- | 'date'
174
- | 'time'
175
- | 'timestamp'
176
- | 'json'
177
- | 'binary'
178
- | 'enum'
179
-
180
- /**
181
- * Default value definition for a column.
182
- */
183
- export type ColumnDefault =
184
- | { kind: 'literal'; value: unknown }
185
- | { kind: 'now' }
186
- | { kind: 'sql'; expression: string }
187
-
188
- /**
189
- * Definition for a computed or generated column.
190
- */
191
- export type ColumnComputed = {
192
- expression: string
193
- stored: boolean
194
- }
195
-
196
- /** Options for configuring identity column generation. */
197
- export type IdentityOptions = {
198
- always?: boolean
199
- start?: number
200
- increment?: number
201
- }
202
-
203
- /** Foreign-key reference metadata declared on a column. */
204
- export type ColumnReference = {
205
- table: TableRef
206
- columns: string[]
207
- name: string
208
- onDelete?: ForeignKeyAction
209
- onUpdate?: ForeignKeyAction
210
- }
211
-
212
- /**
213
- * Check constraint declared on a column definition.
214
- */
215
- export type ColumnCheck = {
216
- expression: string
217
- name: string
218
- }
219
-
220
- /**
221
- * Normalized column definition used in schema operations.
222
- */
223
- export type ColumnDefinition = {
224
- type: ColumnTypeName
225
- nullable?: boolean
226
- primaryKey?: boolean
227
- unique?: boolean | { name?: string }
228
- default?: ColumnDefault
229
- computed?: ColumnComputed
230
- references?: ColumnReference
231
- checks?: ColumnCheck[]
232
- comment?: string
233
- length?: number
234
- precision?: number
235
- scale?: number
236
- unsigned?: boolean
237
- withTimezone?: boolean
238
- enumValues?: string[]
239
- autoIncrement?: boolean
240
- identity?: IdentityOptions
241
- collate?: string
242
- charset?: string
243
- }
244
-
245
- /**
246
- * Primary key constraint definition.
247
- */
248
- export type PrimaryKeyConstraint = {
249
- columns: string[]
250
- name: string
251
- }
252
-
253
- /**
254
- * Unique constraint definition.
255
- */
256
- export type UniqueConstraint = {
257
- columns: string[]
258
- name: string
259
- }
260
-
261
- /**
262
- * Check constraint definition.
263
- */
264
- export type CheckConstraint = {
265
- expression: string
266
- name: string
267
- }
268
-
269
- /**
270
- * Foreign key constraint definition.
271
- */
272
- export type ForeignKeyConstraint = {
273
- columns: string[]
274
- references: {
275
- table: TableRef
276
- columns: string[]
277
- }
278
- name: string
279
- onDelete?: ForeignKeyAction
280
- onUpdate?: ForeignKeyAction
281
- }
282
-
283
- /**
284
- * Index method used when creating an index.
285
- */
286
- export type IndexMethod = 'btree' | 'hash' | 'gin' | 'gist' | 'fulltext' | (string & {})
287
-
288
- /**
289
- * Index definition used in schema operations.
290
- */
291
- export type IndexDefinition = {
292
- table: TableRef
293
- name: string
294
- columns: string[]
295
- unique?: boolean
296
- where?: string
297
- using?: IndexMethod
298
- }
299
-
300
- /**
301
- * Operation that creates a new table.
302
- */
303
- export type CreateTableOperation = {
304
- kind: 'createTable'
305
- table: TableRef
306
- ifNotExists?: boolean
307
- columns: Record<string, ColumnDefinition>
308
- primaryKey?: PrimaryKeyConstraint
309
- uniques?: UniqueConstraint[]
310
- checks?: CheckConstraint[]
311
- foreignKeys?: ForeignKeyConstraint[]
312
- comment?: string
313
- }
314
-
315
- /**
316
- * Alter-table change that adds a column.
317
- */
318
- export type AddColumnChange = {
319
- kind: 'addColumn'
320
- column: string
321
- definition: ColumnDefinition
322
- }
323
-
324
- /**
325
- * Alter-table change that replaces a column definition.
326
- */
327
- export type ChangeColumnChange = {
328
- kind: 'changeColumn'
329
- column: string
330
- definition: ColumnDefinition
331
- }
332
-
333
- /**
334
- * Alter-table change that renames a column.
335
- */
336
- export type RenameColumnChange = {
337
- kind: 'renameColumn'
338
- from: string
339
- to: string
340
- }
341
-
342
- /**
343
- * Alter-table change that drops a column.
344
- */
345
- export type DropColumnChange = {
346
- kind: 'dropColumn'
347
- column: string
348
- ifExists?: boolean
349
- }
350
-
351
- /**
352
- * Alter-table change that adds a primary key.
353
- */
354
- export type AddPrimaryKeyChange = {
355
- kind: 'addPrimaryKey'
356
- constraint: PrimaryKeyConstraint
357
- }
358
-
359
- /**
360
- * Alter-table change that drops a primary key.
361
- */
362
- export type DropPrimaryKeyChange = {
363
- kind: 'dropPrimaryKey'
364
- name: string
365
- }
366
-
367
- /**
368
- * Alter-table change that adds a unique constraint.
369
- */
370
- export type AddUniqueChange = {
371
- kind: 'addUnique'
372
- constraint: UniqueConstraint
373
- }
374
-
375
- /**
376
- * Alter-table change that drops a unique constraint.
377
- */
378
- export type DropUniqueChange = {
379
- kind: 'dropUnique'
380
- name: string
381
- }
382
-
383
- /**
384
- * Alter-table change that adds a foreign key constraint.
385
- */
386
- export type AddForeignKeyChange = {
387
- kind: 'addForeignKey'
388
- constraint: ForeignKeyConstraint
389
- }
390
-
391
- /**
392
- * Alter-table change that drops a foreign key constraint.
393
- */
394
- export type DropForeignKeyChange = {
395
- kind: 'dropForeignKey'
396
- name: string
397
- }
398
-
399
- /**
400
- * Alter-table change that adds a check constraint.
401
- */
402
- export type AddCheckChange = {
403
- kind: 'addCheck'
404
- constraint: CheckConstraint
405
- }
406
-
407
- /**
408
- * Alter-table change that drops a check constraint.
409
- */
410
- export type DropCheckChange = {
411
- kind: 'dropCheck'
412
- name: string
413
- }
414
-
415
- /**
416
- * Alter-table change that updates a table comment.
417
- */
418
- export type SetTableCommentChange = {
419
- kind: 'setTableComment'
420
- comment: string
421
- }
422
-
423
- /**
424
- * Union of supported `alterTable` changes.
425
- */
426
- export type AlterTableChange =
427
- | AddColumnChange
428
- | ChangeColumnChange
429
- | RenameColumnChange
430
- | DropColumnChange
431
- | AddPrimaryKeyChange
432
- | DropPrimaryKeyChange
433
- | AddUniqueChange
434
- | DropUniqueChange
435
- | AddForeignKeyChange
436
- | DropForeignKeyChange
437
- | AddCheckChange
438
- | DropCheckChange
439
- | SetTableCommentChange
440
-
441
- /**
442
- * Operation that applies one or more table changes.
443
- */
444
- export type AlterTableOperation = {
445
- kind: 'alterTable'
446
- table: TableRef
447
- changes: AlterTableChange[]
448
- ifExists?: boolean
449
- }
450
-
451
- /**
452
- * Operation that renames a table.
453
- */
454
- export type RenameTableOperation = {
455
- kind: 'renameTable'
456
- from: TableRef
457
- to: TableRef
458
- }
459
-
460
- /**
461
- * Operation that drops a table.
462
- */
463
- export type DropTableOperation = {
464
- kind: 'dropTable'
465
- table: TableRef
466
- ifExists?: boolean
467
- cascade?: boolean
468
- }
469
-
470
- /**
471
- * Operation that creates an index.
472
- */
473
- export type CreateIndexOperation = {
474
- kind: 'createIndex'
475
- index: IndexDefinition
476
- ifNotExists?: boolean
477
- }
478
-
479
- /**
480
- * Operation that drops an index.
481
- */
482
- export type DropIndexOperation = {
483
- kind: 'dropIndex'
484
- table: TableRef
485
- name: string
486
- ifExists?: boolean
487
- }
488
-
489
- /**
490
- * Operation that renames an index.
491
- */
492
- export type RenameIndexOperation = {
493
- kind: 'renameIndex'
494
- table: TableRef
495
- from: string
496
- to: string
497
- }
498
-
499
- /**
500
- * Operation that adds a table-level foreign key.
501
- */
502
- export type AddForeignKeyOperation = {
503
- kind: 'addForeignKey'
504
- table: TableRef
505
- constraint: ForeignKeyConstraint
506
- }
507
-
508
- /**
509
- * Operation that drops a table-level foreign key.
510
- */
511
- export type DropForeignKeyOperation = {
512
- kind: 'dropForeignKey'
513
- table: TableRef
514
- name: string
515
- }
516
-
517
- /**
518
- * Operation that adds a table-level check constraint.
519
- */
520
- export type AddCheckOperation = {
521
- kind: 'addCheck'
522
- table: TableRef
523
- constraint: CheckConstraint
524
- }
525
-
526
- /**
527
- * Operation that drops a table-level check constraint.
528
- */
529
- export type DropCheckOperation = {
530
- kind: 'dropCheck'
531
- table: TableRef
532
- name: string
533
- }
534
-
535
- /**
536
- * Union of schema and migration operations understood by adapters.
537
- */
538
- export type DataMigrationOperation =
539
- | CreateTableOperation
540
- | AlterTableOperation
541
- | RenameTableOperation
542
- | DropTableOperation
543
- | CreateIndexOperation
544
- | DropIndexOperation
545
- | RenameIndexOperation
546
- | AddForeignKeyOperation
547
- | DropForeignKeyOperation
548
- | AddCheckOperation
549
- | DropCheckOperation
550
- | RawOperation
551
-
552
- /**
553
- * Opaque transaction handle supplied by adapters.
554
- */
555
- export type TransactionToken = {
556
- id: string
557
- metadata?: Record<string, unknown>
558
- }
559
-
560
- /**
561
- * Transaction hints that adapters may apply when supported by the dialect.
562
- */
563
- export type TransactionOptions = {
564
- isolationLevel?: 'read uncommitted' | 'read committed' | 'repeatable read' | 'serializable'
565
- readOnly?: boolean
566
- }
567
-
568
- /**
569
- * Adapter execution request payload.
570
- */
571
- export type DataManipulationRequest = {
572
- operation: DataManipulationOperation
573
- transaction?: TransactionToken
574
- }
575
-
576
- /**
577
- * Adapter migration request payload.
578
- */
579
- export type DataMigrationRequest = {
580
- operation: DataMigrationOperation
581
- transaction?: TransactionToken
582
- }
583
-
584
- /**
585
- * Adapter data-manipulation result payload.
586
- */
587
- export type DataManipulationResult = {
588
- rows?: Record<string, unknown>[]
589
- affectedRows?: number
590
- insertId?: unknown
591
- }
592
-
593
- /**
594
- * Adapter data-migration result payload.
595
- */
596
- export type DataMigrationResult = {
597
- /**
598
- * Number of migration operations processed by the adapter call.
599
- */
600
- affectedOperations?: number
601
- }
602
-
603
- /**
604
- * Declares adapter feature support.
605
- */
606
- export type AdapterCapabilities = {
607
- returning: boolean
608
- savepoints: boolean
609
- upsert: boolean
610
- transactionalDdl: boolean
611
- migrationLock: boolean
612
- }
613
-
614
- /**
615
- * Partial capabilities used to override adapter defaults.
616
- */
617
- export type AdapterCapabilityOverrides = Pretty<Partial<AdapterCapabilities>>
618
-
619
- /**
620
- * Runtime contract implemented by concrete database adapters.
621
- */
622
- export interface DatabaseAdapter {
623
- /** Database dialect name exposed by the adapter. */
624
- dialect: string
625
- /** Feature flags describing the adapter's supported behaviors. */
626
- capabilities: AdapterCapabilities
627
- /** Compiles a data or migration operation into executable SQL statements. */
628
- compileSql(operation: DataManipulationOperation | DataMigrationOperation): SqlStatement[]
629
- /** Executes a data-manipulation request. */
630
- execute(request: DataManipulationRequest): Promise<DataManipulationResult>
631
- /** Executes a migration request. */
632
- migrate(request: DataMigrationRequest): Promise<DataMigrationResult>
633
- /** Checks whether a table exists. */
634
- hasTable(table: TableRef, transaction?: TransactionToken): Promise<boolean>
635
- /** Checks whether a column exists on a table. */
636
- hasColumn(table: TableRef, column: string, transaction?: TransactionToken): Promise<boolean>
637
- /** Starts a new database transaction. */
638
- beginTransaction(options?: TransactionOptions): Promise<TransactionToken>
639
- /** Commits an open transaction. */
640
- commitTransaction(token: TransactionToken): Promise<void>
641
- /** Rolls back an open transaction. */
642
- rollbackTransaction(token: TransactionToken): Promise<void>
643
- /** Creates a savepoint inside an open transaction. */
644
- createSavepoint(token: TransactionToken, name: string): Promise<void>
645
- /** Rolls back to a previously created savepoint. */
646
- rollbackToSavepoint(token: TransactionToken, name: string): Promise<void>
647
- /** Releases a previously created savepoint. */
648
- releaseSavepoint(token: TransactionToken, name: string): Promise<void>
649
- /** Acquires the adapter's migration lock when supported. */
650
- acquireMigrationLock?(): Promise<void>
651
- /** Releases the adapter's migration lock when supported. */
652
- releaseMigrationLock?(): Promise<void>
653
- }
@@ -1,25 +0,0 @@
1
- const migrationFilenamePattern = /^(\d{14})_(.+)\.(?:m?ts|m?js|cts|cjs)$/
2
-
3
- /**
4
- * Parses a migration filename into `{ id, name }`.
5
- *
6
- * Expected format: `YYYYMMDDHHmmss_name.(ts|js|mts|mjs|cts|cjs)`.
7
- * @param filename Migration file basename.
8
- * @returns Parsed migration id and name.
9
- */
10
- export function parseMigrationFilename(filename: string): { id: string; name: string } {
11
- let match = filename.match(migrationFilenamePattern)
12
-
13
- if (!match) {
14
- throw new Error(
15
- 'Invalid migration filename "' +
16
- filename +
17
- '". Expected format YYYYMMDDHHmmss_name.ts (or .js/.mts/.mjs/.cts/.cjs)',
18
- )
19
- }
20
-
21
- return {
22
- id: match[1],
23
- name: match[2],
24
- }
25
- }