How to deploy new DocTypes without developer_mode=true?

Hello gentlemen,
I would like to discuss how to deploy new DocTypes with a combination of “bench export-fixtures” and “bench migrate”

We created an application called “erpituc”.
We use three instances of frappe-bench as Development, Test & Production.
In Production developer_mode is disabled in common_site_config.json
Frappe 13.18.0 and Bench 5.6.0 are used.

We created a new DocType in stage Development with these settings:

Then we used “bench export-fixtures” to create fixtures/doctype.json describing the new DocType.
fixtures/doctype.json was transfered to the stages Test & Production.
There “bench migrate” was used to create the new DocType.

In Production this error-message occured:

Updating DocTypes for frappe        : [========================================] 100%
Updating DocTypes for erpnext       : [========================================] 100%
Updating DocTypes for erpituc       : [========================================] 100%

Traceback (most recent call last):
  File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
...
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 372, in _raise_exception
    raise raise_exception(msg)
frappe.core.doctype.doctype.doctype.CannotCreateStandardDoctypeError: Not in Developer Mode! Set in site_config.json or make 'Custom' DocType.

Seeing this, we temporary enabled developer_mode on Production and were able to create the new DocType.

But fiddling with developer_mode on Production just for this purpose seems a little awkward, as does making the DocType ‘Custom’.

How do you approach this in your applications?

In the screenshot, if you check Custom? checkbox - you will be able to create new doctypes without any hassle (no need for developer mode). basically that checkmark (if unchecked) makes it easier for devs to extend functionality and write controller code :slight_smile:

Thank you for the input.

I think this flag is useful when I put a new DocType into a foreign app, as when I create a new DocType and e.g. assign it to module “erpnext”.

There must still be another way to deploy new DocTypes.
The applications frappe and erpnext don’t check the Custom-Flag in their DocTypes and don’t use fixtures when deploying a new version.

I would like to know how this works.

So the reason why frappe/erpnext’s core doctypes don’t have Custom? checked because these doctypes are integral/core to functioning so they’re not “custom” doctypes but rather “standard” ones and these are the same doctypes you will see in any erpnext/frappe installation.
so basically if you want your doctypes to span across multiple sites/benches - you uncheck Custom? checkmark which also allows us to customize it further by writing code for them.

Why are you using fixtures for DocTypes?
Just create the DocTypes as part of your custom app and they will be added automatically when you install the app elsewhere.

You don’t need fixture to add DocTypes; instead, they are shipped with your app.

In your case, remove the fixture from the app and then install it. The DocTypes will be present on the production server.

Sorry for the delay, I had to finish some other task first.

Thx @rtdany10, this is exactly what I hoped for.

For everyone:
I created a DocType called “my_new_doctype” and copied the folder my_app/my_app/my_app/doctype/my_new_doctype to the next stage.
Then I ran “bench migrate” and the DocType was created. Check.

Next I also added another field to my_new_doctype and again copied the my_new_doctype-folder to the next stage.
I ran “bench migrate” and the new field was added to the DocType was created. Check.

Last I removed a field from my_new_doctype, copied the folder and ran “bench migrate”. The field was removed from. Check, full marks.

Closing this: @rtdany10, this ist great, how do you know about this? I checked Database Migrations but I would not have guessed that this is possible.
Did you read this somewhere or did you find out it by yourself?

This isn’t the right way to manage apps. Create a Git repository and push your app into the repo. Then use bench get-app repo-link to pull the app in the production server.

As you make updates to your app in your development server, push it to the repo. And on the production server, use bench update to update the app.

Apps shipping doctype with them is basic framework feature. That’s how even ERPNext runs on Frappe Framework. I recommend you read the documentation and follow the frappe framework tutorial for a better understanding: Frappe Framework Tutorial