Two domains, one MT3S bundle: Marketing Programs (unchanged) and the
imported Smart Links (smart links + UTM taxonomies), each keeping its
own menu, tables, routes and translations.
- Code moved from MauticPlugin\SmartlinksBundle\ to
MauticPlugin\MT3SMarketingProgramBundle\; template namespace
@Smartlinks/ -> @MT3SMarketingProgram/; smartlinks.js ->
Assets/js/mt3s-mp-smartlinks.js; icon -> Assets/img/smartlinks-icon.svg.
- Incoming migrations renamed Version_0_X_0_SmartLinks.php to avoid
the class-name collision; schema untouched, data intact.
- Permissions folded into MT3SMarketingProgramPermissions:
smart_links + taxonomies under the mt3smarketingprogram: base
(roles that had the old smartlinks: grants must be re-granted).
- config.php: Smart Links routes + menu group, public /l/{slug},
SmartlinksIntegration services, smartlinks_* parameters (legacy
utm_manager_* keys still readable), version 0.18.0. The 0.17.0
placeholder /s/marketing-program-utm-taxonomies is replaced by the
real /s/utm-taxonomies.
- Translations merged (en_US) and added (fr_FR); Tests/ + phpunit moved
in; readme documents both domains and the 0.18.0 merge history.
Verified live: menus, both config tabs, both lists + forms, program
pages, public redirect with taxonomy UTM values, host + unknown-slug
404s, 90/90 unit tests, full php -l, all ini catalogs parse.
73 lines
2.8 KiB
PHP
73 lines
2.8 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
|
use MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLinkHit;
|
|
|
|
/**
|
|
* Creates the Smart Link hits table (one row per call of a short link) for installs of
|
|
* version 0.2.0, which predate the redirect feature.
|
|
*
|
|
* The plugin installer creates the tables of fresh installs (installPluginSchema runs
|
|
* SchemaTool on the plugin's own entities); on update core only runs these migrations.
|
|
* Idempotent: runs on plugin update (core's migration engine) and right after a fresh
|
|
* install (PluginInstallSubscriber), and stops when the table already exists.
|
|
*/
|
|
class Version_0_3_0_SmartLinks extends AbstractMigration
|
|
{
|
|
protected function isApplicable(Schema $schema): bool
|
|
{
|
|
return !$schema->hasTable($this->concatPrefix(SmartLinkHit::TABLE_NAME));
|
|
}
|
|
|
|
protected function up(): void
|
|
{
|
|
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
|
|
|
|
$table = $this->concatPrefix(SmartLinkHit::TABLE_NAME);
|
|
|
|
$this->addSql(<<<SQL
|
|
CREATE TABLE {$table} (
|
|
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
|
|
is_published TINYINT(1) NOT NULL,
|
|
smart_link_id INT UNSIGNED NOT NULL,
|
|
date_added DATETIME DEFAULT NULL,
|
|
created_by INT DEFAULT NULL,
|
|
created_by_user VARCHAR(191) DEFAULT NULL,
|
|
date_modified DATETIME DEFAULT NULL,
|
|
modified_by INT DEFAULT NULL,
|
|
modified_by_user VARCHAR(191) DEFAULT NULL,
|
|
checked_out DATETIME DEFAULT NULL,
|
|
checked_out_by INT DEFAULT NULL,
|
|
checked_out_by_user VARCHAR(191) DEFAULT NULL,
|
|
ip_address VARCHAR(45) DEFAULT NULL,
|
|
referer LONGTEXT DEFAULT NULL,
|
|
user_agent LONGTEXT DEFAULT NULL,
|
|
INDEX smart_link_hit_link (smart_link_id),
|
|
PRIMARY KEY(id)
|
|
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
|
|
SQL);
|
|
|
|
$this->addSql($this->generateAlterTableForeignKeyStatement(
|
|
SmartLinkHit::TABLE_NAME,
|
|
['smart_link_id'],
|
|
$this->resolveLinksTableName($schema),
|
|
['id'],
|
|
'ON DELETE CASCADE'
|
|
));
|
|
}
|
|
|
|
/**
|
|
* The links table under the name it has right now: Version_0_5_0 renames utm_smart_links to
|
|
* smart_links, and an update from 0.2.0 runs this migration before the rename.
|
|
*/
|
|
private function resolveLinksTableName(Schema $schema): string
|
|
{
|
|
return $schema->hasTable($this->concatPrefix('smart_links')) ? 'smart_links' : 'utm_smart_links';
|
|
}
|
|
}
|