Remove migration; rely on DCA only
This commit is contained in:
@@ -1,63 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace MummertMedia\ContaoMeilisearchBundle\Migration;
|
||||
|
||||
use Contao\CoreBundle\Migration\MigrationInterface;
|
||||
use Contao\CoreBundle\Migration\MigrationResult;
|
||||
use Doctrine\DBAL\Connection;
|
||||
|
||||
class ExtendTlSearchMigration implements MigrationInterface
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Connection $connection
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Eindeutiger Name der Migration
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return 'mummert_media_extend_tl_search';
|
||||
}
|
||||
|
||||
/**
|
||||
* Läuft nur, solange mindestens eine der Spalten fehlt
|
||||
*/
|
||||
public function shouldRun(): bool
|
||||
{
|
||||
$existingColumns = (int) $this->connection->fetchOne(
|
||||
<<<SQL
|
||||
SELECT COUNT(*)
|
||||
FROM INFORMATION_SCHEMA.COLUMNS
|
||||
WHERE TABLE_SCHEMA = DATABASE()
|
||||
AND TABLE_NAME = 'tl_search'
|
||||
AND COLUMN_NAME IN ('keywords', 'priority', 'imagepath', 'startDate')
|
||||
SQL
|
||||
);
|
||||
|
||||
// Wir erwarten genau 4 Spalten
|
||||
return $existingColumns < 4;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fügt die Spalten hinzu (idempotent)
|
||||
*/
|
||||
public function run(): MigrationResult
|
||||
{
|
||||
$this->connection->executeStatement(
|
||||
<<<SQL
|
||||
ALTER TABLE tl_search
|
||||
ADD COLUMN IF NOT EXISTS keywords varchar(255) NOT NULL DEFAULT '',
|
||||
ADD COLUMN IF NOT EXISTS priority int(1) NOT NULL DEFAULT 2,
|
||||
ADD COLUMN IF NOT EXISTS imagepath varchar(512) NOT NULL DEFAULT '',
|
||||
ADD COLUMN IF NOT EXISTS startDate bigint(20) NOT NULL DEFAULT 0
|
||||
SQL
|
||||
);
|
||||
|
||||
return new MigrationResult(
|
||||
true,
|
||||
'Extended tl_search with Meilisearch fields.'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
services:
|
||||
_defaults:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
||||
MummertMedia\ContaoMeilisearchBundle\Migration\ExtendTlSearchMigration:
|
||||
arguments:
|
||||
- '@database_connection'
|
||||
tags:
|
||||
- { name: contao.migration }
|
||||
@@ -1,43 +1,36 @@
|
||||
<?php
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_meilisearch'] = [
|
||||
'config' => [
|
||||
'dataContainer' => 'Table',
|
||||
'sql' => [
|
||||
'keys' => [
|
||||
'id' => 'primary',
|
||||
'pid' => 'unique',
|
||||
],
|
||||
],
|
||||
],
|
||||
declare(strict_types=1);
|
||||
|
||||
'fields' => [
|
||||
'id' => [
|
||||
'sql' => "int(10) unsigned NOT NULL auto_increment",
|
||||
],
|
||||
'pid' => [
|
||||
'sql' => "int(10) unsigned NOT NULL default 0",
|
||||
],
|
||||
'source' => [
|
||||
'sql' => "varchar(32) NOT NULL default ''",
|
||||
],
|
||||
'priority' => [
|
||||
'sql' => "int(1) NOT NULL default 2",
|
||||
],
|
||||
'keywords' => [
|
||||
$GLOBALS['TL_DCA']['tl_search']['fields']['keywords'] = [
|
||||
'label' => ['Keywords', 'Suchbegriffe für die Indexierung'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => ['tl_class' => 'w50', 'maxlength' => 255],
|
||||
'sql' => "varchar(255) NOT NULL default ''",
|
||||
],
|
||||
'imagepath' => [
|
||||
'sql' => "varchar(512) NOT NULL default ''",
|
||||
],
|
||||
'startDate' => [
|
||||
'sql' => "bigint(20) NOT NULL default 0",
|
||||
],
|
||||
'checksum' => [
|
||||
'sql' => "varchar(64) NOT NULL default ''",
|
||||
],
|
||||
'tstamp' => [
|
||||
'sql' => "int(10) unsigned NOT NULL default 0",
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_search']['fields']['priority'] = [
|
||||
'label' => ['Priorität', 'Priorität für die Suchergebnisse'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'select',
|
||||
'options' => [1, 2, 3],
|
||||
'eval' => ['tl_class' => 'w50'],
|
||||
'sql' => "int(1) NOT NULL default '2'",
|
||||
];
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_search']['fields']['imagepath'] = [
|
||||
'label' => ['Image Path', 'Speichert den Pfad des Bildes'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => ['maxlength' => 512],
|
||||
'sql' => "varchar(512) NOT NULL default ''",
|
||||
];
|
||||
|
||||
$GLOBALS['TL_DCA']['tl_search']['fields']['startDate'] = [
|
||||
'label' => ['Startdatum', 'Startdatum für die Suchergebnisse (Unix-Timestamp)'],
|
||||
'exclude' => true,
|
||||
'inputType' => 'text',
|
||||
'eval' => ['tl_class' => 'w50', 'rgxp' => 'digit'],
|
||||
'sql' => "bigint(20) NOT NULL default '0'",
|
||||
];
|
||||
Reference in New Issue
Block a user