Monday, January 12, 2015

PHP application with Mysql database to a Django app with Postgres Database

Recently I had a chance to work on a project, where a PHP app had to be converted to a Django one.

The work seemed trivial, but it brought a few difficult technicalities. It had a Mysql DB, with few tables. Overall, I had to  -


  • Convert them into Django models
  • Convert the app into Django
  • Setup the app on Heroku using Postgres

  1. Converting the models to Django is easy. Django provides an inspectdb command. It looks at the current model structures, inspects it and provides django model accordingly.
  2. This is a nice feature. It gave me a push forward to begin the app development. However, this feature lacked some points that I would like to point out - 
    1. In Mysql, we have a set type . This is basically similar to choices in Django models. I had to manually do that. 
    2. The foreign key constraint is set to id by default. The command could check this and set the field in model declaration using to_field parameter.
    3. The DB views had to created manually. 
  3. For changing Mysql Data to Heroku, https://devcenter.heroku.com/articles/heroku-mysql is a good resource.
As always, heroku has to be provided with a S3 access to uploading of static and media files. But thats a different matter.

No comments:

Post a Comment