Change8

data-table@0.3.0

Breaking Changes
📦 remixView on GitHub →
12 breaking3 features🔧 28 symbols

Summary

This release fundamentally changes how database migrations are handled, moving from a schema-builder API to plain SQL files executed via adapters. This includes removing many related APIs and introducing explicit transaction control directives within SQL scripts.

⚠️ Breaking Changes

  • Migrations are now plain SQL files organized in directories named `YYYYMMDDHHmmss_<slug>/` containing `up.sql` and optional `down.sql`. The old schema-builder API for migrations is removed.
  • The `createMigration` function is removed.
  • The types `MigrationContext`, `MigrationSchema`, `AlterTableBuilder`, `CreateMigrationInput`, `Migration`, `KeyColumns`, and `TableInput` are removed from `remix/data-table/migrations`.
  • The function `parseMigrationFilename` is removed and replaced by `parseMigrationDirectoryName`.
  • The `column` / `ColumnBuilder` re-exports from `remix/data-table/migrations` are removed (they remain available from the main `remix/data-table` entry).
  • The structure of `MigrationDescriptor` changed to `{ id, name, up: string, down?: string, transaction?, path? }`. Checksums are now computed by the runner based on the SQL content.
  • `MigrateResult.sql` is now an array of strings (`string[]`) instead of `SqlStatement[]`.
  • `loadMigrations(directory)` now scans folder-per-migration layouts (not `.ts` files) and returns descriptors containing SQL strings.
  • The `DatabaseAdapter` gained a required `executeScript(sql, transaction?)` method. Existing first-party adapters implement this.
  • The methods `migrate(request)` and the entire `DataMigrationOperation` ADT (`CreateTableOperation`, `AlterTableOperation`, etc.) are removed from `DatabaseAdapter` and public exports.
  • `compileSql` now only accepts `DataManipulationOperation`.
  • `isDataManipulationOperation` is removed from `remix/data-table/sql-helpers`.

Migration Steps

  1. Replace existing schema-builder migration files (e.g., `createMigration({...})`) with a directory structure containing `up.sql` and `down.sql` files with the equivalent SQL logic.
  2. Update code referencing removed APIs like `createMigration` or the removed types from `remix/data-table/migrations`.
  3. If implementing a custom `DatabaseAdapter`, implement the required `executeScript(sql, transaction?)` method.
  4. Update calls to `loadMigrations` to handle the new return structure containing SQL strings instead of statement objects.
  5. If using transaction control, update migration files to use SQL directives (e.g., `-- data-table/transaction: none`) or set the `transaction` field in the `MigrationDescriptor`.

✨ New Features

  • Migrations now use plain SQL files (`up.sql`, `down.sql`) executed as multi-statement queries.
  • Added support for explicit transaction control within `up.sql` using directives like `-- data-table/transaction: none`.
  • New transaction modes supported: `auto` (default), `required`, and `none`.

Affected Symbols