-
-
Notifications
You must be signed in to change notification settings - Fork 824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/core#2243 Add created_date column to the civicrm_note table #19738
Conversation
(Standard links)
|
3520ef1
to
0271f54
Compare
@jitendrapurohit can you fix the style issues https://test.civicrm.org/job/CiviCRM-Core-PR/39602/checkstyleResult/new/ |
0271f54
to
61af4c4
Compare
@jitendrapurohit Tested the created date functionality, its working fine. |
@jitendrapurohit Looks like test fail related? |
61af4c4
to
cb4c8e4
Compare
Yep. Test build is passing now 👍 |
@jitendrapurohit I agree with adding this field - but we have a pretty strong convention that the field created_date is a DB populated field normally and it it would normally hold the timestamp - I just added a note and having chosen not to enter the field it winds up empty - which is really against our convention. I guess it's OK to expose if for override but I don't think it should be OK for it to be blank for new entries (historical ones will be like the same field on civicrm_contact) - @mattwire - @seamuslee001 what do you think here? |
ok, agree with the naming of created_date. Probably, we should -
Does the above make sense? @eileenmcnaughton @sunilpawar @mattwire |
public function upgrade_5_37_alpha1($rev) { | ||
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev); | ||
$this->addTask('core-issue#2243 - Add created_date to civicrm_note', 'addColumn', | ||
'civicrm_note', 'created_date', "datetime DEFAULT NULL COMMENT 'When was the note created.'"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not be a timestamp?
@sunilpawar so we chatted on chat & I think the agreement (with @seamuslee001 & @kcristiano ) was
Normally we try to be standardised about having both modified_date and created_date where one is present. In this case modified_date is present & we should probably add created_date for consistency - but since you are not in the end touching either it's OK not to consider that in scope - the xml for the modified_date & created_date should look like the below (when both are present)
|
cb4c8e4
to
641032e
Compare
Based on the discussion with @eileenmcnaughton the latest update to the PR does the following -
|
CRM/Core/DAO/Note.php
Outdated
'description' => ts('When was this note last modified/edited'), | ||
'required' => TRUE, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about adding required here - that would impact what needs to be submitted at the apiv4 level I think (@colemanw to confirm)
I think it's OK just relying on the default
The code looks good - just needs r-run testing & clarification on the required |
@jitendrapurohit I was just thinking I should merge this before 5.37 is cut & then do the one fix that stalled this (#19738 (review)) as a follow up - but I discovered this is actually stale |
641032e
to
5bfc73d
Compare
@eileenmcnaughton Fixed the rebase conflicts and removed the required attribute for |
OK - that looks like the same code I tested minus the required - merging |
Hi there, With MariaDB 10.4 this breaks with the error: |
@J0WI under what circumstance does it break? It is possibly on upgrade because it is trying to access the field before it exists? |
At this point they already exist. I get the same error when I execute this manually: ALTER TABLE civicrm_note ADD COLUMN `note_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Date attached to the note';
ALTER TABLE civicrm_note ADD COLUMN `created_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'When the note was created';
UPDATE civicrm_note SET note_date = modified_date, created_date = modified_date, modified_date = modified_date; |
So there are 3 statements there - do the first 2 run OK & not the last one? |
Exactly. |
@J0WI - do you have data base logging enabled? ie is there a log_civicrm_note table? |
Yes |
@J0WI ok - so it will be the log_civicrm_note table that is missing the new field - if you can disable logging & re-enable it should create it |
Can this be included/fixed in the upgrade procedure? |
@J0WI I found someone else had reported what sounded like the same issue https://lab.civicrm.org/dev/core/-/issues/2961 - I put up a patch here #22150 - which I think would fix it - but I haven't tested the patch |
Overview
Add created_date column to the civicrm_note table
https://lab.civicrm.org/dev/core/-/issues/2243
Before
No date field to know when the note was added. Also, there's no UI field to control/update the date manually.
After
Date field added.
Is available on view -
Comments
API test added.