Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
justinfreeman (Agileware)
Core
Commits
4a423b7a
Commit
4a423b7a
authored
11 years ago
by
Deepak Srivastava
Browse files
Options
Downloads
Patches
Plain Diff
CRM-13302
parent
31c270e1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
CRM/Logging/Schema.php
+31
-16
31 additions, 16 deletions
CRM/Logging/Schema.php
with
31 additions
and
16 deletions
CRM/Logging/Schema.php
+
31
−
16
View file @
4a423b7a
...
...
@@ -232,10 +232,9 @@ AND TABLE_NAME LIKE 'log_civicrm_%'
private
function
_getColumnQuery
(
$col
,
$createQuery
)
{
$line
=
preg_grep
(
"/^ `
$col
` /"
,
$createQuery
);
$line
=
substr
(
array_pop
(
$line
),
0
,
-
1
);
$line
=
rtrim
(
array_pop
(
$line
),
','
);
// CRM-11179
$line
=
self
::
fixTimeStampAndNotNullSQL
(
$line
);
$line
=
$this
->
fixTimeStampAndNotNullSQL
(
$line
);
return
$line
;
}
...
...
@@ -363,26 +362,42 @@ WHERE table_schema IN ('{$this->db}', '{$civiDB}')";
return
$columnSpecs
[
$table
];
}
private
function
columnsWithDiffSpecs
(
$
t
able
1
,
$
t
able
2
)
{
$c
ol
Specs
1
=
$this
->
columnSpecsOf
(
$
t
able
1
);
$
col
Specs
2
=
$this
->
columnSpecsOf
(
$
t
able
2
);
function
columnsWithDiffSpecs
(
$
civiT
able
,
$
logT
able
)
{
$c
iviTable
Specs
=
$this
->
columnSpecsOf
(
$
civiT
able
);
$
logTable
Specs
=
$this
->
columnSpecsOf
(
$
logT
able
);
$diff
=
array
(
'ADD'
=>
array
(),
'MODIFY'
=>
array
(),
'OBSOLETE'
=>
array
());
foreach
(
$colSpecs1
as
$key
=>
$val
)
{
if
(
!
empty
(
array_diff
(
$colSpecs1
[
$key
],
$colSpecs2
[
$key
]))
&&
$key
!=
'id'
)
{
// ignore id column for any spec changes, to avoid any auto-increment mysql errors
$diff
[
'MODIFY'
][]
=
$key
;
// columns to be added
$diff
[
'ADD'
]
=
array_diff
(
array_keys
(
$civiTableSpecs
),
array_keys
(
$logTableSpecs
));
// columns to be modified
// NOTE: we consider only those columns for modifications where there is a spec change, and that the column definition
// wasn't deliberately modified by fixTimeStampAndNotNullSQL() method.
foreach
(
$civiTableSpecs
as
$col
=>
$colSpecs
)
{
if
(
!
empty
(
array_diff
(
$civiTableSpecs
[
$col
],
$logTableSpecs
[
$col
]))
&&
$col
!=
'id'
)
{
// ignore 'id' column for any spec changes, to avoid any auto-increment mysql errors
if
(
$civiTableSpecs
[
$col
][
'DATA_TYPE'
]
!=
$logTableSpecs
[
$col
][
'DATA_TYPE'
])
{
// if data-type is different, surely consider the column
$diff
[
'MODIFY'
][]
=
$col
;
}
else
if
(
$civiTableSpecs
[
$col
][
'IS_NULLABLE'
]
!=
$logTableSpecs
[
$col
][
'IS_NULLABLE'
]
&&
$logTableSpecs
[
$col
][
'IS_NULLABLE'
]
==
'NO'
)
{
// if is-null property is different, and log table's column is NOT-NULL, surely consider the column
$diff
[
'MODIFY'
][]
=
$col
;
}
else
if
(
$civiTableSpecs
[
$col
][
'COLUMN_DEFAULT'
]
!=
$logTableSpecs
[
$col
][
'COLUMN_DEFAULT'
]
&&
!
strstr
(
$civiTableSpecs
[
$col
][
'COLUMN_DEFAULT'
],
'TIMESTAMP'
))
{
// if default property is different, and its not about a timestamp column, consider it
$diff
[
'MODIFY'
][]
=
$col
;
}
}
}
// columns to be added
$diff
[
'ADD'
]
=
array_diff
(
array_keys
(
$colSpecs1
),
array_keys
(
$colSpecs2
));
// columns to be dropped
$oldCols
=
array_diff
(
array_keys
(
$colSpecs2
),
array_keys
(
$colSpecs1
));
// columns to made obsolete by turning into not-null
$oldCols
=
array_diff
(
array_keys
(
$logTableSpecs
),
array_keys
(
$civiTableSpecs
));
foreach
(
$oldCols
as
$col
)
{
if
(
!
in_array
(
$col
,
array
(
'log_date'
,
'log_conn_id'
,
'log_user_id'
,
'log_action'
))
&&
CRM_Utils_Array
::
value
(
'IS_NULLABLE'
,
$colSpecs2
[
$col
])
==
'NO'
)
{
$logTableSpecs
[
$col
][
'IS_NULLABLE'
]
==
'NO'
)
{
// if its a column present only in log table, not among those used by log tables for special purpose, and not-null
$diff
[
'OBSOLETE'
][]
=
$col
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment