mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-06 02:59:29 +00:00
* Erweiterungstätigkeiten zur IPN-Vorschlagsliste anhand von Präfixen aus den Kategorien * Umstellung Migrationen bzgl. Multi-Plattform-Support. Zunächst MySQL, SQLite Statements integrieren. * Postgre Statements integrieren * SQL-Formatierung in Migration verbessern * Erweitere IPN-Suggest um Bauteilbeschreibung. Die Implementierung berücksichtigt nun zusätzlich die Bauteilbeschreibung zu maximal 150 Zeichen Länge für die Generierung von IPN-Vorschlägen und Inkrementen. * Anpassungen aus Analyse vornehmen * IPN-Validierung für Parts überarbeiten * IPN-Vorschlagslogik um Konfiguration erweitert * Anpassungen aus phpstan Analyse * IPN-Vorschlagslogik erweitert und Bauteil-IPN vereindeutigt Die IPN-Logik wurde um eine Konfiguration zur automatischen Suffix-Anfügung und die Berücksichtigung von doppelten Beschreibungen bei Bedarf ergänzt. Zudem wurde das Datenmodell angepasst, um eine eindeutige Speicherung der IPN zu gewährleisten. * Regex-Konfigurationsmöglichkeit für IPN-Vorschläge einführen Die Einstellungen für die IPN-Vorschlagslogik wurden um eine Regex-Validierung und eine Hilfetext-Konfiguration erweitert. Tests und Änderungen an den Formularoptionen wurden implementiert. * Match range assert and form limits in suggestPartDigits * Keep existing behavior with autoAppend suffix by default * Show the regex hint in the browser validation notice. * Improved translations * Removed unnecessary service definition * Removed german comments --------- Co-authored-by: Marcel Diegelmann <marcel.diegelmann@gmail.com> Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
307 lines
11 KiB
PHP
307 lines
11 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use App\Migration\AbstractMultiPlatformMigration;
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
|
|
final class Version20250325073036 extends AbstractMultiPlatformMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Add part_ipn_prefix column to categories table and remove unique constraint from parts table';
|
|
}
|
|
|
|
public function mySQLUp(Schema $schema): void
|
|
{
|
|
$this->addSql(<<<'SQL'
|
|
ALTER TABLE categories ADD COLUMN part_ipn_prefix VARCHAR(255) NOT NULL DEFAULT ''
|
|
SQL);
|
|
}
|
|
|
|
public function mySQLDown(Schema $schema): void
|
|
{
|
|
$this->addSql(<<<'SQL'
|
|
ALTER TABLE categories DROP part_ipn_prefix
|
|
SQL);
|
|
}
|
|
|
|
public function sqLiteUp(Schema $schema): void
|
|
{
|
|
$this->addSql(<<<'SQL'
|
|
CREATE TEMPORARY TABLE __temp__categories AS
|
|
SELECT
|
|
id,
|
|
parent_id,
|
|
id_preview_attachment,
|
|
partname_hint,
|
|
partname_regex,
|
|
disable_footprints,
|
|
disable_manufacturers,
|
|
disable_autodatasheets,
|
|
disable_properties,
|
|
default_description,
|
|
default_comment,
|
|
comment,
|
|
not_selectable,
|
|
name,
|
|
last_modified,
|
|
datetime_added,
|
|
alternative_names,
|
|
eda_info_reference_prefix,
|
|
eda_info_invisible,
|
|
eda_info_exclude_from_bom,
|
|
eda_info_exclude_from_board,
|
|
eda_info_exclude_from_sim,
|
|
eda_info_kicad_symbol
|
|
FROM categories
|
|
SQL);
|
|
|
|
$this->addSql('DROP TABLE categories');
|
|
|
|
$this->addSql(<<<'SQL'
|
|
CREATE TABLE categories (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
parent_id INTEGER DEFAULT NULL,
|
|
id_preview_attachment INTEGER DEFAULT NULL,
|
|
partname_hint CLOB NOT NULL,
|
|
partname_regex CLOB NOT NULL,
|
|
part_ipn_prefix VARCHAR(255) DEFAULT '' NOT NULL,
|
|
disable_footprints BOOLEAN NOT NULL,
|
|
disable_manufacturers BOOLEAN NOT NULL,
|
|
disable_autodatasheets BOOLEAN NOT NULL,
|
|
disable_properties BOOLEAN NOT NULL,
|
|
default_description CLOB NOT NULL,
|
|
default_comment CLOB NOT NULL,
|
|
comment CLOB NOT NULL,
|
|
not_selectable BOOLEAN NOT NULL,
|
|
name VARCHAR(255) NOT NULL,
|
|
last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
alternative_names CLOB DEFAULT NULL,
|
|
eda_info_reference_prefix VARCHAR(255) DEFAULT NULL,
|
|
eda_info_invisible BOOLEAN DEFAULT NULL,
|
|
eda_info_exclude_from_bom BOOLEAN DEFAULT NULL,
|
|
eda_info_exclude_from_board BOOLEAN DEFAULT NULL,
|
|
eda_info_exclude_from_sim BOOLEAN DEFAULT NULL,
|
|
eda_info_kicad_symbol VARCHAR(255) DEFAULT NULL,
|
|
CONSTRAINT FK_3AF34668727ACA70 FOREIGN KEY (parent_id) REFERENCES categories (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE,
|
|
CONSTRAINT FK_3AF34668EA7100A1 FOREIGN KEY (id_preview_attachment) REFERENCES attachments (id) ON UPDATE NO ACTION ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE
|
|
)
|
|
SQL);
|
|
|
|
$this->addSql(<<<'SQL'
|
|
INSERT INTO categories (
|
|
id,
|
|
parent_id,
|
|
id_preview_attachment,
|
|
partname_hint,
|
|
partname_regex,
|
|
disable_footprints,
|
|
disable_manufacturers,
|
|
disable_autodatasheets,
|
|
disable_properties,
|
|
default_description,
|
|
default_comment,
|
|
comment,
|
|
not_selectable,
|
|
name,
|
|
last_modified,
|
|
datetime_added,
|
|
alternative_names,
|
|
eda_info_reference_prefix,
|
|
eda_info_invisible,
|
|
eda_info_exclude_from_bom,
|
|
eda_info_exclude_from_board,
|
|
eda_info_exclude_from_sim,
|
|
eda_info_kicad_symbol
|
|
) SELECT
|
|
id,
|
|
parent_id,
|
|
id_preview_attachment,
|
|
partname_hint,
|
|
partname_regex,
|
|
disable_footprints,
|
|
disable_manufacturers,
|
|
disable_autodatasheets,
|
|
disable_properties,
|
|
default_description,
|
|
default_comment,
|
|
comment,
|
|
not_selectable,
|
|
name,
|
|
last_modified,
|
|
datetime_added,
|
|
alternative_names,
|
|
eda_info_reference_prefix,
|
|
eda_info_invisible,
|
|
eda_info_exclude_from_bom,
|
|
eda_info_exclude_from_board,
|
|
eda_info_exclude_from_sim,
|
|
eda_info_kicad_symbol
|
|
FROM __temp__categories
|
|
SQL);
|
|
|
|
$this->addSql('DROP TABLE __temp__categories');
|
|
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX IDX_3AF34668727ACA70 ON categories (parent_id)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX IDX_3AF34668EA7100A1 ON categories (id_preview_attachment)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX category_idx_name ON categories (name)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX category_idx_parent_name ON categories (parent_id, name)
|
|
SQL);
|
|
}
|
|
|
|
public function sqLiteDown(Schema $schema): void
|
|
{
|
|
$this->addSql(<<<'SQL'
|
|
CREATE TEMPORARY TABLE __temp__categories AS
|
|
SELECT
|
|
id,
|
|
parent_id,
|
|
id_preview_attachment,
|
|
partname_hint,
|
|
partname_regex,
|
|
disable_footprints,
|
|
disable_manufacturers,
|
|
disable_autodatasheets,
|
|
disable_properties,
|
|
default_description,
|
|
default_comment,
|
|
comment,
|
|
not_selectable,
|
|
name,
|
|
last_modified,
|
|
datetime_added,
|
|
alternative_names,
|
|
eda_info_reference_prefix,
|
|
eda_info_invisible,
|
|
eda_info_exclude_from_bom,
|
|
eda_info_exclude_from_board,
|
|
eda_info_exclude_from_sim,
|
|
eda_info_kicad_symbol
|
|
FROM categories
|
|
SQL);
|
|
|
|
$this->addSql('DROP TABLE categories');
|
|
|
|
$this->addSql(<<<'SQL'
|
|
CREATE TABLE categories (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
parent_id INTEGER DEFAULT NULL,
|
|
id_preview_attachment INTEGER DEFAULT NULL,
|
|
partname_hint CLOB NOT NULL,
|
|
partname_regex CLOB NOT NULL,
|
|
disable_footprints BOOLEAN NOT NULL,
|
|
disable_manufacturers BOOLEAN NOT NULL,
|
|
disable_autodatasheets BOOLEAN NOT NULL,
|
|
disable_properties BOOLEAN NOT NULL,
|
|
default_description CLOB NOT NULL,
|
|
default_comment CLOB NOT NULL,
|
|
comment CLOB NOT NULL,
|
|
not_selectable BOOLEAN NOT NULL,
|
|
name VARCHAR(255) NOT NULL,
|
|
last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL,
|
|
alternative_names CLOB DEFAULT NULL,
|
|
eda_info_reference_prefix VARCHAR(255) DEFAULT NULL,
|
|
eda_info_invisible BOOLEAN DEFAULT NULL,
|
|
eda_info_exclude_from_bom BOOLEAN DEFAULT NULL,
|
|
eda_info_exclude_from_board BOOLEAN DEFAULT NULL,
|
|
eda_info_exclude_from_sim BOOLEAN DEFAULT NULL,
|
|
eda_info_kicad_symbol VARCHAR(255) DEFAULT NULL,
|
|
CONSTRAINT FK_3AF34668727ACA70 FOREIGN KEY (parent_id) REFERENCES categories (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE,
|
|
CONSTRAINT FK_3AF34668EA7100A1 FOREIGN KEY (id_preview_attachment) REFERENCES attachments (id) ON UPDATE NO ACTION ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE
|
|
)
|
|
SQL);
|
|
|
|
$this->addSql(<<<'SQL'
|
|
INSERT INTO categories (
|
|
id,
|
|
parent_id,
|
|
id_preview_attachment,
|
|
partname_hint,
|
|
partname_regex,
|
|
disable_footprints,
|
|
disable_manufacturers,
|
|
disable_autodatasheets,
|
|
disable_properties,
|
|
default_description,
|
|
default_comment,
|
|
comment,
|
|
not_selectable,
|
|
name,
|
|
last_modified,
|
|
datetime_added,
|
|
alternative_names,
|
|
eda_info_reference_prefix,
|
|
eda_info_invisible,
|
|
eda_info_exclude_from_bom,
|
|
eda_info_exclude_from_board,
|
|
eda_info_exclude_from_sim,
|
|
eda_info_kicad_symbol
|
|
) SELECT
|
|
id,
|
|
parent_id,
|
|
id_preview_attachment,
|
|
partname_hint,
|
|
partname_regex,
|
|
disable_footprints,
|
|
disable_manufacturers,
|
|
disable_autodatasheets,
|
|
disable_properties,
|
|
default_description,
|
|
default_comment,
|
|
comment,
|
|
not_selectable,
|
|
name,
|
|
last_modified,
|
|
datetime_added,
|
|
alternative_names,
|
|
eda_info_reference_prefix,
|
|
eda_info_invisible,
|
|
eda_info_exclude_from_bom,
|
|
eda_info_exclude_from_board,
|
|
eda_info_exclude_from_sim,
|
|
eda_info_kicad_symbol
|
|
FROM __temp__categories
|
|
SQL);
|
|
|
|
$this->addSql('DROP TABLE __temp__categories');
|
|
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX IDX_3AF34668727ACA70 ON categories (parent_id)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX IDX_3AF34668EA7100A1 ON categories (id_preview_attachment)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX category_idx_name ON categories (name)
|
|
SQL);
|
|
$this->addSql(<<<'SQL'
|
|
CREATE INDEX category_idx_parent_name ON categories (parent_id, name)
|
|
SQL);
|
|
}
|
|
|
|
public function postgreSQLUp(Schema $schema): void
|
|
{
|
|
$this->addSql(<<<'SQL'
|
|
ALTER TABLE categories ADD part_ipn_prefix VARCHAR(255) DEFAULT '' NOT NULL
|
|
SQL);
|
|
}
|
|
|
|
public function postgreSQLDown(Schema $schema): void
|
|
{
|
|
$this->addSql(<<<'SQL'
|
|
ALTER TABLE "categories" DROP part_ipn_prefix
|
|
SQL);
|
|
}
|
|
}
|