Thanks @satish.dvnk. It would be helpful if you mention, in each individual commit, the issue(s) which it addresses. That way it is easy to check and reference what each commit is actually for... You can make multiple small commits, then create one merge request from all of them. ;-)
@satish.dvnk. As I mentioned earlier, I think you need to add the status column in the 650_to_660.php file. Please read line 73 of this file:
$workflowModel->set('status', 1);
I also believe you have a typo in your code to create the new column...
$columns = $db->getColumnNames('com_vtiger_workflows'); if (in_array('status', $columns)) { $db->pquery('ALTER TABLE com_vtiger_workflows MODIFY COLUMN status INT(11)', array()); $db->pquery('ALTER TABLE com_vtiger_workflows ALTER COLUMN status SET DEFAULT 1', array()); $db->pquery('UPDATE com_vtiger_workflows SET status=? WHERE status IS NULL', array(1)); }
Should that not be if (!in_array('status', $columns)) { ... ?
(Note the "!")
Why are you not "ADDing" the column? It does not exist in a 6.5.0 database?
Why is this column INT(11)? Is this purely a 0 or 1 status flag? If so it should be a TINYINT
I notice another typo (incorrect "ALTER" in 2nd position - should be MODIFY or CHANGE):
$db->pquery('ALTER TABLE com_vtiger_workflows ALTER COLUMN status SET DEFAULT 1', array());
Please, check these things ;-)
You can also do both the SET DEFAULT and CHANGE the TYPE in one query rather than two.
@satish.dvnk That looks better. but presumably you should repeat the line $db->pquery('UPDATE com_vtiger_workflows SET status=? WHERE status IS NULL', array(1)); after the ADD COLUMN statement?
Is this script trying to set the "status" column? If so then this file 650_to_660 runs before the 660_to_700 so it will not work as the status column has not yet been created.
That looks better. but presumably you should repeat the line
$db->pquery('UPDATE com_vtiger_workflows SET status=? WHERE status IS NULL', array(1));
No need to repeat @lord_alan, here 1 will be default value. So while adding column to a table, default value 1 sit as column value for every row in that table.
Yes, but will the $workflowModel->save(); actually do anything at all because the column doesn't exist in the database yet? Surely the db query to save the Workflow modification will not work; the script might not die but the Workflow changes will not be saved?