Regeneration and your code
Changing a resource
Section titled “Changing a resource”To add a field, one command does all of it, the migration too:
nevela field Product featured:booleanSee nevela field.
To change a field, or anything else in a descriptor:
- Edit the descriptor, for example give a field a
"default". - Run
nevela generate. - If the database has to change as well, write a migration for it. Nevela writes one for a new table and a new field, and leaves changes to a column that has your data in it to you:
nevela artisan make:migration make_sku_longer_on_products. - Run
nevela migrate.
Your code is kept
Section titled “Your code is kept”Generated code sits between two marker comments:
// nevela:generated:start hash=4f1c2a9b7e31protected $fillable = ['name', 'sku', 'price'];// nevela:generated:end
// Your own relationships, scopes and accessors go here.Regeneration rewrites only what is between the markers. Anything outside them is never touched.
If you edit inside the markers, Nevela notices, because the hash no longer matches the content. It skips that file and tells you:
app/Models/Product.php .. skipped — edited inside generated blockMove your change outside the markers and run the command again, or use --force to overwrite it.
Files that are “written once” in what gets generated, such as the policy, the migration and the dashboard pages, belong to you after they are created. Regeneration never changes them.