mntechnique / kisanmitra_erpnext

ERPNext customisation for KisanMitra.org
Other
1 stars 1 forks source link

ErpNext Installation and Upgrade Queries #1

Open kothagunda opened 6 years ago

kothagunda commented 6 years ago

ErpNext Installation and Upgrade Queries

Backup Queries

  1. What is this .sql backup Does it have just docTypes or also data. How to do replace the .sql with a backup. Need to stop some processes.
  2. If I am on v10, can I take the .sql backup and put it on a v11 instance. (What if member fields differ)
  3. If i am moving my instance from AWS to DigitalOcean, will i get the data, custom field changes, website setting changes, custom scripts etc ?

Version Upgrade Queries

  1. Currently on ERPNext-v10 + Customize docFields/Types + data, how to upgrade to ERPNext-v11 (Impact to custom fields and data. Commands ?)
  2. Currently on ERPNext-v10 + Customize docFields/Types + data, how to upgrade to KisanMitra-v1 (which has plain exotel integ) (Impact to custom fields and data. Commands?)
  3. Currently on KisanMitra -v1, how to upgrade to KisanMitra-v2 (which has new features) (Impact to custom fields and data. Commands ?)
  4. Currently on KisanMitra -v2, how to upgrade to ERPNext-v11(which has new features) (Impact to custom fields and data. Commands ?)
  5. What if there is code conflict between these two branches. Same code might have been changed. Do we merge ErpNext-v11 into KisanMitra -v2 on github, and then install
  6. What if I added field in a doctype and exact same name field added in ErpNext-v11 also.
  7. Patches from ERPNext
  8. If I am on erp-v10
  9. If I am on kisanmitra-v1 (do I merge or just a command ?)
  10. What if I change a DocType name, for example Issue is renamed to Ticket. What if I upgrade from version 10 to Version 11. Will this get overridden ? Will I still get the Issue docType features that were built in version 11 into my Ticket docType.

Multi-Tenant Queries

  1. All tenants have to be same version in a bench ? If I do bench upgrade from v10 o v11 do all the tenants get updated automatically.
  2. Details about multi bench thing you guys were talking about yesterday – dev side wont have some features working
  3. How do I just migrate the skeleton, with my customized docTypes, and custom scripts, without data to other tenants. Do I maintain a tenant with just custom docs and scripts and then use the .sql (witout data) and copy it over
  4. Can we create another tenant with just a different subdomain, or does it have to be a separate URL. (first tenant kisanmitra.org/Vikarabad, second tenant kisanmitra.org/Adilabad. Or it has to be kisanmitrad-adilabad.org and kisanmitra-vikarabad.org)
  5. What is this DEV tenant , apart form the PROD one when we install (on same bench).
  6. Can we test it on the DEV and then migrate the changes to the PROD -on digitalOcean not talking about local machine
  7. Can they both see the same DB ?
  8. Can we have two tenants having same DB
  9. What is bench migrate command. If I have 5 tenants with the same version on a bench. Can I test it on one tenant, and migrate the changes to all the tenants in one go.
  10. Can a have 2-3 tenants on a 1GB RAM assuming the 30GB space is good enough. The droplet on digital ocean we have is 1GB / 30GB.
  11. Can i install only certain modules on each tenant, to save space. So that i can fit in more tenants.
  12. Can something be dont such that one particular tenant can see data from all other tenants. This is to get reports from all the various tenants for data analytics.

Other

  1. Process for Telugu Language for new fields we add
gaurav-naik commented 6 years ago

Backup Queries

What is this .sql backup Does it have just docTypes or also data. How to do replace the .sql with a backup. Need to stop some processes.

The .sql backup is a gzipped .sql file containing schema and data.

The command bench --site {sitename} backup --with-files creates two gzipped files, one containing a full database backup and another containing attachments.

To restore a database:

$cat sites/kisanmitra.local/site_config.json 
$mysql -u root -p {database_name_from_site_config} < ~/path/to/sql/file/backup.sql
$bench migrate
$bench restart #or bench stop; bench start

No need to stop any processes.

If I am on v10, can I take the .sql backup and put it on a v11 instance. (What if member fields differ)

Yes, but this may not be a smooth transition. Customisation is prone to breaking across major versions.

Process:

  1. Restore + migrate a staging server
  2. Identify issues and implement fixes,
  3. repeat on Production server.

If i am moving my instance from AWS to DigitalOcean, will i get the data, custom field changes, website setting changes, custom scripts etc ?

Yes.

  1. Data: Restore SQL backup. (*Website Settings are part of Data )
  2. Custom Fields, Scripts: bench get-app {github_repo_url}, bench migrate
gaurav-naik commented 6 years ago

Version Upgrade Queries

Currently on ERPNext-v10 + Customize docFields/Types + data, how to upgrade to ERPNext-v11 (Impact to custom fields and data. Commands ?) Currently on ERPNext-v10 + Customize docFields/Types + data, how to upgrade to KisanMitra-v1 (which has plain exotel integ) (Impact to custom fields and data. Commands?) Currently on KisanMitra -v1, how to upgrade to KisanMitra-v2 (which has new features) (Impact to custom fields and data. Commands ?) Currently on KisanMitra -v2, how to upgrade to ERPNext-v11(which has new features) (Impact to custom fields and data. Commands ?)

  1. Place all your customisation in a separate app named "kisanmitra_erpnext"

    1. Select "KisanMitra ERPNext" in the Module link field while creating custom doctypes, reports, print formats etc.
    2. Add docnames of each custom field, property setter, print format etc as fixtures in hooks.py of kisanmitra_erpnext
  2. ERPNext and kisanmitra_erpnext can then be updated independently of each other via bench update

  3. Custom fields may get affected if the original field layout changes in the new version. To mitigate:

    1. Place custom fields under a custom Section Break field.
    2. If there are a lot of fields (more than 5) consider linking a new Custom Doctype.

What if there is code conflict between these two branches. Same code might have been changed. Do we merge ErpNext-v11 into KisanMitra -v2 on github, and then install Since ERPNext and kisanmitra_erpnext will be two separate apps entirely, there will be no code conflicts.

What if I added field in a doctype and exact same name field added in ErpNext-v11 also

Add a prefix to Custom Field names, e.g. "kisanmitra_customer_name" or "km_customer_name "instead of "customer_name".

Patches from ERPNext

Both ERPNext and kisanmitra_erpnext will be patched independently after bench update.

What if I change a DocType name, for example Issue is renamed to Ticket. What if I upgrade from version 10 to Version 11. Will this get overridden ? Will I still get the Issue docType features that were built in version 11 into my Ticket docType.

Do not change names of existing Doctypes. Consider using Translation List.

gaurav-naik commented 6 years ago

Multi-Tenant Queries

All tenants have to be same version in a bench ? If I do bench upgrade from v10 o v11 do all the tenants get updated automatically.

Ideally all tenants ought to be on their latest stable version. "bench update --upgrade" will update all tenants in the bench

How do I just migrate the skeleton, with my customized docTypes, and custom scripts, without data to other tenants. Do I maintain a tenant with just custom docs and scripts and then use the .sql (witout data) and copy it over

kisanmitra_erpnext will contain custom doctypes, custom fields, property setters, which will appear in ERPNext after executing the following commands.

$bench get-app {https://github.com/{owner}/kisanmitra_erpnext}
$bench --site {sitename} install-app kisanmitra_erpnext
$bench migrate

Can we create another tenant with just a different subdomain, or does it have to be a separate URL. (first tenant kisanmitra.org/Vikarabad, second tenant kisanmitra.org/Adilabad. Or it has to be kisanmitrad-adilabad.org and kisanmitra-vikarabad.org)

Tenants can look like:

$ls sites
kisanmitra.org  vikarabad.kisanmitra.org  adilabad.kisanmitra.org

You can purchase a domain for kisanmitra.org and have vikarabad.kisanmitra.org and others as subdomains.

What is this DEV tenant , apart form the PROD one when we install (on same bench).

Two tenants kisanmitra.org.local and kisanmitra.org can be installed on the same bench. They will share the same version of ERPNext, Frappe and kisanmitra_erpnext.

Can they both see the same DB ? Can we have two tenants having same DB

No. Each tenant has and sees its own DB.

What is bench migrate command.

Bench migrate updates the tenant set in the frappe-bench/sites/currentsite.txt folder. Optionally:

bench --site {site_name} migrate

Can we test it on the DEV and then migrate the changes to the PROD -on digitalOcean not talking about local machine If I have 5 tenants with the same version on a bench. Can I test it on one tenant, and migrate the changes to all the tenants in one go

Ideally, you develop and test locally, push to github, then update the tenant on staging server, then on production server.

Can a have 2-3 tenants on a 1GB RAM assuming the 30GB space is good enough. The droplet on digital ocean we have is 1GB / 30GB.

Should be good enough. I will confirm this.

Can i install only certain modules on each tenant, to save space. So that i can fit in more tenants.

It is not possible to install specific modules. All modules get installed on installing ERPNext

Can something be dont such that one particular tenant can see data from all other tenants. This is to get reports from all the various tenants for data analytics.

I will get back to you on this.

kothagunda commented 6 years ago

Thanks a lot for the detailed responses @gaurav-naik . Really appreciate your time and patience.

kothagunda commented 6 years ago

Thanks for enlightening us on upgrades and deployment strategy. Some followup queries

  1. If I install a app1, which has links to docTypes which are in app2. And if I don’t install app2, what happens. When do i know the issues, during installation, or at run-time.

  2. If in my app1 I use Employee Loan. Now in erpnext latest version employee-loan renamed to loan. And I upgrade to latest erpnext. But since my app1 will be having link to old employee-loan, what happens.

  3. If i dont have a seperate app, but i have done manual client customizations, and i use employee-loan as link in one of my docTypes. Now in erpnext latest version employee-loan renamed to loan. And I upgrade to latest erpnext. Will it break, or will it ask me to correct it at upgrade.

  4. Is there a serial order in which erpnext and my kisanmitra_app has to be installed

  5. Can you point us to the translation list manual or some doc. Couldnt find any, on how to use.

  6. If we have more than 5 custom fields you suggested new docType. In that case if i have Issue and KisanMitra-Issue-Details as new docType. In this case i cannot directly use Report builder(works only on single docType) as fields are split across Issue and KisanMitra-Issue-Details. So only option is to use Query Rerport to join these tables and write queries right.

  7. Assume kisanmitra_app is installed and deployed. Now i found some changes need to be made. What are steps to be followed. Will this be new version/patch/install and what is process to upgrade the hosted instance without causing any issues.: i. If a new docType has to be added. ii. If an existing docField is modified (lets say is made mandatory to non-mandatory) iii. If some master data such as new districts are added to the Disctrict DocType.

  8. If i add some master data to be inserted during installation., lets say i add items rice and wheat. Now the instance is up and running. Now there are some changes in my app. So i do the changes and do a bench update (is this what i do) on the instance. Will it try to insert rice and wheat again and fail.

gaurav-naik commented 6 years ago

If possible, use custom doctypes where module can be among ERPNext's default modules and "Is Custom" set to true. These doctypes will simply become holders of information with minimal custom logic managed via custom scripts. This approach ensures safer upgrades. If custom logic is still deemed necessary, see if it can be generalised further and issued as a Pull Request to ERPNext. Major customization ought to be a last resort. In this case, add a doctype under KisanMitra ERPNext, where its py file can be edited. Custom doctypes with their own py files (custom logic) must be tested more extensively.

I will look up how "Is Custom" doctypes are migrated and update here.

Answers to the questions above:

  1. If I install a app1, which has links to docTypes which are in app2. And if I don’t install app2, what happens. When do i know the issues, during installation, or at run-time.
  1. If there are Link/Table fields in app1 which which have a doctype of app2 as their Options, then errors will be thrown during installation. Otherwise at runtime.
  2. You can install app 2, then bench migrate again.
  3. You can check which apps have been installed on a site via the bench console:
        bench --site {sitename} console
    [0] frappe.get_installed_apps()
  1. If in my app1 I use Employee Loan. Now in erpnext latest version employee-loan renamed to loan. And I upgrade to latest erpnext. But since my app1 will be having link to old employee-loan, what happens.
  1. If i dont have a seperate app, but i have done manual client customizations, and i use employee-loan as link in one of my docTypes. Now in erpnext latest version employee-loan renamed to loan. And I upgrade to latest erpnext. Will it break, or will it ask me to correct it at upgrade.
  1. Is there a serial order in which erpnext and my kisanmitra_app has to be installed
  1. Can you point us to the translation list manual or some doc. Couldnt find any, on how to use.
  1. If we have more than 5 custom fields you suggested new docType. In that case if i have Issue and KisanMitra-Issue-Details as new docType. In this case i cannot directly use Report builder(works only on single docType) as fields are split across Issue and KisanMitra-Issue-Details. So only option is to use Query Rerport to join these tables and write queries right.
  1. Assume kisanmitra_app is installed and deployed. Now i found some changes need to be made. What are steps to be followed. Will this be new version/patch/install and what is process to upgrade the hosted instance without causing any issues.: i. If a new docType has to be added.

ii. If an existing docField is modified (lets say is made mandatory to non-mandatory)

iii. If some master data such as new districts are added to the Disctrict DocType.

  1. If i add some master data to be inserted during installation., lets say i add items rice and wheat. Now the instance is up and running. Now there are some changes in my app. So i do the changes and do a bench update (is this what i do) on the instance. Will it try to insert rice and wheat again and fail.
kothagunda commented 6 years ago

Thanks for you patience and detailed responses.

For master data insertion, Can we do something similar to HSN codes. https://github.com/frappe/erpnext/blob/e6d65bc2a1ee73a23299268ffc5de3c0f51bd1d7/erpnext/regional/india/setup.py#L56 https://github.com/frappe/erpnext/blob/e6d65bc2a1ee73a23299268ffc5de3c0f51bd1d7/erpnext/regional/india/setup.py#L15

Or can we add in hooks.py of kisanmitra app. Such that once issue table is created, we call a master data insert function . Since upgrades will not create issue table again, our data will not be inserted again and again.