Skip to content

Commit 46de63a

Browse files
committed
chore: update migration validation docs
1 parent 813a032 commit 46de63a

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

src/Web/Documentation/content/main/1-essentials/05-models.md

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -258,39 +258,32 @@ A few [console commands](../3-console/02-building-console-commands) are provided
258258

259259
### Validating migrations
260260

261-
:::warning
262-
All `migrate:up` and `migrate:fresh` commands validate migration files to ensure their integrity by default.
261+
By default, an integrity check is done before applying database migrations with the `migrate:up` and `migrate:fresh` commands. This validation works by comparing the current migration hash with the one stored in the `migrations` table, if it was already applied in your environment.
263262

264-
If you don't want to validate migration files, you can use the `--no-validate` argument.
265-
:::
263+
If a migration file has been tampered with, the command will report it as a validation failure. Note that you may opt-out of this behavior by using the `--no-validate` argument.
266264

267-
The `migrate:validate` command checks the integrity of migration files by comparing their current hash with the stored hash in the database. If a migration file has been tampered with, the command will report it as a validation failure.
265+
Additionally, you may use the `migrate:validate` command to validate the integrity of migrations at any point, in any environment:
268266

269267
```sh
270-
{:hl-comment:# Validate migration files:}
271268
./tempest migrate:validate
272269
```
273270

274-
If any migration fails validation, it will be reported with an error message specifying the issue.
275-
276-
:::info
277-
Only the actual SQL commands (minified and stripped of comments) are hashed during validation. This means that code-style changes, such as indentation or formatting, and comments will not impact the validation process.
271+
:::tip
272+
Only the actual SQL query of a migration, minified and stripped of comments, is hashed during validation. This means that code-style changes, such as indentation, formatting, and comments will not impact the validation process.
278273
:::
279274

280-
### Rehashing Migrations
281-
282-
The `migrate:rehash` command bypasses integrity checks to update stored migration hashes in the database.
275+
### Rehashing migrations
283276

284-
:::warning
285-
This operation can mask serious issues like tampered migration files or schema inconsistencies.
286-
287-
Only use this command when absolutely necessary and when you're confident that your migration files are correct and consistent across environments.
288-
:::
277+
You may use the `migrate:rehash` command to bypass migration integrity checks and update the hashes of migrations in the database.
289278

290279
```sh
291280
./tempest migrate:rehash
292281
```
293282

283+
:::warning
284+
Note that deliberately bypassing migration integrity checks may result in a broken database state. Only use this command when absolutely necessary, if you are confident that your migration files are correct and consistent accross environments.
285+
:::
286+
294287
## Database configuration
295288

296289
By default, Tempest uses a SQLite database stored in the `vendor/.tempest` directory. Changing databases is done by providing a {`Tempest\Database\Config\DatabaseConfig`} [configuration object](./06-configuration).

0 commit comments

Comments
 (0)