Quote:
Originally Posted by Link14716
Upgrade scripts - they require that the hack that it upgrades has been imported (at least) and the upgrade .htl just updates whatever needs to be updated in the hack information and runs its own set of steps. I don't know if this can be done already, but if it cannot, it would be something that is needed. 
|
I'm looking into ways how I can do this.
What I'm CURRENTLY thinking of:
Adding an extra option for each hack (along with Show on front-end, is finished, is installed, etc. etc.) that says: Is Upgrade Script.
Then, if people run that 'hack' (which is labelled Is Upgrade Script) and attempt to install it (thus, attempt to upgrade their existing hack), the HTL will do:
1) a check on the system to see if the hack exists, if not it will STOP THE UPGRADE with an error page.
2) if the hack DOES exist but the version of the existing one is higher or equal to the one from the Upgrade, it will STOP THE UPGRADE with an error page.
3) if the hack exists and is a lower version, then it will first see if the existing hack has any phrases (by checking the `phrasevarnames` column of the hack in the database - this column already holds ALL varnames of ALL imported phrases for each hack). Also, it will check to see if this upgrade has the IMPORT PHRASES step as part of the upgrade. If so, and if the hack has existing phrases, it will remove all phrases and the database columns / rows made for those phrases, rebuild all languages, and then during the IMPORT PHRASES step it will import all phrases again, in an orderly fashion as usual.
4) next, the same for templates. If the upgrade .htl has the import templates step, it will check for the existance of templates for the old version of the hack, and if they exist, remove them first and then reimport the new ones.
5) same for settings;
6) now, we are still actually _before_ step 1 of the HTL install routine at this point, the only thing we may have had happen is that things were removed in preparation of being re-added later on in the 'install' (upgrade) of this hack. So at this point, we will do a REPLACE INTO query on the hack table to update our hack with the newest version. THEN we will continue with the rest of the installation, and if there is nothing else to do, we just forward straight away to the Upgrade Complete page.
Does that sound good, people?