Bench migrate workflow

Dear community,

From frappe tutorial:

When you create a DocType a new folder is created in the Module and a model JSON file and a controller template in Python are automatically created. When you update the DocType, the JSON model file is updated and whenever bench migrate is executed, it is synced with the database.

I had clean setup of ERPNext using bench. I’m trying to edit doc type json files and apply changes to db and web site.
For example - quotation.json, “fieldname”: “naming_series”, I set label: “My new label”.
After that I’ve run bench migrate and bench start and navigate to form to create new quotation.

Expected result: field Series has new label ‘My new label’.
Actual result: field Series label is not changed.

So the question is - what commands should I run after editing json doc types files to apply changes to db and ui?

Thanks. Yevgen.

bench --site sitename migrate

should do it. Also change the “modified_by” property of json.


yes it works, so the reason - do not forget to update modified_by or modified properties.

thanks for answer, it is correct but works a bit slower compare to @rmehta solution.

I have tried this command but i didn’t get results or changes in the json . and what should i change in the “modified_by” property of json


I have been updating existing docs with new fields but never ran bench migrate. Does migrate happen automatically? because everything seems to work. I have been making changes and adding new fields but i am yet to run a single migrate. If everything works and the new fields are saved, does that mean migrate just happens?


no you don’t need to run bench migrate every time.

Bench migrate is supposed to sync database to changes as mentioned in JSON. Now suppose you have an instance and wish to deploy a new feature which may contain reports or custom scripts or custom fields and wish to sync database then you run bench migrate.

Hi, can anyone provide a more detailed understanding of what processes takes place and which scripts are triggered when bench migrate is fired. Thanks in advance.

@sanket the exact script that is executes during migrate is frappe/

according to the script below are the processes that take place:

Migrate all apps to the latest version, will:
	- run before migrate hooks
	- run patches
	- sync doctypes (schema)
	- sync fixtures
	- sync desktop icons
	- sync web pages (from /www)
	- sync web pages (from /www)
	- run after migrate hooks

bench migrate does not work for me.
I changed the json file, run bench migrate, but I don’t see the change in Desk.
How can such a basic critical feature not work?

OMG the hack around is to manually update the modified timestamp.
Apparently that tricks the bench migrate command to think there is a change.
I thought it would be smart enough to compare the field list with the db to detect changes.
I wasted two hours to figure this out.