Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/preserve-removed-fields-in-pre-migration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@tailor-platform/sdk": minor
---

Improve `tailordb migration` handling of data-loss-possible changes:

- Removed fields (`field_removed`) and removed types (`type_removed`) are now reported as **warnings** during `tailordb migration generate`, not silent changes. They are no longer dropped before `migrate.ts` runs: the field/type stays available during the Pre-migration phase so that scripts can read it (e.g. `innerJoin` through a foreign key that is being dropped in the same migration), then the physical drop happens in the Post-migration phase.
- Add `tailordb migration script <number>` subcommand to add a `migrate.ts` (and `db.ts`) template to an existing migration directory. Useful for warning-tier changes where you want a custom data migration even though one was not generated automatically.
- `migrate.ts` is now executed whenever the file exists on disk for a pending migration, regardless of whether the diff originally required a script. Breaking changes still hard-require a script as before.
1 change: 1 addition & 0 deletions packages/sdk/docs/cli-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Commands for managing TailorDB tables, data, and schema migrations.
| ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| [tailordb truncate](./cli/tailordb.md#tailordb-truncate) | Truncate (delete all records from) TailorDB tables. |
| [tailordb migration generate](./cli/tailordb.md#tailordb-migration-generate) | Generate migration files by detecting schema differences between current local types and the previous migration snapshot. |
| [tailordb migration script](./cli/tailordb.md#tailordb-migration-script) | Add a migration script (migrate.ts) template to an existing migration directory. |
| [tailordb migration set](./cli/tailordb.md#tailordb-migration-set) | Set migration checkpoint to a specific number. |
| [tailordb migration status](./cli/tailordb.md#tailordb-migration-status) | Show the current migration status for TailorDB namespaces, including applied and pending migrations. |
| [tailordb erd export](./cli/tailordb.md#tailordb-erd-export) | Export Liam ERD dist from applied TailorDB schema. |
Expand Down
50 changes: 50 additions & 0 deletions packages/sdk/docs/cli/tailordb.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ tailor-sdk tailordb migration [command]
| Command | Description |
| ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| [`tailordb migration generate`](#tailordb-migration-generate) | Generate migration files by detecting schema differences between current local types and the previous migration snapshot. |
| [`tailordb migration script`](#tailordb-migration-script) | Add a migration script (migrate.ts) template to an existing migration directory. |
| [`tailordb migration set`](#tailordb-migration-set) | Set migration checkpoint to a specific number. |
| [`tailordb migration status`](#tailordb-migration-status) | Show the current migration status for TailorDB namespaces, including applied and pending migrations. |

Expand Down Expand Up @@ -204,6 +205,55 @@ tailor-sdk tailordb migration generate [options]
See [Global Options](../cli-reference.md#global-options) for options available to all commands.

<!-- politty:command:tailordb migration generate:global-options-link:end -->
<!-- politty:command:tailordb migration script:heading:start -->

#### tailordb migration script

<!-- politty:command:tailordb migration script:heading:end -->

<!-- politty:command:tailordb migration script:description:start -->

Add a migration script (migrate.ts) template to an existing migration directory.

<!-- politty:command:tailordb migration script:description:end -->

<!-- politty:command:tailordb migration script:usage:start -->

**Usage**

```
tailor-sdk tailordb migration script [options] <number>
```

<!-- politty:command:tailordb migration script:usage:end -->

<!-- politty:command:tailordb migration script:arguments:start -->

**Arguments**

| Argument | Description | Required |
| -------- | ----------------------------------------------------- | -------- |
| `number` | Migration number to add a script to (e.g., 0001 or 1) | Yes |

<!-- politty:command:tailordb migration script:arguments:end -->

<!-- politty:command:tailordb migration script:options:start -->

**Options**

| Option | Alias | Description | Required | Default | Env |
| ------------------------- | ----- | ----------------------------------------------------------------- | -------- | -------------------- | --------------------------------- |
| `--config <CONFIG>` | `-c` | Path to SDK config file | No | `"tailor.config.ts"` | `TAILOR_PLATFORM_SDK_CONFIG_PATH` |
| `--namespace <NAMESPACE>` | `-n` | Target TailorDB namespace (required if multiple namespaces exist) | No | - | - |

<!-- politty:command:tailordb migration script:options:end -->

<!-- politty:command:tailordb migration script:global-options-link:start -->

See [Global Options](../cli-reference.md#global-options) for options available to all commands.

<!-- politty:command:tailordb migration script:global-options-link:end -->

<!-- politty:command:tailordb migration set:heading:start -->

#### tailordb migration set
Expand Down
Loading
Loading