Let Plugins define Schema changes #4204

Closed
mattab opened this Issue Oct 8, 2013 · 4 comments

1 participant

@mattab
Piwik Open Source Analytics member

Plugin developers can create new tables in the database, or alter existing tables to add fields.

In this process, it is common requirement to also maintain schema versioning for plugins. Piwik plugins have this built in.

The schema version is the same as the plugin version. When you release a new plugin version you can bundle with it some schema changes.

How to do this:

  • If your plugin has schama changes in version 1.13, create a file in plugins/MyPlugin/Updates/1.13.php
  • This file contains a Updates_1_13 class
  • This class can run PHP code during the update, and you can implement the getSql() method to return sql code to execute.

See an example of Plugin Schema Update in the DevicesDetection plugin here.

@mattab
Piwik Open Source Analytics member

In 16f8dd6: Fixes #4203 DevicesDetection 1.14 version schema update to account for longer strings ( fields config_os_version and config_device_type are not large enough )

Refs #4204 Plugin schema example with DevicesDetection

@mattab
Piwik Open Source Analytics member

In ded987a: Fixes #4203 DevicesDetection 1.14 version schema update to account for longer strings ( fields config_os_version and config_device_type are not large enough )
Refs #4204 Plugin schema example with DevicesDetection

@mattab
Piwik Open Source Analytics member

In bbb8642: Refs #4204 Fix logic bug: setting Plugin schema version after they were successfully installed + should fix the build (thx ArchiveCronTest)

@mattab
Piwik Open Source Analytics member

In 20cdfcf: Refs #4204

@mattab mattab added this to the 2.0 - Piwik 2.0 milestone Jul 8, 2014
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab Fixes #4203 DevicesDetection 1.14 version schema update to account fo…
…r longer strings ( fields config_os_version and config_device_type are not large enough )

Refs #4204 Plugin schema example with DevicesDetection
16f8dd6
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab Fixes #4203 DevicesDetection 1.14 version schema update to account fo…
…r longer strings ( fields config_os_version and config_device_type are not large enough )

Refs #4204 Plugin schema example with DevicesDetection
ded987a
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab Refs #4204 Fix logic bug: setting Plugin schema version after they we…
…re successfully installed + should fix the build (thx ArchiveCronTest)
bbb8642
@sabl0r sabl0r pushed a commit to sabl0r/piwik that referenced this issue Sep 23, 2014
@mattab mattab Refs #4204 20cdfcf
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment