@remix-run/data-table 0.3.0 → 0.5.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 (83) hide show
  1. package/README.md +217 -78
  2. package/dist/cli.d.ts +76 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +78 -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/database/execution-context.d.ts +5 -5
  11. package/dist/lib/database/execution-context.d.ts.map +1 -1
  12. package/dist/lib/database/execution-context.js +1 -0
  13. package/dist/lib/database/helpers.js +6 -6
  14. package/dist/lib/database/query-execution.d.ts.map +1 -1
  15. package/dist/lib/database/query-execution.js +17 -17
  16. package/dist/lib/database/relations.js +5 -5
  17. package/dist/lib/database/write-lifecycle.d.ts +2 -2
  18. package/dist/lib/database/write-lifecycle.d.ts.map +1 -1
  19. package/dist/lib/database/write-lifecycle.js +5 -5
  20. package/dist/lib/database.d.ts +74 -59
  21. package/dist/lib/database.d.ts.map +1 -1
  22. package/dist/lib/database.js +176 -83
  23. package/dist/lib/{adapter.d.ts → driver.d.ts} +46 -48
  24. package/dist/lib/driver.d.ts.map +1 -0
  25. package/dist/lib/errors.d.ts +2 -2
  26. package/dist/lib/errors.d.ts.map +1 -1
  27. package/dist/lib/errors.js +4 -4
  28. package/dist/lib/migrations/journal-store.d.ts +6 -6
  29. package/dist/lib/migrations/journal-store.d.ts.map +1 -1
  30. package/dist/lib/migrations/journal-store.js +20 -11
  31. package/dist/lib/migrations/runner.d.ts +12 -19
  32. package/dist/lib/migrations/runner.d.ts.map +1 -1
  33. package/dist/lib/migrations/runner.js +152 -130
  34. package/dist/lib/migrations-node.d.ts +19 -1
  35. package/dist/lib/migrations-node.d.ts.map +1 -1
  36. package/dist/lib/migrations-node.js +22 -1
  37. package/dist/lib/migrations.d.ts +55 -20
  38. package/dist/lib/migrations.d.ts.map +1 -1
  39. package/dist/lib/operators.d.ts +8 -7
  40. package/dist/lib/operators.d.ts.map +1 -1
  41. package/dist/lib/operators.js +15 -11
  42. package/dist/lib/query.d.ts +1 -1
  43. package/dist/lib/query.d.ts.map +1 -1
  44. package/dist/lib/query.js +4 -4
  45. package/dist/lib/sql-helpers.d.ts +1 -1
  46. package/dist/lib/sql-helpers.d.ts.map +1 -1
  47. package/dist/lib/sql.d.ts +1 -1
  48. package/dist/lib/sql.js +1 -1
  49. package/dist/lib/table.d.ts +1 -1
  50. package/dist/lib/table.d.ts.map +1 -1
  51. package/dist/lib/table.js +5 -5
  52. package/dist/migrations/node.d.ts +1 -1
  53. package/dist/migrations/node.d.ts.map +1 -1
  54. package/dist/migrations/node.js +1 -1
  55. package/dist/migrations.d.ts +1 -2
  56. package/dist/migrations.d.ts.map +1 -1
  57. package/dist/migrations.js +2 -3
  58. package/dist/operators.js +1 -1
  59. package/dist/sql-helpers.js +1 -1
  60. package/package.json +13 -9
  61. package/src/cli.ts +179 -0
  62. package/src/index.ts +19 -20
  63. package/src/lib/column.ts +1 -1
  64. package/src/lib/database/execution-context.ts +10 -6
  65. package/src/lib/database/helpers.ts +1 -1
  66. package/src/lib/database/query-execution.ts +15 -11
  67. package/src/lib/database/write-lifecycle.ts +4 -4
  68. package/src/lib/database.ts +223 -96
  69. package/src/lib/{adapter.ts → driver.ts} +48 -48
  70. package/src/lib/errors.ts +4 -4
  71. package/src/lib/migrations/journal-store.ts +21 -11
  72. package/src/lib/migrations/runner.ts +201 -148
  73. package/src/lib/migrations-node.ts +23 -1
  74. package/src/lib/migrations.ts +58 -19
  75. package/src/lib/operators.ts +24 -11
  76. package/src/lib/query.ts +1 -1
  77. package/src/lib/sql-helpers.ts +1 -1
  78. package/src/lib/sql.ts +1 -1
  79. package/src/lib/table.ts +1 -1
  80. package/src/migrations/node.ts +1 -1
  81. package/src/migrations.ts +3 -4
  82. package/dist/lib/adapter.d.ts.map +0 -1
  83. /package/dist/lib/{adapter.js → driver.js} +0 -0
package/README.md CHANGED
@@ -4,13 +4,14 @@ Typed relational query toolkit for JavaScript runtimes.
4
4
 
5
5
  ## Features
6
6
 
7
- - **One API Across Databases**: Same query and relation APIs across PostgreSQL, MySQL, and SQLite adapters
7
+ - **One API Across Databases**: Same query and relation APIs across PostgreSQL, MySQL, and SQLite
8
8
  - **One Query API**: Build reusable `Query` objects with `query(table)` and execute them with `db.exec(...)`, or use `db.query(table)` as shorthand
9
9
  - **Type-Safe Reads**: Typed `select`, relation loading, and predicate keys
10
10
  - **Optional Runtime Validation**: Add `validate(context)` at the table level for create/update validation and coercion
11
11
  - **Relation-First Queries**: `hasMany`, `hasOne`, `belongsTo`, `hasManyThrough`, and nested eager loading
12
12
  - **Safe Scoped Writes**: `update`/`delete` with `orderBy`/`limit` run safely in a transaction
13
13
  - **First-Class Migrations**: Plain SQL `up.sql`/`down.sql` files with a journaling runner and dry-run planning
14
+ - **Database Lifecycle Commands**: Wipe, migrate, rollback, inspect, seed, and reset through `remix db`
14
15
  - **Raw SQL Escape Hatch**: Execute SQL directly with `db.exec(sql\`...\`)`
15
16
 
16
17
  `data-table` gives you two complementary APIs:
@@ -33,12 +34,11 @@ npm i mysql2
33
34
 
34
35
  ## Setup
35
36
 
36
- Define tables once, then create a database with an adapter.
37
+ Define tables once, then create a database for your SQL dialect.
37
38
 
38
39
  ```ts
39
- import { Pool } from 'pg'
40
- import { column as c, createDatabase, hasMany, query, table } from 'remix/data-table'
41
- import { createPostgresDatabaseAdapter } from 'remix/data-table/postgres'
40
+ import { column as c, hasMany, query, table } from 'remix/data-table'
41
+ import { createPostgresDatabase } from 'remix/data-table/postgres'
42
42
 
43
43
  let users = table({
44
44
  name: 'users',
@@ -63,8 +63,7 @@ let orders = table({
63
63
 
64
64
  let userOrders = hasMany(users, orders)
65
65
 
66
- let pool = new Pool({ connectionString: process.env.DATABASE_URL })
67
- let db = createDatabase(createPostgresDatabaseAdapter(pool))
66
+ let db = createPostgresDatabase({ connectionString: process.env.DATABASE_URL })
68
67
  ```
69
68
 
70
69
  ## Query Objects
@@ -201,7 +200,7 @@ let createManyResult = await db.createMany(orders, [
201
200
  { id: 'o_102', user_id: 'u_003', status: 'pending', total: 48.5, created_at: Date.now() },
202
201
  ])
203
202
 
204
- // Return inserted rows (requires adapter RETURNING support)
203
+ // Return inserted rows (requires database RETURNING support)
205
204
  let insertedRows = await db.createMany(
206
205
  orders,
207
206
  [{ id: 'o_103', user_id: 'u_003', status: 'pending', total: 12, created_at: Date.now() }],
@@ -249,8 +248,7 @@ Return behavior:
249
248
 
250
249
  ### Validation and Lifecycle
251
250
 
252
- Validation is optional and table-scoped. Define `validate(context)` to validate/coerce write
253
- payloads, and add lifecycle callbacks when you need custom read/write/delete behavior.
251
+ Validation is optional and table-scoped. Define `validate(context)` to validate/coerce write payloads, and add lifecycle callbacks when you need custom read/write/delete behavior.
254
252
 
255
253
  ```ts
256
254
  import { column as c, fail, table } from 'remix/data-table'
@@ -344,10 +342,7 @@ await db.transaction(async (tx) => {
344
342
 
345
343
  ## Migrations
346
344
 
347
- `data-table` ships a SQL-first migration system under `remix/data-table/migrations`. Each migration
348
- is a directory containing hand-written `up.sql` and (optionally) `down.sql`. The runner journals
349
- applied migrations, detects checksum drift, and wraps each migration in a transaction when the
350
- adapter supports transactional DDL.
345
+ `data-table` ships a SQL-first migration system under `remix/data-table/migrations`. Each migration is a directory containing hand-written `up.sql` and (optionally) `down.sql`. The runner journals applied migrations, detects checksum drift and missing applied migrations, and wraps each migration in a transaction when the database supports transactional DDL.
351
346
 
352
347
  ### Example Setup
353
348
 
@@ -361,7 +356,7 @@ app/
361
356
  20260301113000_add_user_status/
362
357
  up.sql
363
358
  down.sql
364
- migrate.ts
359
+ db.ts
365
360
  ```
366
361
 
367
362
  - Keep migration directories in one parent directory (for example `app/db/migrations`).
@@ -392,92 +387,133 @@ drop table if exists users;
392
387
 
393
388
  ### Multi-Statement Driver Configuration
394
389
 
395
- The runner sends each migration to the adapter as a single multi-statement script. Make sure the
396
- underlying driver accepts multiple statements:
390
+ The runner sends each migration to the database as a single multi-statement script. Make sure the underlying driver accepts multiple statements:
397
391
 
398
392
  - `better-sqlite3`: works out of the box (`db.exec`).
399
393
  - `pg`: works out of the box when no parameter array is passed.
400
394
  - `mysql2`: requires `multipleStatements: true` on the connection/pool.
401
395
 
402
396
  ```ts
403
- import { createPool } from 'mysql2/promise'
397
+ import { createMysqlDatabase } from 'remix/data-table/mysql'
404
398
 
405
- let pool = createPool({
399
+ let db = createMysqlDatabase({
406
400
  uri: process.env.DATABASE_URL,
407
401
  multipleStatements: true,
408
402
  })
409
403
  ```
410
404
 
411
- ### Runner Script Example
405
+ ### Database Command Configuration
406
+
407
+ Configure `remix db` statically in `remix.json`. Connection secrets are read from the named
408
+ environment variable at command runtime, and paths are resolved relative to `remix.json`:
409
+
410
+ ```jsonc
411
+ {
412
+ "$schema": "./node_modules/remix/schema/remix.json",
413
+ "db": {
414
+ "adapter": {
415
+ "type": "postgres",
416
+ "connectionString": { "env": "DATABASE_URL" },
417
+ },
418
+ "migrations": {
419
+ "directory": "./db/migrations",
420
+ "journalTable": "app_migrations",
421
+ },
422
+ "seed": "./db/seed.sql",
423
+ },
424
+ }
425
+ ```
412
426
 
413
- In `app/db/migrate.ts`:
427
+ Application runtime setup remains application-owned. It does not need to expose any special
428
+ exports for the CLI.
414
429
 
415
- ```ts
416
- import path from 'node:path'
417
- import { Pool } from 'pg'
418
- import { createPostgresDatabaseAdapter } from 'remix/data-table/postgres'
419
- import { createMigrationRunner } from 'remix/data-table/migrations'
420
- import { loadMigrations } from 'remix/data-table/migrations/node'
430
+ Run lifecycle commands through the Remix CLI:
421
431
 
422
- let directionArg = process.argv[2] ?? 'up'
423
- let direction = directionArg === 'down' ? 'down' : 'up'
424
- let to = process.argv[3]
432
+ ```sh
433
+ remix db status
434
+ remix db migrate
435
+ remix db migrate --to 20260301113000_add_user_status
436
+ remix db rollback
437
+ remix db rollback --step 2
438
+ remix db rollback --to 20260301113000_add_user_status
439
+ remix db rollback --dry-run
440
+ remix db seed
441
+ remix db reset --force
442
+ remix db wipe --force
443
+ ```
425
444
 
426
- let pool = new Pool({ connectionString: process.env.DATABASE_URL })
427
- let adapter = createPostgresDatabaseAdapter(pool)
428
- let migrations = await loadMigrations(path.resolve('app/db/migrations'))
429
- let runner = createMigrationRunner(adapter, migrations)
445
+ `rollback` reverts the most recently applied migration by default. Bound it with either `--step <count>` or `--to <migration>`, which reverts through the target migration inclusively. Migration targets accept a bare migration id (`20260301113000`) or the full directory name (`20260301113000_add_user_status`). Use `--dry-run` to report what would be reverted without changing the database.
430
446
 
431
- try {
432
- let result = direction === 'up' ? await runner.up({ to }) : await runner.down({ to })
433
- console.log(direction + ' complete', {
434
- applied: result.applied.map((entry) => entry.id),
435
- reverted: result.reverted.map((entry) => entry.id),
436
- })
437
- } finally {
438
- await pool.end()
439
- }
440
- ```
447
+ `remix db status` reports applied migrations whose files are no longer present as `missing`. If the journal table does not exist, it reports every migration as pending without creating the table. Forward migration runs stop before executing SQL when an applied journal entry is missing from the current migration set. Rollbacks skip those orphaned journal entries so migrations that are still present can be reverted.
441
448
 
442
- Use `journalTable` if you want a custom migrations journal table name:
449
+ `wipe` and `reset` are destructive. They require a config-backed database so it can close, recreate, and reconnect to the configured database.
450
+
451
+ ### Programmatic Migrations
452
+
453
+ Load migrations and pass the resolved collection directly to the database:
443
454
 
444
455
  ```ts
445
- let runner = createMigrationRunner(adapter, migrations, {
446
- journalTable: 'app_migrations',
447
- })
456
+ import { loadMigrations } from 'remix/data-table/migrations/node'
457
+
458
+ let migrations = await loadMigrations('./db/migrations')
459
+ await db.migrate(migrations)
448
460
  ```
449
461
 
450
- Run it with your runtime, for example:
462
+ `Database.migrate()` supports forward and backward directions, a target or step bound, dry runs,
463
+ and a custom journal table:
451
464
 
452
- ```sh
453
- node ./app/db/migrate.ts up
454
- node ./app/db/migrate.ts up 20260301113000
455
- node ./app/db/migrate.ts down
456
- node ./app/db/migrate.ts down 20260228090000
465
+ ```ts
466
+ await db.migrate(migrations)
467
+ await db.migrate(migrations, { to: '20260301113000_add_user_status' })
468
+ await db.migrate(migrations, { step: 1 })
469
+ await db.migrate(migrations, { direction: 'down' })
470
+ await db.migrate(migrations, { direction: 'down', to: '20260301113000' })
471
+ await db.migrate(migrations, { direction: 'down', step: 1 })
472
+ await db.migrate(migrations, { journalTable: 'app_migrations' })
473
+
474
+ let plan = await db.migrate(migrations, { dryRun: true })
475
+ for (let script of plan.sql) console.log(script)
457
476
  ```
458
477
 
459
- Use `step` for bounded rollforward/rollback behavior instead of a target id:
478
+ `to` and `step` are mutually exclusive. Omit `journalTable` to use `data_table_migrations`.
479
+
480
+ Hosts that embed the database CLI can invoke the same rollback behavior through `runRemixDb()`:
460
481
 
461
482
  ```ts
462
- await runner.up({ step: 1 })
463
- await runner.down({ step: 1 })
483
+ import { runRemixDb } from 'remix/data-table/cli'
484
+
485
+ await runRemixDb({ command: 'rollback', db, migrations })
486
+ await runRemixDb({ command: 'rollback', db, migrations, step: 2, dryRun: true })
464
487
  ```
465
488
 
466
- `to` and `step` are mutually exclusive within a single run.
489
+ Database drivers with migration locking run the complete migration and journal lifecycle through the
490
+ connection that owns the lock. This keeps advisory locks correctly paired when the driver uses a
491
+ connection pool, including pools configured with a single connection.
467
492
 
468
- Use `dryRun` to inspect the SQL plan without applying or journaling anything:
493
+ Read status separately, or rebuild a database with migrations and an optional seed. A seed is a
494
+ function that receives the database; `loadSeed()` builds one from a SQL file:
469
495
 
470
496
  ```ts
471
- let plan = await runner.up({ dryRun: true })
472
- for (let script of plan.sql) {
473
- console.log(script)
474
- }
497
+ import { loadSeed } from 'remix/data-table/migrations/node'
498
+
499
+ let seed = await loadSeed('./db/seed.sql')
500
+
501
+ let status = await db.migrationStatus(migrations, { journalTable: 'app_migrations' })
502
+ await db.reset({ migrations })
503
+ await db.reset({ migrations, seed })
504
+ await db.reset({ migrations, seed, journalTable: 'app_migrations' })
505
+ ```
506
+
507
+ When a lifecycle command is the last thing a process does, close database-owned connections so
508
+ the process can exit:
509
+
510
+ ```ts
511
+ await db.close()
475
512
  ```
476
513
 
477
514
  ### Transaction Modes
478
515
 
479
- By default each migration is wrapped in a transaction when the adapter supports transactional DDL.
480
- Override per migration with a directive on the first non-blank line of `up.sql`:
516
+ By default each migration is wrapped in a transaction when the database supports transactional DDL. Override per migration with a directive on the first non-blank line of `up.sql`:
481
517
 
482
518
  ```sql
483
519
  -- data-table/transaction: none
@@ -486,20 +522,18 @@ create index concurrently users_email_active_idx on users (email) where status =
486
522
 
487
523
  Supported modes:
488
524
 
489
- - `auto` (default): wrap when the adapter supports transactional DDL.
490
- - `required`: wrap; the runner throws if the adapter cannot support it.
491
- - `none`: never wrap. Use this for statements like postgres `CREATE INDEX CONCURRENTLY` that
492
- cannot run inside a transaction.
525
+ - `auto` (default): wrap when the database supports transactional DDL.
526
+ - `required`: wrap; the runner throws if the database cannot support it.
527
+ - `none`: never wrap. Use this for statements like postgres `CREATE INDEX CONCURRENTLY` that cannot run inside a transaction.
493
528
 
494
- You can also set `transaction` directly on a `MigrationDescriptor` when registering migrations
495
- programmatically.
529
+ You can also set `transaction` directly on a `MigrationDescriptor` when registering migrations programmatically.
496
530
 
497
531
  ### Programmatic Registration
498
532
 
499
533
  For non-filesystem runtimes, register migrations directly:
500
534
 
501
535
  ```ts
502
- import { createMigrationRegistry, createMigrationRunner } from 'remix/data-table/migrations'
536
+ import { createMigrationRegistry } from 'remix/data-table/migrations'
503
537
 
504
538
  let registry = createMigrationRegistry()
505
539
  registry.register({
@@ -509,8 +543,7 @@ registry.register({
509
543
  down: 'drop table users;',
510
544
  })
511
545
 
512
- let runner = createMigrationRunner(adapter, registry)
513
- await runner.up()
546
+ await db.migrate(registry)
514
547
  ```
515
548
 
516
549
  ## Raw SQL Escape Hatch
@@ -538,14 +571,120 @@ let result = await db.exec(sql`
538
571
  `)
539
572
  ```
540
573
 
541
- `sql` keeps values parameterized per adapter dialect, so you can avoid manual string concatenation.
574
+ `sql` keeps values parameterized for the database dialect, so you can avoid manual string concatenation.
575
+
576
+ ## Custom Database Drivers
577
+
578
+ Applications normally use one of the concrete SQLite, PostgreSQL, or MySQL factories. Integration
579
+ packages can add another dialect by implementing `DatabaseDriver` and extending `Database`. This
580
+ complete skeleton assumes the underlying client exposes the operations needed by the driver:
581
+
582
+ ```ts
583
+ import {
584
+ Database,
585
+ type DatabaseDriver,
586
+ type DataManipulationRequest,
587
+ type DataManipulationResult,
588
+ type DatabaseOptions,
589
+ type TableRef,
590
+ type TransactionOptions,
591
+ type TransactionToken,
592
+ } from 'remix/data-table'
593
+ import type { AcmeClient } from 'acme-database'
594
+
595
+ class AcmeDriver implements DatabaseDriver<'acme'> {
596
+ readonly dialect = 'acme'
597
+ readonly capabilities = {
598
+ returning: true,
599
+ savepoints: true,
600
+ upsert: true,
601
+ transactionalDdl: true,
602
+ migrationLock: false,
603
+ } as const
604
+
605
+ #client: AcmeClient
606
+
607
+ constructor(client: AcmeClient) {
608
+ this.#client = client
609
+ }
610
+
611
+ execute(request: DataManipulationRequest): Promise<DataManipulationResult> {
612
+ return this.#client.execute(request)
613
+ }
614
+
615
+ executeScript(sql: string, transaction?: TransactionToken): Promise<void> {
616
+ return this.#client.executeScript(sql, transaction)
617
+ }
618
+
619
+ beginTransaction(options?: TransactionOptions): Promise<TransactionToken> {
620
+ return this.#client.beginTransaction(options)
621
+ }
622
+
623
+ commitTransaction(transaction: TransactionToken): Promise<void> {
624
+ return this.#client.commitTransaction(transaction)
625
+ }
626
+
627
+ rollbackTransaction(transaction: TransactionToken): Promise<void> {
628
+ return this.#client.rollbackTransaction(transaction)
629
+ }
630
+
631
+ hasTable(table: TableRef, transaction?: TransactionToken): Promise<boolean> {
632
+ return this.#client.hasTable(table, transaction)
633
+ }
634
+
635
+ hasColumn(table: TableRef, column: string, transaction?: TransactionToken): Promise<boolean> {
636
+ return this.#client.hasColumn(table, column, transaction)
637
+ }
638
+
639
+ createSavepoint(transaction: TransactionToken, name: string): Promise<void> {
640
+ return this.#client.createSavepoint(transaction, name)
641
+ }
642
+
643
+ rollbackToSavepoint(transaction: TransactionToken, name: string): Promise<void> {
644
+ return this.#client.rollbackToSavepoint(transaction, name)
645
+ }
646
+
647
+ releaseSavepoint(transaction: TransactionToken, name: string): Promise<void> {
648
+ return this.#client.releaseSavepoint(transaction, name)
649
+ }
650
+
651
+ wipe(): Promise<void> {
652
+ return this.#client.wipe()
653
+ }
654
+
655
+ close(): void | Promise<void> {
656
+ return this.#client.close()
657
+ }
658
+ }
659
+
660
+ export class AcmeDatabase extends Database<'acme'> {
661
+ constructor(client: AcmeClient, options?: DatabaseOptions) {
662
+ super(new AcmeDriver(client), options)
663
+ }
664
+ }
665
+ ```
666
+
667
+ `Database` supplies queries, CRUD helpers, relations, transactions, and migrations. The private
668
+ driver owns SQL execution and connection lifecycle. A driver provides:
669
+
670
+ - `dialect` and an immutable `capabilities` object
671
+ - `execute()` and `executeScript()`
672
+ - `hasTable()`, `hasColumn()`, `wipe()`, and idempotent `close()`
673
+ - transaction and savepoint lifecycle methods using opaque `TransactionToken` values
674
+
675
+ Drivers whose capabilities report `migrationLock: true` also implement `withMigrationLock()` and
676
+ run its callback with a `DatabaseDriver` bound to the connection that owns the lock.
677
+
678
+ `Database`, `DatabaseDriver`, and the supporting driver protocol types are all exported directly
679
+ from `remix/data-table`. Transaction callbacks receive a transaction-scoped `Database`, so custom
680
+ subclass methods are intentionally unavailable inside the callback.
542
681
 
543
682
  ## Related Packages
544
683
 
545
684
  - [`data-schema`](https://github.com/remix-run/remix/tree/main/packages/data-schema) - Optional schema parsing you can use inside table-level `validate(...)` hooks
546
- - [`data-table-postgres`](https://github.com/remix-run/remix/tree/main/packages/data-table-postgres) - PostgreSQL adapter
547
- - [`data-table-mysql`](https://github.com/remix-run/remix/tree/main/packages/data-table-mysql) - MySQL adapter
548
- - [`data-table-sqlite`](https://github.com/remix-run/remix/tree/main/packages/data-table-sqlite) - SQLite adapter
685
+ - [`data-table-postgres`](https://github.com/remix-run/remix/tree/main/packages/data-table-postgres) - PostgreSQL database integration
686
+ - [`data-table-mysql`](https://github.com/remix-run/remix/tree/main/packages/data-table-mysql) - MySQL database integration
687
+ - [`data-table-sqlite`](https://github.com/remix-run/remix/tree/main/packages/data-table-sqlite) - SQLite database integration
549
688
 
550
689
  ## License
551
690
 
package/dist/cli.d.ts ADDED
@@ -0,0 +1,76 @@
1
+ import type { Database } from './lib/database.ts';
2
+ import type { Migrations, Seed } from './lib/migrations.ts';
3
+ interface DatabaseCommandOptions {
4
+ /** Database instance used by the command. */
5
+ db: Database;
6
+ }
7
+ type RollbackBoundOptions = {
8
+ /**
9
+ * Reverts back through this migration, inclusive. Accepts a bare
10
+ * migration id or the full `id_name` directory form.
11
+ */
12
+ to: string;
13
+ step?: never;
14
+ } | {
15
+ to?: never;
16
+ /** Reverts this many migrations. Defaults to `1`. */
17
+ step?: number;
18
+ };
19
+ type RollbackCommandOptions = DatabaseCommandOptions & RollbackBoundOptions & {
20
+ /** Reverts applied migrations, newest first. */
21
+ command: 'rollback';
22
+ /** Migrations to revert. */
23
+ migrations: Migrations;
24
+ /** Reports what would be reverted without running it. */
25
+ dryRun?: boolean;
26
+ /** Migration journal table. */
27
+ journalTable?: string;
28
+ };
29
+ /** Structured invocation options accepted by {@link runRemixDb}. */
30
+ export type RunRemixDbOptions = (DatabaseCommandOptions & {
31
+ /** Applies pending migrations. */
32
+ command: 'migrate';
33
+ /** Migrations to apply. */
34
+ migrations: Migrations;
35
+ /**
36
+ * Stops after applying this migration. Accepts a bare migration id or
37
+ * the full `id_name` directory form.
38
+ */
39
+ to?: string;
40
+ /** Migration journal table. */
41
+ journalTable?: string;
42
+ }) | RollbackCommandOptions | (DatabaseCommandOptions & {
43
+ /** Wipes, migrates, and optionally seeds the database. */
44
+ command: 'reset';
45
+ /** Migrations to apply after wiping the database. */
46
+ migrations: Migrations;
47
+ /** Initializes database data after migrations finish. */
48
+ seed?: Seed;
49
+ /** Migration journal table. */
50
+ journalTable?: string;
51
+ }) | (DatabaseCommandOptions & {
52
+ /** Runs the application's seed function. */
53
+ command: 'seed';
54
+ /** Initializes application database data. */
55
+ seed: Seed;
56
+ }) | (DatabaseCommandOptions & {
57
+ /** Reports the status of known migrations. */
58
+ command: 'status';
59
+ /** Migrations to inspect. */
60
+ migrations: Migrations;
61
+ /** Migration journal table. */
62
+ journalTable?: string;
63
+ }) | (DatabaseCommandOptions & {
64
+ /** Destructively recreates the configured database. */
65
+ command: 'wipe';
66
+ });
67
+ /**
68
+ * Runs a data-table database command from structured invocation options.
69
+ *
70
+ * @param options Database command and application database values.
71
+ * @returns The exit code the host CLI should use. Always resolves `0`;
72
+ * command failures throw.
73
+ */
74
+ export declare function runRemixDb(options: RunRemixDbOptions): Promise<number>;
75
+ export {};
76
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE3D,UAAU,sBAAsB;IAC9B,6CAA6C;IAC7C,EAAE,EAAE,QAAQ,CAAA;CACb;AAED,KAAK,oBAAoB,GACrB;IACE;;;OAGG;IACH,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,CAAC,EAAE,KAAK,CAAA;CACb,GACD;IACE,EAAE,CAAC,EAAE,KAAK,CAAA;IACV,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,CAAA;AAEL,KAAK,sBAAsB,GAAG,sBAAsB,GAClD,oBAAoB,GAAG;IACrB,gDAAgD;IAChD,OAAO,EAAE,UAAU,CAAA;IACnB,4BAA4B;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAEH,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GACzB,CAAC,sBAAsB,GAAG;IACxB,kCAAkC;IAClC,OAAO,EAAE,SAAS,CAAA;IAClB,2BAA2B;IAC3B,UAAU,EAAE,UAAU,CAAA;IACtB;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,+BAA+B;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAC,GACF,sBAAsB,GACtB,CAAC,sBAAsB,GAAG;IACxB,0DAA0D;IAC1D,OAAO,EAAE,OAAO,CAAA;IAChB,qDAAqD;IACrD,UAAU,EAAE,UAAU,CAAA;IACtB,yDAAyD;IACzD,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,+BAA+B;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAC,GACF,CAAC,sBAAsB,GAAG;IACxB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAA;IACf,6CAA6C;IAC7C,IAAI,EAAE,IAAI,CAAA;CACX,CAAC,GACF,CAAC,sBAAsB,GAAG;IACxB,8CAA8C;IAC9C,OAAO,EAAE,QAAQ,CAAA;IACjB,6BAA6B;IAC7B,UAAU,EAAE,UAAU,CAAA;IACtB,+BAA+B;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB,CAAC,GACF,CAAC,sBAAsB,GAAG;IACxB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAA;CAChB,CAAC,CAAA;AAEN;;;;;;GAMG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,CA2F5E"}
package/dist/cli.js ADDED
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Runs a data-table database command from structured invocation options.
3
+ *
4
+ * @param options Database command and application database values.
5
+ * @returns The exit code the host CLI should use. Always resolves `0`;
6
+ * command failures throw.
7
+ */
8
+ export async function runRemixDb(options) {
9
+ if (options.command === 'migrate') {
10
+ let migrateOptions = options.to === undefined
11
+ ? { journalTable: options.journalTable }
12
+ : { to: options.to, journalTable: options.journalTable };
13
+ let result = await options.db.migrate(options.migrations, migrateOptions);
14
+ if (result.applied.length === 0) {
15
+ console.log('no pending migrations');
16
+ }
17
+ for (let entry of result.applied) {
18
+ console.log('applied ' + entry.id + '_' + entry.name);
19
+ }
20
+ return 0;
21
+ }
22
+ if (options.command === 'rollback') {
23
+ if (options.to !== undefined && options.step !== undefined) {
24
+ throw new Error('Cannot combine "to" and "step" migration options in the same run');
25
+ }
26
+ let result = options.to === undefined
27
+ ? await options.db.migrate(options.migrations, {
28
+ direction: 'down',
29
+ step: options.step ?? 1,
30
+ dryRun: options.dryRun,
31
+ journalTable: options.journalTable,
32
+ })
33
+ : await options.db.migrate(options.migrations, {
34
+ direction: 'down',
35
+ to: options.to,
36
+ dryRun: options.dryRun,
37
+ journalTable: options.journalTable,
38
+ });
39
+ if (result.reverted.length === 0) {
40
+ console.log('no migrations to revert');
41
+ }
42
+ for (let entry of result.reverted) {
43
+ console.log((options.dryRun ? 'would revert ' : 'reverted ') + entry.id + '_' + entry.name);
44
+ }
45
+ return 0;
46
+ }
47
+ if (options.command === 'reset') {
48
+ await options.db.reset({
49
+ migrations: options.migrations,
50
+ seed: options.seed,
51
+ journalTable: options.journalTable,
52
+ });
53
+ console.log('database reset');
54
+ return 0;
55
+ }
56
+ if (options.command === 'seed') {
57
+ await options.seed(options.db);
58
+ console.log('database seeded');
59
+ return 0;
60
+ }
61
+ if (options.command === 'status') {
62
+ let entries = await options.db.migrationStatus(options.migrations, {
63
+ journalTable: options.journalTable,
64
+ });
65
+ for (let entry of entries) {
66
+ console.log(entry.id + ' ' + entry.name + ' ' + entry.status);
67
+ }
68
+ return 0;
69
+ }
70
+ if (options.command === 'wipe') {
71
+ await options.db.wipe();
72
+ return 0;
73
+ }
74
+ // Guard against unchecked command strings from plain-JS callers so an
75
+ // unknown command can never fall through to a destructive operation.
76
+ let command = options.command;
77
+ throw new Error('Unknown database command: ' + command);
78
+ }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export type { AdapterCapabilityOverrides, AdapterCapabilities, DataManipulationRequest, ColumnCheck, ColumnComputed, ColumnDefault, ColumnDefinition, ColumnTypeName, CountOperation, DataManipulationResult, DataManipulationOperation, DeleteOperation, DatabaseAdapter, ExistsOperation, ForeignKeyAction, IdentityOptions, InsertManyOperation, InsertOperation, JoinClause, JoinType, RawOperation, ReturningSelection, SelectColumn, SelectOperation, TableRef, TransactionOptions, TransactionToken, UpdateOperation, UpsertOperation, } from './lib/adapter.ts';
2
- export { DataTableAdapterError, DataTableConstraintError, DataTableError, DataTableQueryError, DataTableValidationError, } from './lib/errors.ts';
1
+ export type { DatabaseCapabilities, DatabaseDriver, DataManipulationOperation, DataManipulationRequest, ColumnCheck, ColumnComputed, ColumnDefault, ColumnDefinition, ColumnTypeName, DataManipulationResult, ForeignKeyAction, IdentityOptions, TableRef, TransactionOptions, TransactionToken, } from './lib/driver.ts';
2
+ export { DataTableDatabaseError, DataTableConstraintError, DataTableError, DataTableQueryError, DataTableValidationError, } from './lib/errors.ts';
3
3
  export type { AnyRelation, AnyColumn, AnyTable, BelongsToOptions, ColumnReference, ColumnReferenceForQualifiedName, HasManyOptions, HasManyThroughOptions, HasOneOptions, KeySelector, OrderByClause, OrderDirection, PrimaryKeyInput, Relation, RelationCardinality, RelationKind, RelationMapForTable, Table, TableAfterDelete, TableAfterDeleteContext, TableAfterRead, TableAfterReadContext, TableAfterReadResult, TableAfterWrite, TableAfterWriteContext, TableBeforeDelete, TableBeforeDeleteContext, TableBeforeDeleteResult, TableBeforeWrite, TableBeforeWriteContext, TableBeforeWriteResult, TableColumnInput, TableColumnName, TableColumns, TableLifecycleOperation, TableName, TablePrimaryKey, TableReference, TableRow, TableRowWith, TableColumnsDefinition, TableValidate, TableValidationContext, TableWriteOperation, TableValidationOperation, TableValidationResult, TimestampConfig, TimestampOptions, ValidationFailure, ValidationIssue, } from './lib/table.ts';
4
4
  export { belongsTo, columnMetadataKey, fail, getTableColumns, getTableColumnDefinitions, getTableBeforeDelete, getTableBeforeWrite, getTableAfterDelete, getTableAfterRead, getTableAfterWrite, getTableName, getTablePrimaryKey, getTableReference, getTableTimestamps, getTableValidator, hasMany, hasManyThrough, hasOne, table, tableMetadataKey, timestamps, } from './lib/table.ts';
5
5
  export type { ColumnNamespace } from './lib/column.ts';
@@ -8,8 +8,9 @@ export type { Predicate, WhereInput, WhereObject } from './lib/operators.ts';
8
8
  export { and, between, eq, gt, gte, ilike, inList, isNull, like, lt, lte, ne, notInList, notNull, or, } from './lib/operators.ts';
9
9
  export type { SqlStatement } from './lib/sql.ts';
10
10
  export { rawSql, sql } from './lib/sql.ts';
11
- export type { CountOptions, CreateManyResultOptions, CreateManyRowsOptions, CreateResultOptions, CreateRowOptions, DeleteManyOptions, FindManyOptions, FindOneOptions, OrderByInput, OrderByTuple, QueryColumnTypesForTable, QueryForTable, QueryTableInput, SingleTableColumn, SingleTableWhere, UpdateManyOptions, UpdateOptions, WriteResult, WriteRowResult, WriteRowsResult, } from './lib/database.ts';
12
- export { createDatabase, Database } from './lib/database.ts';
11
+ export type { CountOptions, CreateManyResultOptions, CreateManyRowsOptions, CreateResultOptions, CreateRowOptions, DeleteManyOptions, DatabaseOptions, FindManyOptions, FindOneOptions, OrderByInput, OrderByTuple, QueryColumnTypesForTable, QueryForTable, QueryTableInput, SingleTableColumn, SingleTableWhere, UpdateManyOptions, UpdateOptions, WriteResult, WriteRowResult, WriteRowsResult, } from './lib/database.ts';
12
+ export { Database } from './lib/database.ts';
13
+ export type { DatabaseMigrateOptions, DatabaseMigrationStatusOptions, DatabaseResetOptions, MigrateResult, MigrationDescriptor, MigrationRegistry, Migrations, MigrationStatus, MigrationStatusEntry, Seed, } from './lib/migrations.ts';
13
14
  export type { AnyQuery } from './lib/query.ts';
14
15
  export { Query, query } from './lib/query.ts';
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export { DataTableAdapterError, DataTableConstraintError, DataTableError, DataTableQueryError, DataTableValidationError, } from "./lib/errors.js";
2
- export { belongsTo, columnMetadataKey, fail, getTableColumns, getTableColumnDefinitions, getTableBeforeDelete, getTableBeforeWrite, getTableAfterDelete, getTableAfterRead, getTableAfterWrite, getTableName, getTablePrimaryKey, getTableReference, getTableTimestamps, getTableValidator, hasMany, hasManyThrough, hasOne, table, tableMetadataKey, timestamps, } from "./lib/table.js";
3
- export { ColumnBuilder, column } from "./lib/column.js";
4
- export { and, between, eq, gt, gte, ilike, inList, isNull, like, lt, lte, ne, notInList, notNull, or, } from "./lib/operators.js";
5
- export { rawSql, sql } from "./lib/sql.js";
6
- export { createDatabase, Database } from "./lib/database.js";
7
- export { Query, query } from "./lib/query.js";
1
+ export { DataTableDatabaseError, DataTableConstraintError, DataTableError, DataTableQueryError, DataTableValidationError, } from './lib/errors.js';
2
+ export { belongsTo, columnMetadataKey, fail, getTableColumns, getTableColumnDefinitions, getTableBeforeDelete, getTableBeforeWrite, getTableAfterDelete, getTableAfterRead, getTableAfterWrite, getTableName, getTablePrimaryKey, getTableReference, getTableTimestamps, getTableValidator, hasMany, hasManyThrough, hasOne, table, tableMetadataKey, timestamps, } from './lib/table.js';
3
+ export { ColumnBuilder, column } from './lib/column.js';
4
+ export { and, between, eq, gt, gte, ilike, inList, isNull, like, lt, lte, ne, notInList, notNull, or, } from './lib/operators.js';
5
+ export { rawSql, sql } from './lib/sql.js';
6
+ export { Database } from './lib/database.js';
7
+ export { Query, query } from './lib/query.js';
@@ -1,4 +1,4 @@
1
- import type { ColumnDefinition, ForeignKeyAction, IdentityOptions } from './adapter.ts';
1
+ import type { ColumnDefinition, ForeignKeyAction, IdentityOptions } from './driver.ts';
2
2
  /**
3
3
  * Chainable builder used to describe physical column definitions.
4
4
  */