Merge the Smartlinks plugin (SmartlinksBundle 0.6.0) into the bundle as the Smart Links domain (0.18.0)
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.
This commit is contained in:
1 parent
debce4ba4a
commit
dce849610c
69 files changed
+8225
-43
No files matched your search
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink;
|
||||
|
||||
/**
|
||||
* Creates the Smart Links table for installs of version 0.1.0, which predate the 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_2_0_SmartLinks extends AbstractMigration
|
||||
{
|
||||
protected function isApplicable(Schema $schema): bool
|
||||
{
|
||||
return !$schema->hasTable($this->concatPrefix(SmartLink::TABLE_NAME));
|
||||
}
|
||||
|
||||
protected function up(): void
|
||||
{
|
||||
$table = $this->concatPrefix(SmartLink::TABLE_NAME);
|
||||
|
||||
$this->addSql(<<<SQL
|
||||
CREATE TABLE {$table} (
|
||||
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
|
||||
is_published TINYINT(1) 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,
|
||||
slug VARCHAR(9) NOT NULL,
|
||||
redirect_type VARCHAR(20) DEFAULT 'external' NOT NULL,
|
||||
redirect_code INT DEFAULT 302 NOT NULL,
|
||||
destination_url LONGTEXT DEFAULT NULL,
|
||||
utm_parameters JSON NOT NULL,
|
||||
UNIQUE INDEX UNIQ_SLUG (slug),
|
||||
INDEX smart_link_slug (slug),
|
||||
PRIMARY KEY(id)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
|
||||
SQL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
<?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';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink;
|
||||
|
||||
/**
|
||||
* Adds the Mautic destinations to the Smart Links: a landing page or a standalone form.
|
||||
*
|
||||
* Idempotent: runs on plugin update (core's migration engine) and right after a fresh
|
||||
* install (PluginInstallSubscriber), and stops when the columns already exist.
|
||||
*/
|
||||
class Version_0_4_0_SmartLinks extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Local column => referenced core table.
|
||||
*/
|
||||
private const FOREIGN_KEYS = [
|
||||
'page_id' => 'pages',
|
||||
'form_id' => 'forms',
|
||||
];
|
||||
|
||||
protected function isApplicable(Schema $schema): bool
|
||||
{
|
||||
$table = $this->getTable($schema);
|
||||
|
||||
if (null === $table) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (array_keys(self::FOREIGN_KEYS) as $column) {
|
||||
if (!$table->hasColumn($column)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return [] !== $this->getMissingForeignKeys($table);
|
||||
}
|
||||
|
||||
protected function up(): void
|
||||
{
|
||||
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
|
||||
$table = $this->getTable($schema);
|
||||
|
||||
if (null === $table) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (array_keys(self::FOREIGN_KEYS) as $column) {
|
||||
if (!$table->hasColumn($column)) {
|
||||
$this->addSql(sprintf(
|
||||
'ALTER TABLE %s ADD %s INT UNSIGNED DEFAULT NULL',
|
||||
$this->concatPrefix(SmartLink::TABLE_NAME),
|
||||
$column
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getMissingForeignKeys($table) as $column => $referenceTable) {
|
||||
$this->addSql($this->generateAlterTableForeignKeyStatement(
|
||||
SmartLink::TABLE_NAME,
|
||||
[$column],
|
||||
$referenceTable,
|
||||
['id'],
|
||||
'ON DELETE SET NULL'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private function getTable(Schema $schema): ?Table
|
||||
{
|
||||
$name = $this->concatPrefix(SmartLink::TABLE_NAME);
|
||||
|
||||
return $schema->hasTable($name) ? $schema->getTable($name) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function getMissingForeignKeys(Table $table): array
|
||||
{
|
||||
$missing = self::FOREIGN_KEYS;
|
||||
|
||||
foreach ($table->getForeignKeys() as $foreignKey) {
|
||||
foreach ($foreignKey->getLocalColumns() as $column) {
|
||||
unset($missing[$column]);
|
||||
}
|
||||
}
|
||||
|
||||
return $missing;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\DBAL\Schema\Table;
|
||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLinkHit;
|
||||
|
||||
/**
|
||||
* The 0.5.0 rename of the plugin (UTM Manager -> Smartlinks) also renames its tables and their
|
||||
* indexes: utm_smart_links -> smart_links and utm_smart_link_hits -> smart_link_hits.
|
||||
*
|
||||
* Mautic syncs the plugin schema before running the migrations, so the new tables usually
|
||||
* already exist (empty, straight from the entity metadata) when this runs: the rows are copied
|
||||
* from the old tables, which are then dropped (hits first: they still reference the old links
|
||||
* table). When the new tables don't exist yet (a plugin update without the schema sync) the old
|
||||
* tables are renamed instead, which keeps the rows, the foreign keys and the indexes.
|
||||
*
|
||||
* Installs updated from 0.3.0 skipped the Mautic destinations of Version_0_4_0, which looks for
|
||||
* the table under its new name: the page_id / form_id columns and their foreign keys are
|
||||
* re-checked here so every install converges to the same schema.
|
||||
*
|
||||
* Idempotent: runs on plugin update (core's migration engine) and right after a fresh install
|
||||
* (PluginInstallSubscriber), and stops when nothing is left to rename, copy or add.
|
||||
*/
|
||||
class Version_0_5_0_SmartLinks extends AbstractMigration
|
||||
{
|
||||
private const RENAMED_TABLES = [
|
||||
'utm_smart_links' => 'smart_links',
|
||||
'utm_smart_link_hits' => 'smart_link_hits',
|
||||
];
|
||||
|
||||
private const RENAMED_INDEXES = [
|
||||
'utm_smart_link_slug' => 'smart_link_slug',
|
||||
'utm_smart_link_hit_link' => 'smart_link_hit_link',
|
||||
];
|
||||
|
||||
/** Local column => referenced core table (the Mautic destinations of Version_0_4_0). */
|
||||
private const MAUTIC_DESTINATIONS = [
|
||||
'page_id' => 'pages',
|
||||
'form_id' => 'forms',
|
||||
];
|
||||
|
||||
protected function isApplicable(Schema $schema): bool
|
||||
{
|
||||
foreach (array_keys(self::RENAMED_TABLES) as $old) {
|
||||
if ($schema->hasTable($this->concatPrefix($old))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$links = $this->findLinksTable($schema);
|
||||
if (null !== $links) {
|
||||
foreach (array_keys(self::MAUTIC_DESTINATIONS) as $column) {
|
||||
if (!$links->hasColumn($column)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if ([] !== $this->getOldIndexes($links) || [] !== $this->getMissingForeignKeys($links)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
$hits = $this->findHitsTable($schema);
|
||||
|
||||
return null !== $hits && [] !== $this->getOldIndexes($hits);
|
||||
}
|
||||
|
||||
protected function up(): void
|
||||
{
|
||||
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
|
||||
|
||||
$emptied = [];
|
||||
|
||||
foreach (self::RENAMED_TABLES as $old => $new) {
|
||||
$oldTable = $this->findTable($schema, $old);
|
||||
$newTable = $this->findTable($schema, $new);
|
||||
|
||||
if (null === $oldTable) {
|
||||
continue; // nothing left under the old name
|
||||
}
|
||||
|
||||
if (null === $newTable) {
|
||||
// No schema sync ran: rename keeps the rows, the foreign keys and the indexes.
|
||||
$this->addSql(sprintf('RENAME TABLE %s TO %s', $this->concatPrefix($old), $this->concatPrefix($new)));
|
||||
continue;
|
||||
}
|
||||
|
||||
// The schema sync already created the new table (empty): copy the rows over, then
|
||||
// drop the old table. Hits reference links, so everything is copied before the
|
||||
// first DROP (see below).
|
||||
$columns = implode(', ', array_intersect(
|
||||
array_keys($newTable->getColumns()),
|
||||
array_keys($oldTable->getColumns())
|
||||
));
|
||||
$this->addSql(sprintf(
|
||||
'INSERT INTO %s (%s) SELECT %s FROM %s',
|
||||
$this->concatPrefix($new),
|
||||
$columns,
|
||||
$columns,
|
||||
$this->concatPrefix($old)
|
||||
));
|
||||
$emptied[] = $old;
|
||||
}
|
||||
|
||||
// Drop the copied-from tables, hits first: their foreign key still references the old links table.
|
||||
foreach (array_reverse($emptied) as $old) {
|
||||
$this->addSql(sprintf('DROP TABLE %s', $this->concatPrefix($old)));
|
||||
}
|
||||
|
||||
$links = $this->findLinksTable($schema);
|
||||
$hits = $this->findHitsTable($schema);
|
||||
|
||||
if (null === $links) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The statements below run after the RENAME TABLE ones, so they target the new names.
|
||||
foreach ([[SmartLink::TABLE_NAME, $links], [SmartLinkHit::TABLE_NAME, $hits]] as [$name, $table]) {
|
||||
if (null === $table) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($this->getOldIndexes($table) as $old) {
|
||||
$this->addSql(sprintf(
|
||||
'ALTER TABLE %s DROP INDEX %s, ADD INDEX %s (%s)',
|
||||
$this->concatPrefix($name),
|
||||
$old,
|
||||
self::RENAMED_INDEXES[$old],
|
||||
implode(', ', $table->getIndex($old)->getColumns())
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (array_keys(self::MAUTIC_DESTINATIONS) as $column) {
|
||||
if (!$links->hasColumn($column)) {
|
||||
$this->addSql(sprintf(
|
||||
'ALTER TABLE %s ADD %s INT UNSIGNED DEFAULT NULL',
|
||||
$this->concatPrefix(SmartLink::TABLE_NAME),
|
||||
$column
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($this->getMissingForeignKeys($links) as $column => $referenceTable) {
|
||||
$this->addSql($this->generateAlterTableForeignKeyStatement(
|
||||
SmartLink::TABLE_NAME,
|
||||
[$column],
|
||||
$referenceTable,
|
||||
['id'],
|
||||
'ON DELETE SET NULL'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The links table under the name it has right now: new on fresh installs, old on installs
|
||||
* that wait for the RENAME TABLE statements queued above.
|
||||
*/
|
||||
private function findLinksTable(Schema $schema): ?Table
|
||||
{
|
||||
return $this->findTable($schema, SmartLink::TABLE_NAME) ?? $this->findTable($schema, 'utm_smart_links');
|
||||
}
|
||||
|
||||
private function findHitsTable(Schema $schema): ?Table
|
||||
{
|
||||
return $this->findTable($schema, SmartLinkHit::TABLE_NAME) ?? $this->findTable($schema, 'utm_smart_link_hits');
|
||||
}
|
||||
|
||||
private function findTable(Schema $schema, string $name): ?Table
|
||||
{
|
||||
$name = $this->concatPrefix($name);
|
||||
|
||||
return $schema->hasTable($name) ? $schema->getTable($name) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string> Indexes still carrying their pre-rename name
|
||||
*/
|
||||
private function getOldIndexes(Table $table): array
|
||||
{
|
||||
return array_values(array_filter(
|
||||
array_keys(self::RENAMED_INDEXES),
|
||||
fn (string $index): bool => $table->hasIndex($index)
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function getMissingForeignKeys(Table $table): array
|
||||
{
|
||||
$missing = self::MAUTIC_DESTINATIONS;
|
||||
|
||||
foreach ($table->getForeignKeys() as $foreignKey) {
|
||||
foreach ($foreignKey->getLocalColumns() as $column) {
|
||||
unset($missing[$column]);
|
||||
}
|
||||
}
|
||||
|
||||
return $missing;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace MauticPlugin\MT3SMarketingProgramBundle\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Mautic\IntegrationsBundle\Migration\AbstractMigration;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\SmartLink;
|
||||
use MauticPlugin\MT3SMarketingProgramBundle\Entity\UtmTaxonomy;
|
||||
|
||||
/**
|
||||
* The 0.6.0 UTM Taxonomies feature: the `utm_taxonomies` table, and the taxonomy of each
|
||||
* Smart Link (`utm_taxonomy_id`, ON DELETE SET NULL: deleting a taxonomy keeps its links,
|
||||
* they redirect with the values they already carry).
|
||||
*
|
||||
* Idempotent: runs on plugin update (core's migration engine) and right after a fresh install
|
||||
* (PluginInstallSubscriber), and stops when everything is already in place.
|
||||
*/
|
||||
class Version_0_6_0_SmartLinks extends AbstractMigration
|
||||
{
|
||||
protected function isApplicable(Schema $schema): bool
|
||||
{
|
||||
return !$schema->hasTable($this->concatPrefix(UtmTaxonomy::TABLE_NAME))
|
||||
|| !$this->hasTaxonomyColumn($schema)
|
||||
|| [] !== $this->getMissingForeignKeys($schema);
|
||||
}
|
||||
|
||||
protected function up(): void
|
||||
{
|
||||
$schema = $this->entityManager->getConnection()->createSchemaManager()->introspectSchema();
|
||||
|
||||
if (!$schema->hasTable($this->concatPrefix(UtmTaxonomy::TABLE_NAME))) {
|
||||
$table = $this->concatPrefix(UtmTaxonomy::TABLE_NAME);
|
||||
|
||||
$this->addSql(<<<SQL
|
||||
CREATE TABLE {$table} (
|
||||
id INT UNSIGNED AUTO_INCREMENT NOT NULL,
|
||||
is_published TINYINT(1) 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,
|
||||
name VARCHAR(50) NOT NULL,
|
||||
description LONGTEXT DEFAULT NULL,
|
||||
parameters JSON NOT NULL,
|
||||
UNIQUE INDEX UNIQ_TAXONOMY_NAME (name),
|
||||
INDEX utm_taxonomy_name (name),
|
||||
PRIMARY KEY(id)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
|
||||
SQL);
|
||||
}
|
||||
|
||||
if (!$this->hasTaxonomyColumn($schema)) {
|
||||
$this->addSql(sprintf(
|
||||
'ALTER TABLE %s ADD utm_taxonomy_id INT UNSIGNED DEFAULT NULL',
|
||||
$this->concatPrefix(SmartLink::TABLE_NAME)
|
||||
));
|
||||
}
|
||||
|
||||
foreach ($this->getMissingForeignKeys($schema) as $foreignKey) {
|
||||
$this->addSql($this->generateAlterTableForeignKeyStatement(
|
||||
SmartLink::TABLE_NAME,
|
||||
['utm_taxonomy_id'],
|
||||
UtmTaxonomy::TABLE_NAME,
|
||||
['id'],
|
||||
'ON DELETE SET NULL'
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
private function hasTaxonomyColumn(Schema $schema): bool
|
||||
{
|
||||
$links = $this->concatPrefix(SmartLink::TABLE_NAME);
|
||||
|
||||
return $schema->hasTable($links) && $schema->getTable($links)->hasColumn('utm_taxonomy_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<string>
|
||||
*/
|
||||
private function getMissingForeignKeys(Schema $schema): array
|
||||
{
|
||||
$links = $this->concatPrefix(SmartLink::TABLE_NAME);
|
||||
$missing = ['utm_taxonomy_id'];
|
||||
|
||||
if ($schema->hasTable($links)) {
|
||||
foreach ($schema->getTable($links)->getForeignKeys() as $foreignKey) {
|
||||
$missing = array_diff($missing, $foreignKey->getLocalColumns());
|
||||
}
|
||||
}
|
||||
|
||||
return array_values($missing);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user