You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/Web/Documentation/content/main/1-essentials/05-models.md
+11-18Lines changed: 11 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -258,39 +258,32 @@ A few [console commands](../3-console/02-building-console-commands) are provided
258
258
259
259
### Validating migrations
260
260
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.
263
262
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.
266
264
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:
268
266
269
267
```sh
270
-
{:hl-comment:# Validate migration files:}
271
268
./tempest migrate:validate
272
269
```
273
270
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.
278
273
:::
279
274
280
-
### Rehashing Migrations
281
-
282
-
The `migrate:rehash` command bypasses integrity checks to update stored migration hashes in the database.
275
+
### Rehashing migrations
283
276
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.
289
278
290
279
```sh
291
280
./tempest migrate:rehash
292
281
```
293
282
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
+
294
287
## Database configuration
295
288
296
289
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