data-table@0.4.0
Breaking Changes📦 remixView on GitHub →
⚠ 2 breaking✨ 6 features🔧 31 symbols
Summary
Introduced new database management APIs including wipe, migrate, status, reset, and close, along with a typed runRemixDb API. Refactored database adapters to concrete factories and updated migration handling.
⚠️ Breaking Changes
- `runRemixDb()` now accepts resolved `Database`, `Migrations`, and `Seed` values in a command-discriminated options union. The public `createMigrationRunner()`, `MigrationRunner`, `MigrationRunnerOptions`, and `GetMigrations` APIs were removed; use `Database.migrate()` and `Database.migrationStatus()`. `MigrateOptions` was replaced by `DatabaseMigrateOptions`, with `DatabaseMigrationStatusOptions` and `DatabaseResetOptions` covering the other lifecycle methods.
- Replaced public adapter classes and factories with concrete database factories. Use `createPostgresDatabase()`, `createMysqlDatabase()`, or `createSqliteDatabase()` instead of `createDatabase(create*DatabaseAdapter())`. `Database` is now the canonical public class and instance type. Integration packages extend `Database`, implement a composed `DatabaseDriver`, and pass that private driver to `super()`. The database object exposes its dialect, immutable capabilities, table checks, and column checks directly. The `DatabaseAdapter`, `AdapterCapabilities`, and `AdapterCapabilityOverrides` types were replaced by `DatabaseDriver`, which requires `wipe()` and an idempotent `close()`. The `createDatabase()` helper, built-in adapter exports, and `db.adapter` escape hatch were removed. Individual operation types such as `SelectOperation` and `InsertOperation` are no longer exported; derive them from the exported union instead, for example `Extract<DataManipulationOperation, { kind: 'select' }>`. `DataTableAdapterError` was renamed to `DataTableDatabaseError` to match the new API.
Migration Steps
- Replace calls to `createDatabase(create*DatabaseAdapter())` with `createPostgresDatabase()`, `createMysqlDatabase()`, or `createSqliteDatabase()`.
- Update usages of `createMigrationRunner()`, `MigrationRunner`, `MigrationRunnerOptions`, and `GetMigrations` to use `Database.migrate()` and `Database.migrationStatus()`.
- Replace `MigrateOptions` with `DatabaseMigrateOptions`, `DatabaseMigrationStatusOptions`, and `DatabaseResetOptions` as appropriate.
- Replace `DataTableAdapterError` with `DataTableDatabaseError`.
- If extending database integrations, import `Database`, `DatabaseDriver`, and supporting driver protocol types directly from `remix/data-table`.
- Derive individual operation types (e.g., `SelectOperation`) from the exported union instead of importing them directly.
✨ New Features
- Added `Database.wipe()`, `Database.migrate()`, `Database.migrationStatus()`, `Database.reset()`, and `Database.close()` along with the typed `runRemixDb()` API from `remix/data-table/cli`.
- `Database.migrate()` supports forward and backward directions, mutually exclusive `to` and `step` bounds, dry runs, and custom journal tables.
- Migration status reports applied journal entries missing from the current migration set without creating an absent journal table.
- Forward runs reject missing applied migrations before executing SQL, while backward runs skip orphaned journal entries so migrations that are still present can be rolled back.
- Concrete databases release internally owned connections with `close()`.
- `loadSeed()` from `remix/data-table/migrations/node` loads a SQL seed file as a `Seed` function.
Affected Symbols
Database.wipe()Database.migrate()Database.migrationStatus()Database.reset()Database.close()runRemixDb()createMigrationRunner()MigrationRunnerMigrationRunnerOptionsGetMigrationsMigrateOptionsDatabaseMigrateOptionsDatabaseMigrationStatusOptionsDatabaseResetOptionscreatePostgresDatabase()createMysqlDatabase()createSqliteDatabase()createDatabase()create*DatabaseAdapter()DatabaseDatabaseDriverDatabaseAdapterAdapterCapabilitiesAdapterCapabilityOverridesdb.adapterSelectOperationInsertOperationDataManipulationOperationDataTableAdapterErrorDataTableDatabaseErrorloadSeed()