Skip to content

fresh

Drop all tables and re-run every migration from scratch.

Data Loss

fresh drops all tables and re-runs all migrations. All data is permanently deleted. Only use this command on local or development databases. Never run it against a production database.

Synopsis

bash
npx @orphnet/d1-eloquent fresh --db <DB_NAME> [--local | --remote]

Options

FlagDescription
--db <DB_NAME>Required. The D1 binding name defined in wrangler.toml.
--localRun against the local D1 database. Recommended — keep fresh local.
--remoteRun against the Cloudflare-hosted D1 database. Use with extreme caution.

Example

Reset the local database and apply all migrations from scratch:

bash
npx @orphnet/d1-eloquent fresh --db MY_DB --local

Notes

  • fresh is equivalent to dropping every table manually and then running migrate.
  • The _migrations tracking table is also cleared, so every migration file will be treated as new.
  • After fresh, run seed to repopulate the database with development data.

Released under the MIT License.