Skip to content
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

CRM-20892 Add in modified_date column to civicrm_mailing to assist in… #10953

Merged
merged 3 commits into from
Sep 11, 2017

Conversation

seamuslee001
Copy link
Contributor

… preventing cross edit of mailings

Overview

This adds in the column modified_date column to civicrm_mailing in part to help fix the ability to prevent cross tab edits of mailings. Pulling this bit out to try to help keep the other PR from going stale as often

Comments

@eileenmcnaughton @totten @JKingsnorth i think this is what was suggested on #10864

@eileenmcnaughton
Copy link
Contributor

If Jenkins is happy with it I am

@eileenmcnaughton
Copy link
Contributor

Hmm he isn't

ERROR 1293 (HY000) at line 3729: Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause

@seamuslee001
Copy link
Contributor Author

So the issue is that both created and this new modifed_date have CURRENT_TIMESTAMP as default see https://stackoverflow.com/questions/4489548/why-there-can-be-only-one-timestamp-column-with-current-timestamp-in-default-cla

@eileenmcnaughton
Copy link
Contributor

Hmm contact table does this

created_date timestamp NULL DEFAULT NULL COMMENT 'When was the contact was created.',
modified_date timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When was the contact (or closely related entity) was created or modified or deleted.',

@seamuslee001
Copy link
Contributor Author

@totten any thoughts on the above?

@monishdeb
Copy link
Member

@seamuslee001 PR need rebase !

@totten
Copy link
Member

totten commented Sep 7, 2017

We discussed this a bit more on https://chat.civicrm.org/civicrm/pl/68cbe4pie3fufq7tgy9h3ebb3o ; TLDR: one column can use DEFAULT CURRENT_TIMESTAMP..., and the other column can use a SQL trigger like https://github.com/civicrm/civicrm-core/blob/4.7.25-rc/Civi/Core/Container.php#L211

@seamuslee001 seamuslee001 force-pushed the CRM-20892 branch 2 times, most recently from 431bd5f to 80d7658 Compare September 10, 2017 04:10
@seamuslee001
Copy link
Contributor Author

@monishdeb @totten @eileenmcnaughton i think i have it sorted now, created_date defaults to NULL but populated by trigger on insert and modifed_date UPATES to CURRENT_TIMESTAMP

'name' => 'modified_date',
'type' => CRM_Utils_Type::T_TIMESTAMP,
'title' => ts('Modified Date') ,
'description' => 'When was the mailing (or closely related entity) was created or modified or deleted.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra was

@@ -487,4 +487,14 @@
<type>Select</type>
</html>
</field>
<field>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if you move this right after created_date it will be in a more logical place in the table

@eileenmcnaughton
Copy link
Contributor

eileenmcnaughton commented Sep 10, 2017

I just tested this on a new install and it seems to be working at the mysql level. Oddly when I edit the mailing through the form rather than via mysql modified date does not update. I am guessing something in the form is setting modified_date.

I have not yet tested upgrade

…set it

Remove duplicate was

Move field around in table definition as per Eileen's comment
@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton i believe that i have fixed your issue now, please test Upgrade and let me know how you go. I think this part is probably right to be merged

@eileenmcnaughton
Copy link
Contributor

I did an upgrade test, checking out 4.7.25 & recreating & then checking out master, pulling this patch & upgrading and then added a new mailing & then edited it. Modified & created_date were correctly created/ updated.

Looks like an enotice issue remains but I'm giving this merge on pass

@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton tests has passed now

@eileenmcnaughton eileenmcnaughton merged commit d2c3675 into civicrm:master Sep 11, 2017
@eileenmcnaughton eileenmcnaughton deleted the CRM-20892 branch September 11, 2017 07:35
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Jun 17, 2021
On digging I determined this trigger hokiness was all about mysql
5.5 and we can ditch it now

https://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-5.html#mysqld-5-6-5-data-types

and civicrm#10953 (comment)

Note that we still support mysql 5.6 and the current version is 5.6.51

I think it's fine to require that the 5.6 minimum is 5.6.5 as released in 2012

I'll do the upgrade script as a follow up
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Jun 17, 2021
On digging I determined this trigger hokiness was all about mysql
5.5 and we can ditch it now

https://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-5.html#mysqld-5-6-5-data-types

and civicrm#10953 (comment)

Note that we still support mysql 5.6 and the current version is 5.6.51

I think it's fine to require that the 5.6 minimum is 5.6.5 as released in 2012

I'll do the upgrade script as a follow up
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Jun 17, 2021
On digging I determined this trigger hokiness was all about mysql
5.5 and we can ditch it now

https://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-5.html#mysqld-5-6-5-data-types

and civicrm#10953 (comment)

Note that we still support mysql 5.6 and the current version is 5.6.51

I think it's fine to require that the 5.6 minimum is 5.6.5 as released in 2012

I'll do the upgrade script as a follow up
eileenmcnaughton added a commit to eileenmcnaughton/civicrm-core that referenced this pull request Jul 4, 2021
On digging I determined this trigger hokiness was all about mysql
5.5 and we can ditch it now

https://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-5.html#mysqld-5-6-5-data-types

and civicrm#10953 (comment)

Note that we still support mysql 5.6 and the current version is 5.6.51

I think it's fine to require that the 5.6 minimum is 5.6.5 as released in 2012

I'll do the upgrade script as a follow up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants