Setting the template_master via database

Discussion in 'General' started by pyte, Jan 26, 2024.

  1. pyte

    pyte Well-Known Member HowtoForge Supporter

    Hi,
    i have quiet a few hunderts of customers within ISPConfig all of them should have the template_master with the id "1" set, but 460 of them don't have the template set. Is it sufficient to update the "template_master" field in the database for all customers to "1" or are there additional steps neccesary to make it work?

    Code:
    UPDATE client SET template_master = 1 WHERE template_master <> 1; 
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    I'm not 100% sure, but I guess you might have to set the limits of the client to the values of the template as well and you might have to add a record in client_template_assigned (but might be that client_template_assigned is only needed for additional templates only). I would check it like this:

    Export a record of a specific client with, e.g., phpmyadmin, check which records are in client_template_assigned, assign the template to the client using ISPConfig GUI, and then compare what has changed for this client in the client table and in client_template_assigned. This procedure is likely faster and less error prone than reading through the code :)
     
    ahrasis and pyte like this.
  3. pyte

    pyte Well-Known Member HowtoForge Supporter

    Mhh what is "client_template_assigned" even for? It is completely empty for me.
    It seems like changing the template just updates all the limit values in the corresponding fields in the client table, aswell as the template_master setting.

    Another approach would be to export all clients via the api with client_get, update all the limit values and template value and update the clients with the client_update api call, but i assume this has the same effect?
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Most likely its for the additional templates that can be added.

    Yes. You can do it directly in the DB, using API has no benefits here.
     
  5. pyte

    pyte Well-Known Member HowtoForge Supporter

    Nothing that fuzzy finding the code base couldn't find i guess. Seems like you are correct, the old style was template_additional and the new one client_template_assigned.
    Which seems to be obsolete?

    Ok i will just set the limits one by one in the DB and then set the template_master at last.
     
    Last edited: Jan 26, 2024
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    This part of the code is a bit messy, and I'm not familiar with it as several other devs contributed to it, and then it was partially rewritten because it was broken. So I can't say for sure which tables are used at the moment. But as it works at the moment and I don't have the time to rewrite it from scratch, I better leave it alone :)
     
  7. pyte

    pyte Well-Known Member HowtoForge Supporter

    No worries, i wouldn't change anything either and the feature also seems unnecessary to me. I could simply create another master template with corresponding changes to the existing one and be good to go. Doesn't seem high requested anyways as upon a quick look it definitively looks broken
     

Share This Page