Custom Fresh - Keep specific tables during database resets

byโ€ข
Custom Fresh v2.1.0 adds powerful new features for Laravel developers who need more control over database resets, including schema freezing, raw table preservation, configurable reset presets, related-table handling, fresh seeding, and safer foreign-key protection. ๐Ÿงน

Add a comment

Replies

Best
Maker
๐Ÿ“Œ

๐Ÿš€ Custom Fresh v2.1.0 is here!

A major release making Laravel database resets more flexible, predictable, and safe, with better control over tables, migrations, related data, and reset workflows.

โœจ Added

  • โ„๏ธ Add the `--freeze-schema` option to mark every migration for kept tables as already run, skipping pending alter migrations when you want to leave the current schema untouched.

  • ๐Ÿ’พ Add the `--keep-raw=` option to preserve tables that have no matching migration files.

  • ๐Ÿšซ Add the `--except=` option to drop tables that would otherwise be kept by `always_keep` or `--keep`.

  • ๐Ÿ—‘๏ธ Add the `--drop=` option to drop only the listed tables while preserving everything else.

  • โš™๏ธ Add the `--preset=` option to apply named table groups from the configuration with a single flag.

  • ๐Ÿ”— Add the `--with-related` option to also preserve tables linked by foreign keys to a kept table.

  • ๐Ÿ“‹ Add the `--list` option to display discovered tables and the migration files that touch them.

  • ๐Ÿ“Š Add the `--json` option to output `--explain` and `--list` results as JSON for scripting and automation.

  • ๐ŸŒฑ Add the `--seed-fresh` option to seed only dropped tables using the `table_seeders` configuration map.

  • ๐Ÿ—„๏ธ Add the `--drop-views` and `--drop-types` options so `fresh:custom` can match Laravel's `migrate:fresh` behavior.

  • ๐Ÿงฉ Add the `keep_without_migrations`, `presets`, `table_seeders`, and `connections` configuration keys.

  • ๐Ÿ”„ Add the `replace_migrate_fresh` configuration key so `migrate:fresh` can delegate to `fresh:custom` when keep lists are configured.

  • ๐Ÿ’ฌ Prompt interactively for tables when no tables, flags, or configuration lists are specified.

  • โš ๏ธ Warn about foreign-key relationships that could break after the drop step, allowing you to add `--with-related` or adjust the keep list before running.

  • ๐Ÿงช Add PHPUnit and Orchestra Testbench coverage with a GitHub Actions matrix covering Laravel 10 through 13.

๐Ÿ›  Fixed

  • ๐Ÿ”— Preserve sibling tables created in the same `Schema::create` migration as a kept table, so keeping `sessions` no longer drops `users` and breaks later foreign keys.

  • ๐Ÿ”„ Restore only already-applied migrations (and `Schema::create` files) for kept tables, allowing pending alter migrations to run correctly.