Moving from one version of a framework to another can be a daunting process especially when ‘living’ documentation is vague.  Cake provide a general migration guide but this how I’ve had success migrating from 1.3 to 2.0 in the past.

Step 1: Back Up.

I don’t know how you back up your site but do it NOW.   This could be to create a working version on your local server or by creating a duplicate site on your test server.  Which ever it is do it now, and don’t forget to download a copy of your DB and pop that in a safe place too.

Step 2: Idiot Check.

If you didn’t do step 1 at least make a copy of your database so you have that.  I’ve skipped it before to my peril.  In the next step you are going to copy file from the old version.

Step 3:  Download the latest version of CakePHP

You’ll need the latest version of Cake unzipped and ready on your computer.  I like to create a new working install on my test server and move the old files into it.

Step 4:  Merge the Old and New.

In this step you are coping files from your old version into the ‘virgin’ new version you have just unzipped.  I have copied across the following but if you have other app files such as Plugins you’ll want ot move those as well:

  • copy database.php into the Config folder.
  • copy across the Salts and Cipher seeds if you are using the Auth (maybe optional).
  • copy all the controllers into the Controller folder.
  • copy all the models into the Model folder
  • copy all the views into the View folder
  • you also need to copy across your webroot files taking great care NOT TO overwrite the index.php and test.php files.  So only copy the contents of css, js, files and img folders.

Step 5:  Run the Console upgrade script.

Now you can run the cake upgrade script which will update much of the app to version 2 for you.  The upgrade shell is described here but in simple terms, assuming you are in the app folder for the new version, just type the following.

../lib/Cake/Console/cake upgrade all

Now if you get lots of errors similar to

Warning Error: file_put_contents(/home/cims4sch/OPERA-System/OPERA.DEV2/app/View/appointments/stepfour.ctp): failed to open stream: Permission denied in [/home/cims4sch/OPERA-System/OPERA.DEV2/lib/Cake/Console/Command/UpgradeShell.php, line 741]

try repeating the process using sudo.

Step 6:  Make the required changes to the code.

There are still a few changes to make to bring the old system inline to the new.

  1. Update the database.php file so that it uses <code>datasource</code> not <code>driver</code>
  2. Move any core settings across such as salt values.
  3. Set the <code>tmp</code> folder so it is writable.



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.