CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • extension table naming convention and/or requirement?
Pages: [1]

Author Topic: extension table naming convention and/or requirement?  (Read 1195 times)

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
extension table naming convention and/or requirement?
February 04, 2014, 03:53:02 am
I have a new extension that creates it's own tables. I'd assumed that it would be appropriate to prefix these table names with "civicrm_", so that in cases where CiviCRM shares a database with the CMS, the table clearly belongs to civicrm.

Unfortunately, that means that the extended logging feature in civicrm (this: https://civicrm.org/blogs/shot/new-civicrm-33-feature-logging) breaks.

The specific message is:

Code: [Select]
Table 'dev18_crmlog.log_civicrm_iats_customer_codes' doesn't exist
The table my extension creates is "civicrm_iats_customer_codes".

I don't know much about this logging, and only found out about thanks to Sarah Gladstone's testing of my extension (iATS Payments), but it seems like an important question to answer.

My preference would be to keep with my current naming convention, but do something to allow my tables to also have the feature logging working, so if that's an option, i guess I just need to tell CiviCRM more about my table, or perhaps this is just something that the extensions infrastructure should be handling?

On the other hand, it looks like the whole extended logging has been abandoned:

http://issues.civicrm.org/jira/browse/CRM-7164

and maybe just shouldn't be used at all?
« Last Edit: February 04, 2014, 05:22:09 am by adixon »

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: extension table naming convention and/or requirement?
February 04, 2014, 08:29:09 am
I suspect the status on CRM-7164 is more of a clerical error -- the feature is really part of Civi, and from time-to-time we do some development/fixing that involves it.

FWIW, in CiviHR's org.civicrm.hrjob extension, we added some new tables and did some development to take advantage of logging on those tables. A couple theories on why it's worked there but not here:

1. Different order of operations. When I set up a devbuild for CiviHR, I first install all the extensions, and then (sometimes) enable logging afterward. But that means the extension tables already exist when logging is activated. If you first enable logging and then enable the extension, it might work out differently.
2. The hrjob extension includes hook_civicrm_entityTypes which defines metadata for the new entities. I don't think this metadata is used by the logging system, but I haven't strictly tested/evaluated that... so maybe it helps.

As a couple possible fixes you might try (on a testing/staging machine):

1. Disable and re-enable logging
2. Run: drush eval 'civicrm_initialize(); $logging = new CRM_Logging_Schema(); $logging->fixSchemaDifferences(TRUE);'

adixon

  • I post frequently
  • ***
  • Posts: 314
  • Karma: 19
    • Blackfly Solutions
Re: extension table naming convention and/or requirement?
April 02, 2014, 01:34:49 pm
Thanks for your note, here's what I found:

1. The order matters - if you enable the extended logging after the extension is enabled, you're okay.
2. It doesn't create log tables for my tables that are named civicrm_iats_request_log and civicrm_iats_response_log. Which is actually awesome!

Conclusion: extended logging++

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • extension table naming convention and/or requirement?

This forum was archived on 2017-11-26.