guardEnvironment function
Refuses schema- or data-changing commands outside a local environment.
Migrations and seeders rewrite the database in place, so running them
against a staging or production APP_ENV has to be deliberate: pass
--force to say so.
Implementation
void guardEnvironment(String command, {required bool force}) {
final environment = AppEnvironment.current();
if (!environment.isProtected || force) return;
throw DatabaseException(
'Refusing to run "$command": APP_ENV is ${environment.name}. '
'This would change a ${environment.name} database. Re-run with --force '
'if that is what you want.',
);
}