Skip to content

Commit

Permalink
Add default value to activity.parent_changed column. Fixes #1283
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Oct 19, 2016
1 parent c87ad22 commit 9a2ac70
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ public function manageRecordUpdate($tableName, $recordData, $activityEntryMode =
$deltaRecordData = $recordIsNew ? [] : array_intersect_key((array)$parentRecordWithForeignKeys, (array)$fullRecordData);

switch ($activityEntryMode) {

// Activity logging is enabled, and I am a nested action
case self::ACTIVITY_ENTRY_MODE_CHILD:
$logEntryAction = $recordIsNew ? DirectusActivityTableGateway::ACTION_ADD : DirectusActivityTableGateway::ACTION_UPDATE;
Expand All @@ -157,6 +156,7 @@ public function manageRecordUpdate($tableName, $recordData, $activityEntryMode =
'parent_table' => isset($parentData['table_name']) ? $parentData['table_name'] : null,
'data' => json_encode($fullRecordData),
'delta' => json_encode($deltaRecordData),
'parent_changed' => (int)$parentRecordChanged,
'row_id' => $rowId,
'identifier' => $this->findRecordIdentifier($schemaArray, $fullRecordData),
'logged_ip' => isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function up()
$t->column('delta', 'text', ['null' => true]);
$t->column('parent_id', 'integer', ['unsigned' => true, 'default' => NULL]);
$t->column('parent_table', 'string', ['limit' => 100]);
$t->column('parent_changed', 'tinyinteger', ['limit' => 1, 'null' => false, 'comment' => 'Did the top-level record in the change set alter (scalar values/many-to-one relationships)? Or only the data within its related foreign collection records? (*toMany)']);
$t->column('parent_changed', 'tinyinteger', ['limit' => 1, 'null' => false, 'default' => 0, 'comment' => 'Did the top-level record in the change set alter (scalar values/many-to-one relationships)? Or only the data within its related foreign collection records? (*toMany)']);
$t->column('datetime', 'datetime', ['default' => NULL]);
$t->column('logged_ip', 'string', ['limit' => 20, 'default' => NULL]);
$t->column('user_agent', 'string', ['limit' => 256]);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
use Ruckusing\Migration\Base as Ruckusing_Migration_Base;

class ChangeDirectusPrivilegesNavListedDefaultValue extends Ruckusing_Migration_Base
{
public function up()
{
if ($this->has_column('directus_activity', 'parent_changed')) {
$this->change_column('directus_activity', 'parent_changed', 'tinyinteger', [
'limit' => 1,
'null' => false,
'default' => 0,
'comment' => 'Did the top-level record in the change set alter (scalar values/many-to-one relationships)? Or only the data within its related foreign collection records? (*toMany)'
]);
}
}//up()

public function down()
{
if ($this->has_column('directus_activity', 'parent_changed')) {
$this->change_column('directus_activity', 'parent_changed', 'tinyinteger', [
'limit' => 1,
'null' => false,
'comment' => 'Did the top-level record in the change set alter (scalar values/many-to-one relationships)? Or only the data within its related foreign collection records? (*toMany)'
]);
}
}//down()
}
2 changes: 1 addition & 1 deletion api/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ CREATE TABLE `directus_activity` (
`delta` text NOT NULL,
`parent_id` int unsigned DEFAULT NULL,
`parent_table` varchar(100) DEFAULT NULL,
`parent_changed` tinyint(1) NOT NULL COMMENT 'Did the top-level record in the change set alter (scalar values/many-to-one relationships)? Or only the data within its related foreign collection records? (*toMany)',
`parent_changed` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Did the top-level record in the change set alter (scalar values/many-to-one relationships)? Or only the data within its related foreign collection records? (*toMany)',
`datetime` datetime DEFAULT NULL,
`logged_ip` varchar(20) DEFAULT NULL,
`user_agent` varchar(256) DEFAULT NULL,
Expand Down

0 comments on commit 9a2ac70

Please sign in to comment.