"Fossies" - the Fresh Open Source Software Archive

Member "matomo/plugins/CustomDimensions/Updates/0.1.2.php" (3 Aug 2022, 2163 Bytes) of package /linux/www/matomo-4.11.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 <?php
    2 /**
    3  * Matomo - free/libre analytics platform
    4  *
    5  * @link https://matomo.org
    6  * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
    7  *
    8  */
    9 
   10 namespace Piwik\Plugins\CustomDimensions;
   11 
   12 use Piwik\Updater;
   13 use Piwik\Updates as PiwikUpdates;
   14 use Piwik\Updater\Migration\Factory as MigrationFactory;
   15 
   16 /**
   17  * Update for version 0.1.2.
   18  */
   19 class Updates_0_1_2 extends PiwikUpdates
   20 {
   21 
   22     /**
   23      * @var MigrationFactory
   24      */
   25     private $migration;
   26 
   27     public function __construct(MigrationFactory $factory)
   28     {
   29         $this->migration = $factory;
   30     }
   31 
   32     /**
   33      * Return SQL to be executed in this update.
   34      *
   35      * SQL queries should be defined here, instead of in `doUpdate()`, since this method is used
   36      * in the `core:update` command when displaying the queries an update will run. If you execute
   37      * queries directly in `doUpdate()`, they won't be displayed to the user.
   38      *
   39      * @param Updater $updater
   40      * @return array ```
   41      *               array(
   42      *                   'ALTER .... ' => '1234', // if the query fails, it will be ignored if the error code is 1234
   43      *                   'ALTER .... ' => false,  // if an error occurs, the update will stop and fail
   44      *                                            // and user will have to manually run the query
   45      *               )
   46      *               ```
   47      */
   48     public function getMigrations(Updater $updater)
   49     {
   50         return array(
   51             // ignore existing column name error (1060)
   52             $this->migration->db->addColumn('custom_dimensions', 'case_sensitive', 'TINYINT UNSIGNED NOT NULL DEFAULT 1', 'extractions')
   53         );
   54     }
   55 
   56     /**
   57      * Perform the incremental version update.
   58      *
   59      * This method should perform all updating logic. If you define queries in an overridden `getMigrationQueries()`
   60      * method, you must call {@link Updater::executeMigrationQueries()} here.
   61      *
   62      * See {@link Updates} for an example.
   63      *
   64      * @param Updater $updater
   65      */
   66     public function doUpdate(Updater $updater)
   67     {
   68         $updater->executeMigrations(__FILE__, $this->getMigrations($updater));
   69     }
   70 }