Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. describe database table columns in "Fields" array:
    1. make "db_type" field option used to describe database type (e.g. "varchar(255)") required
    2. add new optional "db_extra" field option of array type, where "auto_increment" and other db column options are defined
  2. describe index structure in the new "Indexes" unit config option like so (the field specified in "IDField" of unit config is automatically assigned an "auto_increment" db extra and added as primary key): 

    Code Block
    'Indexes' => array(
    	'IDX_INDEX_NAME' => array(
    		'columns' => array('DBColumn1', 'DBColumn2'),
    		'unique' => true,
    	),
    ),
  3. create the "in-portal db:sync" command, that will:
    1. create missing database tables
    2. change structure of existing tables to match one from unit config (but won't delete columns/tables, because of performance)
    3. integrate code, that creates multi-lingual columns (e.g. "l1_Name") into this command
  4. replace "Rebuild Multilingual Fields" action on "System Tools" page with "Rebuild Database Structure" action that would call above created command
  5. run above created command before SQL migrations during deploy
  6. if table column has association with another database table, then define it via new "foreign_key" field option (won't be used for now) like so: 

    Code Block
    'Fields' => array(
        'ItemResourceId' => array(
            'type' => 'int',
            ...,
            'default' => null, 'foreign_key' => 'l:ResourceId'
        ),
    ),

Problems

  • existing unit configs might be already not in sync with db and attempting to mass convert db based on unit configs might make things worse
  • none of unit configs have "db_type" and we have lots of tables/fields to populate them automatically
  • not sure how to handle data transformations during automatic structure change, e.g.:
    • column allows "null", but we're changing it to "not null" and that will cause SQL error for existing records
    • string column contains string, but we're changing column type to "int" and data needs to be converted

Related Discussions

...