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
c28241be
Commit
c28241be
authored
12 years ago
by
lobo
Browse files
Options
Downloads
Patches
Plain Diff
fix CRM-12002
parent
5af3d504
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Logging/Schema.php
+13
-10
13 additions, 10 deletions
CRM/Logging/Schema.php
CRM/Upgrade/Incremental/php/FourThree.php
+98
-88
98 additions, 88 deletions
CRM/Upgrade/Incremental/php/FourThree.php
with
111 additions
and
98 deletions
CRM/Logging/Schema.php
+
13
−
10
View file @
c28241be
...
...
@@ -196,7 +196,7 @@ AND TABLE_NAME LIKE 'log_civicrm_%'
$line
=
preg_grep
(
"/^ `
$col
` /"
,
$create
);
$line
=
substr
(
array_pop
(
$line
),
0
,
-
1
);
// CRM-11179
$line
=
self
::
fixTimeStampSQL
(
$line
);
$line
=
self
::
fixTimeStamp
AndNotNull
SQL
(
$line
);
CRM_Core_DAO
::
executeQuery
(
"ALTER TABLE `
{
$this
->
db
}
`.log_
$table
ADD
$line
"
);
}
...
...
@@ -207,10 +207,11 @@ AND TABLE_NAME LIKE 'log_civicrm_%'
}
}
function
fixTimeStampSQL
(
$query
)
{
function
fixTimeStamp
AndNotNull
SQL
(
$query
)
{
$query
=
str_ireplace
(
"TIMESTAMP NOT NULL"
,
"TIMESTAMP NULL"
,
$query
);
$query
=
str_ireplace
(
"DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"
,
''
,
$query
);
$query
=
str_ireplace
(
"DEFAULT CURRENT_TIMESTAMP"
,
''
,
$query
);
$query
=
str_ireplace
(
"NOT NULL"
,
''
,
$query
);
return
$query
;
}
...
...
@@ -287,25 +288,27 @@ AND TABLE_NAME LIKE 'log_civicrm_%'
$query
=
$dao
->
Create_Table
;
// rewrite the queries into CREATE TABLE queries for log tables:
// - prepend the name with log_
// - drop AUTO_INCREMENT columns
// - drop non-column rows of the query (keys, constraints, etc.)
// - set the ENGINE to ARCHIVE
// - add log-specific columns (at the end of the table)
$cols
=
<<<COLS
log_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
log_conn_id INTEGER,
log_user_id INTEGER,
log_action ENUM('Initialization', 'Insert', 'Update', 'Delete')
COLS;
// - prepend the name with log_
// - drop AUTO_INCREMENT columns
// - drop non-column rows of the query (keys, constraints, etc.)
// - set the ENGINE to ARCHIVE
// - add log-specific columns (at the end of the table)
$query
=
preg_replace
(
"/^CREATE TABLE `
$table
`/i"
,
"CREATE TABLE `
{
$this
->
db
}
`.log_
$table
"
,
$query
);
$query
=
preg_replace
(
"/ AUTO_INCREMENT/i"
,
''
,
$query
);
$query
=
preg_replace
(
"/^ [^`].*$/m"
,
''
,
$query
);
$query
=
preg_replace
(
"/^\) ENGINE=[^ ]+ /im"
,
') ENGINE=ARCHIVE '
,
$query
);
// log_civicrm_contact.modified_date for example would always be copied from civicrm_contact.modified_date,
// so there's no need for a default timestamp and therefore we remove such default timestamps
by using fixTimeStampSQL() method,
//
before we inject special log columns with default timestamps
$query
=
self
::
fixTimeStampSQL
(
$query
);
// so there's no need for a default timestamp and therefore we remove such default timestamps
//
also eliminate the NOT NULL constraint, since we always copy and schema can change down the road)
$query
=
self
::
fixTimeStamp
AndNotNull
SQL
(
$query
);
$query
=
preg_replace
(
"/^\) /m"
,
"
$cols
\n
) "
,
$query
);
CRM_Core_DAO
::
executeQuery
(
$query
);
...
...
This diff is collapsed.
Click to expand it.
CRM/Upgrade/Incremental/php/FourThree.php
+
98
−
88
View file @
c28241be
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