Versioning with SVN and SQL inserts
From LeonWiki!
Strategy/Definitions/Use Case
- We have two main server instances
- Only content is added/modified on production.
- ALL other changes are done on dev.
- Staging is ONLY for testing/sign-off for release to production and ALWAYS contains the versioned codebase.
- Use Case
- Content has been added on production
- Staging
- New/modified features (components/modules/menus) have been added on dev
- Do a joomlapack backup, download to staging server and overlay on versioned code.
- Make sure desired checkins on dev are done.
- Do a subversion update on staging workspace.
- Do a merge with source=dev and target=staging.
Versioning/Updating the codebase and database
- Initial setup (this MUST be done each time because production will have added content) to establish code/database baseline
-
- Take a joomlapack backup of the current production codebase.
- First time -- install the production backup to a tmp directory where the files will be imported into subversion.
- Checkout baselined-code to the working stage directory : <sandbox-domain>/staging/<context>
- Go to the <sandbox-domain>/dev/<context> and checkout baselined code.
- This is only performed the very first time: Copy <sandbox-domain>/<context> files, which contain the recently changed code under development to <sandbox-domain>/dev/<context>.
- Perform joomla web install on staging directory.
- Perform merge with source=dev and target=staging.
- Subsequent times -- install the joomlapack backup to staging (overwriting existing versioned files)
- NOTE: There shouldn't be any changes to the codebase since components/modules/plugins should NEVER be added in production
- If for some reason that had to be done then commit new files that have come from production to the repostitory.
- Update changed files to <sandbox-domain>/dev/<context>.
- Perform merge with source=staging and target=dev
- Perform joomla web install on staging directory.
- Perform merge with source=dev and target=staging.
- Now staging and dev should be synchronized. Don't forget to make any appropriate changes to configuration.php located in the root of the context. NOTE: Any files changed on dev for existing records will not overwrite the staging record with the same ID. This is intended as we cannot be overwriting records on staging with dev records (we shouldn't be changing any records that content providers have created but we don't know 100% positive that this is true), since that is what came from production. One solution to this problem is to implement a database table exclusion list based on regular expressions. In studying the database tables it seems everything is very segmented, e.g. the content is contained in jos_content, and all the components and modules have their own tables. Hence, if it's necessary to configure existing components/modules, all we'd have to do is keep track of the component/module that we changed and add that to the exclusion list. Then any tables that are on the exclusion list will have an insert replace sql statement instead of a insert ignore. Insert replace will replace the target record with the source record of the same unique ID, whereas insert ignore will not.
- Now we have a snapshot of production in staging/<context> and a snapshot of development in dev/<context> each with their own database.
- What is the process for everyday working environment?
-
- Daily development process
-
- At any point where there is working code, checkin the changed code to subversion.
- Periodic reconciliation of dev to staging (code and database)
-
- Go to the versioned staging directory and perform a subversion update
- Perform merge with source=dev and target=staging