TableManager and DataManager in WhatACart

With any software project which is database driven, for the installation of the project a sql script is created which would run behind the scenes to install the database.

So assuming a project has a sql script in place. A new module is added and it requires few tables to be added and some data to be added. So there are two ways

  • Update sql script with new tables and data
  • Another way which works as a plugin into the system

The first approach is not easy to maintain from our point of view hence we decided to go with the second approach and because of which table manager and data manager concept comes into the picture. So take example of Manufacturer module. It has got

  • TableManager which consist of tables that needs to be build for the module
  • ManufacturerTableBuilder which consist of table fields with definition and indexes
  • ManufacturerDataManager having the default data installed with the application. You could add the demo data as well if needed.

In case after the install of the application, you have added a module having some tables and default data than no need to reinstall the application or do the manual addition. For that we can use

  1. TableController – This would build the table through
    1. yii table/build {tableManagerClassName} (This would rebuild all the tables)
    2. yii table/add {builderClassName}(This would build a specific table)
  2. DataController  – This would install the data by running yii data/index {dataManagerClassName}

Leave a Reply

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