From be8fb57a4f5dc3eb460ae9c90e9af38291d7bee8 Mon Sep 17 00:00:00 2001 From: Marcel Diegelmann Date: Tue, 14 Oct 2025 10:04:11 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Migrationen=20zusammenf=C3=BChren?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- migrations/Version20250321075747.php | 534 +++++++++++++++++++++++++-- migrations/Version20250321141740.php | 503 ------------------------- 2 files changed, 507 insertions(+), 530 deletions(-) delete mode 100644 migrations/Version20250321141740.php diff --git a/migrations/Version20250321075747.php b/migrations/Version20250321075747.php index b236796d..14bcb8a9 100644 --- a/migrations/Version20250321075747.php +++ b/migrations/Version20250321075747.php @@ -11,27 +11,27 @@ final class Version20250321075747 extends AbstractMultiPlatformMigration { public function getDescription(): string { - return 'Create entity table for custom part states'; + return 'Create entity table for custom part states and add custom state to parts'; } public function mySQLUp(Schema $schema): void { $this->addSql(<<<'SQL' CREATE TABLE part_custom_states ( - id INT AUTO_INCREMENT NOT NULL, - parent_id INT DEFAULT NULL, - id_preview_attachment INT DEFAULT NULL, - name VARCHAR(255) NOT NULL, - comment LONGTEXT NOT NULL, - not_selectable TINYINT(1) NOT NULL, - alternative_names LONGTEXT DEFAULT NULL, - last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, - datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, - INDEX IDX_F552745D727ACA70 (parent_id), - INDEX IDX_F552745DEA7100A1 (id_preview_attachment), - INDEX part_custom_state_name (name), + id INT AUTO_INCREMENT NOT NULL, + parent_id INT DEFAULT NULL, + id_preview_attachment INT DEFAULT NULL, + name VARCHAR(255) NOT NULL, + comment LONGTEXT NOT NULL, + not_selectable TINYINT(1) NOT NULL, + alternative_names LONGTEXT DEFAULT NULL, + last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, + datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, + INDEX IDX_F552745D727ACA70 (parent_id), + INDEX IDX_F552745DEA7100A1 (id_preview_attachment), + INDEX part_custom_state_name (name), PRIMARY KEY(id) - ) + ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` SQL); $this->addSql(<<<'SQL' @@ -40,10 +40,30 @@ final class Version20250321075747 extends AbstractMultiPlatformMigration $this->addSql(<<<'SQL' ALTER TABLE part_custom_states ADD CONSTRAINT FK_F552745DEA7100A1 FOREIGN KEY (id_preview_attachment) REFERENCES attachments (id) ON DELETE SET NULL SQL); + + $this->addSql(<<<'SQL' + ALTER TABLE parts ADD id_part_custom_state INT DEFAULT NULL AFTER id_part_unit + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE parts ADD CONSTRAINT FK_6940A7FEA3ED1215 FOREIGN KEY (id_part_custom_state) REFERENCES part_custom_states (id) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FEA3ED1215 ON parts (id_part_custom_state) + SQL); } public function mySQLDown(Schema $schema): void { + $this->addSql(<<<'SQL' + ALTER TABLE parts DROP FOREIGN KEY FK_6940A7FEA3ED1215 + SQL); + $this->addSql(<<<'SQL' + DROP INDEX IDX_6940A7FEA3ED1215 ON parts + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE parts DROP id_part_custom_state + SQL); + $this->addSql(<<<'SQL' ALTER TABLE part_custom_states DROP FOREIGN KEY FK_F552745D727ACA70 SQL); @@ -59,15 +79,15 @@ final class Version20250321075747 extends AbstractMultiPlatformMigration { $this->addSql(<<<'SQL' CREATE TABLE "part_custom_states" ( - id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, - parent_id INTEGER DEFAULT NULL, + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + parent_id INTEGER DEFAULT NULL, id_preview_attachment INTEGER DEFAULT NULL, - name VARCHAR(255) NOT NULL, + name VARCHAR(255) NOT NULL, comment CLOB NOT NULL, - not_selectable BOOLEAN NOT NULL, - alternative_names CLOB DEFAULT NULL, - last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, - datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, + not_selectable BOOLEAN NOT NULL, + alternative_names CLOB DEFAULT NULL, + last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, + datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, CONSTRAINT FK_F552745D727ACA70 FOREIGN KEY (parent_id) REFERENCES "part_custom_states" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, CONSTRAINT FK_F5AF83CFEA7100A1 FOREIGN KEY (id_preview_attachment) REFERENCES "attachments" (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE ) @@ -78,10 +98,439 @@ final class Version20250321075747 extends AbstractMultiPlatformMigration $this->addSql(<<<'SQL' CREATE INDEX part_custom_state_name ON "part_custom_states" (name) SQL); + + $this->addSql(<<<'SQL' + CREATE TEMPORARY TABLE __temp__parts AS + SELECT + id, + id_preview_attachment, + id_category, + id_footprint, + id_part_unit, + id_manufacturer, + order_orderdetails_id, + built_project_id, + datetime_added, + name, + last_modified, + needs_review, + tags, + mass, + description, + comment, + visible, + favorite, + minamount, + manufacturer_product_url, + manufacturer_product_number, + manufacturing_status, + order_quantity, + manual_order, + ipn, + provider_reference_provider_key, + provider_reference_provider_id, + provider_reference_provider_url, + provider_reference_last_updated, + eda_info_reference_prefix, + eda_info_value, + eda_info_invisible, + eda_info_exclude_from_bom, + eda_info_exclude_from_board, + eda_info_exclude_from_sim, + eda_info_kicad_symbol, + eda_info_kicad_footprint + FROM parts + SQL); + + $this->addSql(<<<'SQL' + DROP TABLE parts + SQL); + + $this->addSql(<<<'SQL' + CREATE TABLE parts ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + id_preview_attachment INTEGER DEFAULT NULL, + id_category INTEGER NOT NULL, + id_footprint INTEGER DEFAULT NULL, + id_part_unit INTEGER DEFAULT NULL, + id_manufacturer INTEGER DEFAULT NULL, + id_part_custom_state INTEGER DEFAULT NULL, + order_orderdetails_id INTEGER DEFAULT NULL, + built_project_id INTEGER DEFAULT NULL, + datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, + name VARCHAR(255) NOT NULL, + last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, + needs_review BOOLEAN NOT NULL, + tags CLOB NOT NULL, + mass DOUBLE PRECISION DEFAULT NULL, + description CLOB NOT NULL, + comment CLOB NOT NULL, + visible BOOLEAN NOT NULL, + favorite BOOLEAN NOT NULL, + minamount DOUBLE PRECISION NOT NULL, + manufacturer_product_url CLOB NOT NULL, + manufacturer_product_number VARCHAR(255) NOT NULL, + manufacturing_status VARCHAR(255) DEFAULT NULL, + order_quantity INTEGER NOT NULL, + manual_order BOOLEAN NOT NULL, + ipn VARCHAR(100) DEFAULT NULL, + provider_reference_provider_key VARCHAR(255) DEFAULT NULL, + provider_reference_provider_id VARCHAR(255) DEFAULT NULL, + provider_reference_provider_url VARCHAR(255) DEFAULT NULL, + provider_reference_last_updated DATETIME DEFAULT NULL, + eda_info_reference_prefix VARCHAR(255) DEFAULT NULL, + eda_info_value 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, + eda_info_kicad_footprint VARCHAR(255) DEFAULT NULL, + CONSTRAINT FK_6940A7FEEA7100A1 FOREIGN KEY (id_preview_attachment) REFERENCES attachments (id) ON UPDATE NO ACTION ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FE5697F554 FOREIGN KEY (id_category) REFERENCES categories (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FE7E371A10 FOREIGN KEY (id_footprint) REFERENCES footprints (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FE2626CEF9 FOREIGN KEY (id_part_unit) REFERENCES measurement_units (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FE1ECB93AE FOREIGN KEY (id_manufacturer) REFERENCES manufacturers (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FEA3ED1215 FOREIGN KEY (id_part_custom_state) REFERENCES "part_custom_states" (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FE81081E9B FOREIGN KEY (order_orderdetails_id) REFERENCES orderdetails (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FEE8AE70D9 FOREIGN KEY (built_project_id) REFERENCES projects (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE + ) + SQL); + + $this->addSql(<<<'SQL' + INSERT INTO parts ( + id, + id_preview_attachment, + id_category, + id_footprint, + id_part_unit, + id_manufacturer, + order_orderdetails_id, + built_project_id, + datetime_added, + name, + last_modified, + needs_review, + tags, + mass, + description, + comment, + visible, + favorite, + minamount, + manufacturer_product_url, + manufacturer_product_number, + manufacturing_status, + order_quantity, + manual_order, + ipn, + provider_reference_provider_key, + provider_reference_provider_id, + provider_reference_provider_url, + provider_reference_last_updated, + eda_info_reference_prefix, + eda_info_value, + eda_info_invisible, + eda_info_exclude_from_bom, + eda_info_exclude_from_board, + eda_info_exclude_from_sim, + eda_info_kicad_symbol, + eda_info_kicad_footprint) + SELECT + id, + id_preview_attachment, + id_category, + id_footprint, + id_part_unit, + id_manufacturer, + order_orderdetails_id, + built_project_id, + datetime_added, + name, + last_modified, + needs_review, + tags, + mass, + description, + comment, + visible, + favorite, + minamount, + manufacturer_product_url, + manufacturer_product_number, + manufacturing_status, + order_quantity, + manual_order, + ipn, + provider_reference_provider_key, + provider_reference_provider_id, + provider_reference_provider_url, + provider_reference_last_updated, + eda_info_reference_prefix, + eda_info_value, + eda_info_invisible, + eda_info_exclude_from_bom, + eda_info_exclude_from_board, + eda_info_exclude_from_sim, + eda_info_kicad_symbol, + eda_info_kicad_footprint + FROM __temp__parts + SQL); + + $this->addSql(<<<'SQL' + DROP TABLE __temp__parts + SQL); + + $this->addSql(<<<'SQL' + CREATE INDEX parts_idx_name ON parts (name) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX parts_idx_ipn ON parts (ipn) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX parts_idx_datet_name_last_id_needs ON parts (datetime_added, name, last_modified, id, needs_review) + SQL); + $this->addSql(<<<'SQL' + CREATE UNIQUE INDEX UNIQ_6940A7FEE8AE70D9 ON parts (built_project_id) + SQL); + $this->addSql(<<<'SQL' + CREATE UNIQUE INDEX UNIQ_6940A7FE81081E9B ON parts (order_orderdetails_id) + SQL); + $this->addSql(<<<'SQL' + CREATE UNIQUE INDEX UNIQ_6940A7FE3D721C14 ON parts (ipn) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FEEA7100A1 ON parts (id_preview_attachment) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FE7E371A10 ON parts (id_footprint) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FE5697F554 ON parts (id_category) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FE2626CEF9 ON parts (id_part_unit) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FE1ECB93AE ON parts (id_manufacturer) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FEA3ED1215 ON parts (id_part_custom_state) + SQL); } public function sqLiteDown(Schema $schema): void { + $this->addSql(<<<'SQL' + CREATE TEMPORARY TABLE __temp__parts AS + SELECT + id, + id_preview_attachment, + id_category, + id_footprint, + id_part_unit, + id_manufacturer, + order_orderdetails_id, + built_project_id, + datetime_added, + name, + last_modified, + needs_review, + tags, + mass, + description, + comment, + visible, + favorite, + minamount, + manufacturer_product_url, + manufacturer_product_number, + manufacturing_status, + order_quantity, + manual_order, + ipn, + provider_reference_provider_key, + provider_reference_provider_id, + provider_reference_provider_url, + provider_reference_last_updated, + eda_info_reference_prefix, + eda_info_value, + eda_info_invisible, + eda_info_exclude_from_bom, + eda_info_exclude_from_board, + eda_info_exclude_from_sim, + eda_info_kicad_symbol, + eda_info_kicad_footprint + FROM "parts" + SQL); + $this->addSql(<<<'SQL' + DROP TABLE "parts" + SQL); + $this->addSql(<<<'SQL' + CREATE TABLE "parts" ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + id_preview_attachment INTEGER DEFAULT NULL, + id_category INTEGER NOT NULL, + id_footprint INTEGER DEFAULT NULL, + id_part_unit INTEGER DEFAULT NULL, + id_manufacturer INTEGER DEFAULT NULL, + order_orderdetails_id INTEGER DEFAULT NULL, + built_project_id INTEGER DEFAULT NULL, + datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, + name VARCHAR(255) NOT NULL, + last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, + needs_review BOOLEAN NOT NULL, + tags CLOB NOT NULL, + mass DOUBLE PRECISION DEFAULT NULL, + description CLOB NOT NULL, + comment CLOB NOT NULL, + visible BOOLEAN NOT NULL, + favorite BOOLEAN NOT NULL, + minamount DOUBLE PRECISION NOT NULL, + manufacturer_product_url CLOB NOT NULL, + manufacturer_product_number VARCHAR(255) NOT NULL, + manufacturing_status VARCHAR(255) DEFAULT NULL, + order_quantity INTEGER NOT NULL, + manual_order BOOLEAN NOT NULL, + ipn VARCHAR(100) DEFAULT NULL, + provider_reference_provider_key VARCHAR(255) DEFAULT NULL, + provider_reference_provider_id VARCHAR(255) DEFAULT NULL, + provider_reference_provider_url VARCHAR(255) DEFAULT NULL, + provider_reference_last_updated DATETIME DEFAULT NULL, + eda_info_reference_prefix VARCHAR(255) DEFAULT NULL, + eda_info_value 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, + eda_info_kicad_footprint VARCHAR(255) DEFAULT NULL, + CONSTRAINT FK_6940A7FEEA7100A1 FOREIGN KEY (id_preview_attachment) REFERENCES "attachments" (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FE5697F554 FOREIGN KEY (id_category) REFERENCES "categories" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FE7E371A10 FOREIGN KEY (id_footprint) REFERENCES "footprints" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FE2626CEF9 FOREIGN KEY (id_part_unit) REFERENCES "measurement_units" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FE1ECB93AE FOREIGN KEY (id_manufacturer) REFERENCES "manufacturers" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FE81081E9B FOREIGN KEY (order_orderdetails_id) REFERENCES "orderdetails" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, + CONSTRAINT FK_6940A7FEE8AE70D9 FOREIGN KEY (built_project_id) REFERENCES projects (id) NOT DEFERRABLE INITIALLY IMMEDIATE + ) + SQL); + $this->addSql(<<<'SQL' + INSERT INTO "parts" ( + id, + id_preview_attachment, + id_category, + id_footprint, + id_part_unit, + id_manufacturer, + order_orderdetails_id, + built_project_id, + datetime_added, + name, + last_modified, + needs_review, + tags, + mass, + description, + comment, + visible, + favorite, + minamount, + manufacturer_product_url, + manufacturer_product_number, + manufacturing_status, + order_quantity, + manual_order, + ipn, + provider_reference_provider_key, + provider_reference_provider_id, + provider_reference_provider_url, + provider_reference_last_updated, + eda_info_reference_prefix, + eda_info_value, + eda_info_invisible, + eda_info_exclude_from_bom, + eda_info_exclude_from_board, + eda_info_exclude_from_sim, + eda_info_kicad_symbol, + eda_info_kicad_footprint + ) SELECT + id, + id_preview_attachment, + id_category, + id_footprint, + id_part_unit, + id_manufacturer, + order_orderdetails_id, + built_project_id, + datetime_added, + name, + last_modified, + needs_review, + tags, + mass, + description, + comment, + visible, + favorite, + minamount, + manufacturer_product_url, + manufacturer_product_number, + manufacturing_status, + order_quantity, + manual_order, + ipn, + provider_reference_provider_key, + provider_reference_provider_id, + provider_reference_provider_url, + provider_reference_last_updated, + eda_info_reference_prefix, + eda_info_value, + eda_info_invisible, + eda_info_exclude_from_bom, + eda_info_exclude_from_board, + eda_info_exclude_from_sim, + eda_info_kicad_symbol, + eda_info_kicad_footprint + FROM __temp__parts + SQL); + + $this->addSql(<<<'SQL' + DROP TABLE __temp__parts + SQL); + $this->addSql(<<<'SQL' + CREATE UNIQUE INDEX UNIQ_6940A7FE3D721C14 ON "parts" (ipn) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FEEA7100A1 ON "parts" (id_preview_attachment) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FE5697F554 ON "parts" (id_category) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FE7E371A10 ON "parts" (id_footprint) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FE2626CEF9 ON "parts" (id_part_unit) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FE1ECB93AE ON "parts" (id_manufacturer) + SQL); + $this->addSql(<<<'SQL' + CREATE UNIQUE INDEX UNIQ_6940A7FE81081E9B ON "parts" (order_orderdetails_id) + SQL); + $this->addSql(<<<'SQL' + CREATE UNIQUE INDEX UNIQ_6940A7FEE8AE70D9 ON "parts" (built_project_id) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX parts_idx_datet_name_last_id_needs ON "parts" (datetime_added, name, last_modified, id, needs_review) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX parts_idx_name ON "parts" (name) + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX parts_idx_ipn ON "parts" (ipn) + SQL); + $this->addSql(<<<'SQL' DROP TABLE "part_custom_states" SQL); @@ -91,14 +540,14 @@ final class Version20250321075747 extends AbstractMultiPlatformMigration { $this->addSql(<<<'SQL' CREATE TABLE "part_custom_states" ( - id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, - parent_id INT DEFAULT NULL, + id INT GENERATED BY DEFAULT AS IDENTITY NOT NULL, + parent_id INT DEFAULT NULL, id_preview_attachment INT DEFAULT NULL, PRIMARY KEY(id), - name VARCHAR(255) NOT NULL, - comment TEXT NOT NULL, - not_selectable BOOLEAN NOT NULL, + name VARCHAR(255) NOT NULL, + comment TEXT NOT NULL, + not_selectable BOOLEAN NOT NULL, alternative_names TEXT DEFAULT NULL, - last_modified TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, + last_modified TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL, datetime_added TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT CURRENT_TIMESTAMP NOT NULL ) SQL); @@ -108,10 +557,41 @@ final class Version20250321075747 extends AbstractMultiPlatformMigration $this->addSql(<<<'SQL' CREATE INDEX IDX_F552745DEA7100A1 ON "part_custom_states" (id_preview_attachment) SQL); + $this->addSql(<<<'SQL' + ALTER TABLE "part_custom_states" + ADD CONSTRAINT FK_F552745D727ACA70 + FOREIGN KEY (parent_id) REFERENCES "part_custom_states" (id) NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE "part_custom_states" + ADD CONSTRAINT FK_F552745DEA7100A1 + FOREIGN KEY (id_preview_attachment) REFERENCES "attachments" (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + + + $this->addSql(<<<'SQL' + ALTER TABLE parts ADD id_part_custom_state INT DEFAULT NULL + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE parts ADD CONSTRAINT FK_6940A7FEA3ED1215 FOREIGN KEY (id_part_custom_state) REFERENCES "part_custom_states" (id) NOT DEFERRABLE INITIALLY IMMEDIATE + SQL); + $this->addSql(<<<'SQL' + CREATE INDEX IDX_6940A7FEA3ED1215 ON parts (id_part_custom_state) + SQL); } public function postgreSQLDown(Schema $schema): void { + $this->addSql(<<<'SQL' + ALTER TABLE "parts" DROP CONSTRAINT FK_6940A7FEA3ED1215 + SQL); + $this->addSql(<<<'SQL' + DROP INDEX IDX_6940A7FEA3ED1215 + SQL); + $this->addSql(<<<'SQL' + ALTER TABLE "parts" DROP id_part_custom_state + SQL); + $this->addSql(<<<'SQL' ALTER TABLE "part_custom_states" DROP CONSTRAINT FK_F552745D727ACA70 SQL); diff --git a/migrations/Version20250321141740.php b/migrations/Version20250321141740.php deleted file mode 100644 index 34eca652..00000000 --- a/migrations/Version20250321141740.php +++ /dev/null @@ -1,503 +0,0 @@ -addSql(<<<'SQL' - ALTER TABLE parts ADD id_part_custom_state INT DEFAULT NULL AFTER id_part_unit - SQL); - $this->addSql(<<<'SQL' - ALTER TABLE parts ADD CONSTRAINT FK_6940A7FEA3ED1215 FOREIGN KEY (id_part_custom_state) REFERENCES part_custom_states (id) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FEA3ED1215 ON parts (id_part_custom_state) - SQL); - } - - public function mySQLDown(Schema $schema): void - { - $this->addSql(<<<'SQL' - ALTER TABLE parts DROP FOREIGN KEY FK_6940A7FEA3ED1215 - SQL); - $this->addSql(<<<'SQL' - DROP INDEX IDX_6940A7FEA3ED1215 ON parts - SQL); - $this->addSql(<<<'SQL' - ALTER TABLE parts DROP id_part_custom_state - SQL); - } - - public function sqLiteUp(Schema $schema): void - { - $this->addSql(<<<'SQL' - CREATE TEMPORARY TABLE __temp__parts AS - SELECT - id, - id_preview_attachment, - id_category, - id_footprint, - id_part_unit, - id_manufacturer, - order_orderdetails_id, - built_project_id, - datetime_added, - name, - last_modified, - needs_review, - tags, - mass, - description, - comment, - visible, - favorite, - minamount, - manufacturer_product_url, - manufacturer_product_number, - manufacturing_status, - order_quantity, - manual_order, - ipn, - provider_reference_provider_key, - provider_reference_provider_id, - provider_reference_provider_url, - provider_reference_last_updated, - eda_info_reference_prefix, - eda_info_value, - eda_info_invisible, - eda_info_exclude_from_bom, - eda_info_exclude_from_board, - eda_info_exclude_from_sim, - eda_info_kicad_symbol, - eda_info_kicad_footprint - FROM parts - SQL); - - $this->addSql(<<<'SQL' - DROP TABLE parts - SQL); - - $this->addSql(<<<'SQL' - CREATE TABLE parts ( - id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, - id_preview_attachment INTEGER DEFAULT NULL, - id_category INTEGER NOT NULL, - id_footprint INTEGER DEFAULT NULL, - id_part_unit INTEGER DEFAULT NULL, - id_manufacturer INTEGER DEFAULT NULL, - id_part_custom_state INTEGER DEFAULT NULL, - order_orderdetails_id INTEGER DEFAULT NULL, - built_project_id INTEGER DEFAULT NULL, - datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, - name VARCHAR(255) NOT NULL, - last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, - needs_review BOOLEAN NOT NULL, - tags CLOB NOT NULL, - mass DOUBLE PRECISION DEFAULT NULL, - description CLOB NOT NULL, - comment CLOB NOT NULL, - visible BOOLEAN NOT NULL, - favorite BOOLEAN NOT NULL, - minamount DOUBLE PRECISION NOT NULL, - manufacturer_product_url CLOB NOT NULL, - manufacturer_product_number VARCHAR(255) NOT NULL, - manufacturing_status VARCHAR(255) DEFAULT NULL, - order_quantity INTEGER NOT NULL, - manual_order BOOLEAN NOT NULL, - ipn VARCHAR(100) DEFAULT NULL, - provider_reference_provider_key VARCHAR(255) DEFAULT NULL, - provider_reference_provider_id VARCHAR(255) DEFAULT NULL, - provider_reference_provider_url VARCHAR(255) DEFAULT NULL, - provider_reference_last_updated DATETIME DEFAULT NULL, - eda_info_reference_prefix VARCHAR(255) DEFAULT NULL, - eda_info_value 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, - eda_info_kicad_footprint VARCHAR(255) DEFAULT NULL, - CONSTRAINT FK_6940A7FEEA7100A1 FOREIGN KEY (id_preview_attachment) REFERENCES attachments (id) ON UPDATE NO ACTION ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FE5697F554 FOREIGN KEY (id_category) REFERENCES categories (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FE7E371A10 FOREIGN KEY (id_footprint) REFERENCES footprints (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FE2626CEF9 FOREIGN KEY (id_part_unit) REFERENCES measurement_units (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FE1ECB93AE FOREIGN KEY (id_manufacturer) REFERENCES manufacturers (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FEA3ED1215 FOREIGN KEY (id_part_custom_state) REFERENCES "part_custom_states" (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FE81081E9B FOREIGN KEY (order_orderdetails_id) REFERENCES orderdetails (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FEE8AE70D9 FOREIGN KEY (built_project_id) REFERENCES projects (id) ON UPDATE NO ACTION ON DELETE NO ACTION NOT DEFERRABLE INITIALLY IMMEDIATE - ) - SQL); - - $this->addSql(<<<'SQL' - INSERT INTO parts ( - id, - id_preview_attachment, - id_category, - id_footprint, - id_part_unit, - id_manufacturer, - order_orderdetails_id, - built_project_id, - datetime_added, - name, - last_modified, - needs_review, - tags, - mass, - description, - comment, - visible, - favorite, - minamount, - manufacturer_product_url, - manufacturer_product_number, - manufacturing_status, - order_quantity, - manual_order, - ipn, - provider_reference_provider_key, - provider_reference_provider_id, - provider_reference_provider_url, - provider_reference_last_updated, - eda_info_reference_prefix, - eda_info_value, - eda_info_invisible, - eda_info_exclude_from_bom, - eda_info_exclude_from_board, - eda_info_exclude_from_sim, - eda_info_kicad_symbol, - eda_info_kicad_footprint) - SELECT - id, - id_preview_attachment, - id_category, - id_footprint, - id_part_unit, - id_manufacturer, - order_orderdetails_id, - built_project_id, - datetime_added, - name, - last_modified, - needs_review, - tags, - mass, - description, - comment, - visible, - favorite, - minamount, - manufacturer_product_url, - manufacturer_product_number, - manufacturing_status, - order_quantity, - manual_order, - ipn, - provider_reference_provider_key, - provider_reference_provider_id, - provider_reference_provider_url, - provider_reference_last_updated, - eda_info_reference_prefix, - eda_info_value, - eda_info_invisible, - eda_info_exclude_from_bom, - eda_info_exclude_from_board, - eda_info_exclude_from_sim, - eda_info_kicad_symbol, - eda_info_kicad_footprint - FROM __temp__parts - SQL); - - $this->addSql(<<<'SQL' - DROP TABLE __temp__parts - SQL); - - $this->addSql(<<<'SQL' - CREATE INDEX parts_idx_name ON parts (name) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX parts_idx_ipn ON parts (ipn) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX parts_idx_datet_name_last_id_needs ON parts (datetime_added, name, last_modified, id, needs_review) - SQL); - $this->addSql(<<<'SQL' - CREATE UNIQUE INDEX UNIQ_6940A7FEE8AE70D9 ON parts (built_project_id) - SQL); - $this->addSql(<<<'SQL' - CREATE UNIQUE INDEX UNIQ_6940A7FE81081E9B ON parts (order_orderdetails_id) - SQL); - $this->addSql(<<<'SQL' - CREATE UNIQUE INDEX UNIQ_6940A7FE3D721C14 ON parts (ipn) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FEEA7100A1 ON parts (id_preview_attachment) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FE7E371A10 ON parts (id_footprint) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FE5697F554 ON parts (id_category) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FE2626CEF9 ON parts (id_part_unit) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FE1ECB93AE ON parts (id_manufacturer) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FEA3ED1215 ON parts (id_part_custom_state) - SQL); - } - - public function sqLiteDown(Schema $schema): void - { - $this->addSql(<<<'SQL' - CREATE TEMPORARY TABLE __temp__parts AS - SELECT - id, - id_preview_attachment, - id_category, - id_footprint, - id_part_unit, - id_manufacturer, - order_orderdetails_id, - built_project_id, - datetime_added, - name, - last_modified, - needs_review, - tags, - mass, - description, - comment, - visible, - favorite, - minamount, - manufacturer_product_url, - manufacturer_product_number, - manufacturing_status, - order_quantity, - manual_order, - ipn, - provider_reference_provider_key, - provider_reference_provider_id, - provider_reference_provider_url, - provider_reference_last_updated, - eda_info_reference_prefix, - eda_info_value, - eda_info_invisible, - eda_info_exclude_from_bom, - eda_info_exclude_from_board, - eda_info_exclude_from_sim, - eda_info_kicad_symbol, - eda_info_kicad_footprint - FROM "parts" - SQL); - $this->addSql(<<<'SQL' - DROP TABLE "parts" - SQL); - $this->addSql(<<<'SQL' - CREATE TABLE "parts" ( - id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, - id_preview_attachment INTEGER DEFAULT NULL, - id_category INTEGER NOT NULL, - id_footprint INTEGER DEFAULT NULL, - id_part_unit INTEGER DEFAULT NULL, - id_manufacturer INTEGER DEFAULT NULL, - order_orderdetails_id INTEGER DEFAULT NULL, - built_project_id INTEGER DEFAULT NULL, - datetime_added DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, - name VARCHAR(255) NOT NULL, - last_modified DATETIME DEFAULT CURRENT_TIMESTAMP NOT NULL, - needs_review BOOLEAN NOT NULL, - tags CLOB NOT NULL, - mass DOUBLE PRECISION DEFAULT NULL, - description CLOB NOT NULL, - comment CLOB NOT NULL, - visible BOOLEAN NOT NULL, - favorite BOOLEAN NOT NULL, - minamount DOUBLE PRECISION NOT NULL, - manufacturer_product_url CLOB NOT NULL, - manufacturer_product_number VARCHAR(255) NOT NULL, - manufacturing_status VARCHAR(255) DEFAULT NULL, - order_quantity INTEGER NOT NULL, - manual_order BOOLEAN NOT NULL, - ipn VARCHAR(100) DEFAULT NULL, - provider_reference_provider_key VARCHAR(255) DEFAULT NULL, - provider_reference_provider_id VARCHAR(255) DEFAULT NULL, - provider_reference_provider_url VARCHAR(255) DEFAULT NULL, - provider_reference_last_updated DATETIME DEFAULT NULL, - eda_info_reference_prefix VARCHAR(255) DEFAULT NULL, - eda_info_value 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, - eda_info_kicad_footprint VARCHAR(255) DEFAULT NULL, - CONSTRAINT FK_6940A7FEEA7100A1 FOREIGN KEY (id_preview_attachment) REFERENCES "attachments" (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FE5697F554 FOREIGN KEY (id_category) REFERENCES "categories" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FE7E371A10 FOREIGN KEY (id_footprint) REFERENCES "footprints" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FE2626CEF9 FOREIGN KEY (id_part_unit) REFERENCES "measurement_units" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FE1ECB93AE FOREIGN KEY (id_manufacturer) REFERENCES "manufacturers" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FE81081E9B FOREIGN KEY (order_orderdetails_id) REFERENCES "orderdetails" (id) NOT DEFERRABLE INITIALLY IMMEDIATE, - CONSTRAINT FK_6940A7FEE8AE70D9 FOREIGN KEY (built_project_id) REFERENCES projects (id) NOT DEFERRABLE INITIALLY IMMEDIATE - ) - SQL); - $this->addSql(<<<'SQL' - INSERT INTO "parts" ( - id, - id_preview_attachment, - id_category, - id_footprint, - id_part_unit, - id_manufacturer, - order_orderdetails_id, - built_project_id, - datetime_added, - name, - last_modified, - needs_review, - tags, - mass, - description, - comment, - visible, - favorite, - minamount, - manufacturer_product_url, - manufacturer_product_number, - manufacturing_status, - order_quantity, - manual_order, - ipn, - provider_reference_provider_key, - provider_reference_provider_id, - provider_reference_provider_url, - provider_reference_last_updated, - eda_info_reference_prefix, - eda_info_value, - eda_info_invisible, - eda_info_exclude_from_bom, - eda_info_exclude_from_board, - eda_info_exclude_from_sim, - eda_info_kicad_symbol, - eda_info_kicad_footprint - ) SELECT - id, - id_preview_attachment, - id_category, - id_footprint, - id_part_unit, - id_manufacturer, - order_orderdetails_id, - built_project_id, - datetime_added, - name, - last_modified, - needs_review, - tags, - mass, - description, - comment, - visible, - favorite, - minamount, - manufacturer_product_url, - manufacturer_product_number, - manufacturing_status, - order_quantity, - manual_order, - ipn, - provider_reference_provider_key, - provider_reference_provider_id, - provider_reference_provider_url, - provider_reference_last_updated, - eda_info_reference_prefix, - eda_info_value, - eda_info_invisible, - eda_info_exclude_from_bom, - eda_info_exclude_from_board, - eda_info_exclude_from_sim, - eda_info_kicad_symbol, - eda_info_kicad_footprint - FROM __temp__parts - SQL); - - $this->addSql(<<<'SQL' - DROP TABLE __temp__parts - SQL); - $this->addSql(<<<'SQL' - CREATE UNIQUE INDEX UNIQ_6940A7FE3D721C14 ON "parts" (ipn) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FEEA7100A1 ON "parts" (id_preview_attachment) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FE5697F554 ON "parts" (id_category) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FE7E371A10 ON "parts" (id_footprint) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FE2626CEF9 ON "parts" (id_part_unit) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FE1ECB93AE ON "parts" (id_manufacturer) - SQL); - $this->addSql(<<<'SQL' - CREATE UNIQUE INDEX UNIQ_6940A7FE81081E9B ON "parts" (order_orderdetails_id) - SQL); - $this->addSql(<<<'SQL' - CREATE UNIQUE INDEX UNIQ_6940A7FEE8AE70D9 ON "parts" (built_project_id) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX parts_idx_datet_name_last_id_needs ON "parts" (datetime_added, name, last_modified, id, needs_review) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX parts_idx_name ON "parts" (name) - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX parts_idx_ipn ON "parts" (ipn) - SQL); - } - - public function postgreSQLUp(Schema $schema): void - { - $this->addSql(<<<'SQL' - ALTER TABLE parts ADD id_part_custom_state INT DEFAULT NULL - SQL); - $this->addSql(<<<'SQL' - ALTER TABLE parts ADD CONSTRAINT FK_6940A7FEA3ED1215 FOREIGN KEY (id_part_custom_state) REFERENCES "part_custom_states" (id) NOT DEFERRABLE INITIALLY IMMEDIATE - SQL); - $this->addSql(<<<'SQL' - CREATE INDEX IDX_6940A7FEA3ED1215 ON parts (id_part_custom_state) - SQL); - } - - public function postgreSQLDown(Schema $schema): void - { - $this->addSql(<<<'SQL' - ALTER TABLE "parts" DROP CONSTRAINT FK_6940A7FEA3ED1215 - SQL); - $this->addSql(<<<'SQL' - DROP INDEX IDX_6940A7FEA3ED1215 - SQL); - $this->addSql(<<<'SQL' - ALTER TABLE "parts" DROP id_part_custom_state - SQL); - } -} From c653dddd8f2848acf0218d5e4b770963e972ba55 Mon Sep 17 00:00:00 2001 From: Marcel Diegelmann Date: Tue, 14 Oct 2025 13:58:46 +0200 Subject: [PATCH 2/3] PartCustomState: Anpassungen bzgl. Tests --- src/DataFixtures/DataStructureFixtures.php | 3 ++- src/Services/UserSystem/PermissionPresetsHelper.php | 1 + tests/Twig/EntityExtensionTest.php | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/DataFixtures/DataStructureFixtures.php b/src/DataFixtures/DataStructureFixtures.php index fc713d4d..9c685338 100644 --- a/src/DataFixtures/DataStructureFixtures.php +++ b/src/DataFixtures/DataStructureFixtures.php @@ -24,6 +24,7 @@ namespace App\DataFixtures; use App\Entity\Attachments\AttachmentType; use App\Entity\Base\AbstractStructuralDBElement; +use App\Entity\Parts\PartCustomState; use App\Entity\ProjectSystem\Project; use App\Entity\Parts\Category; use App\Entity\Parts\Footprint; @@ -50,7 +51,7 @@ class DataStructureFixtures extends Fixture implements DependentFixtureInterface { //Reset autoincrement $types = [AttachmentType::class, Project::class, Category::class, Footprint::class, Manufacturer::class, - MeasurementUnit::class, StorageLocation::class, Supplier::class,]; + MeasurementUnit::class, StorageLocation::class, Supplier::class, PartCustomState::class]; foreach ($types as $type) { $this->createNodesForClass($type, $manager); diff --git a/src/Services/UserSystem/PermissionPresetsHelper.php b/src/Services/UserSystem/PermissionPresetsHelper.php index a6301388..a3ed01b8 100644 --- a/src/Services/UserSystem/PermissionPresetsHelper.php +++ b/src/Services/UserSystem/PermissionPresetsHelper.php @@ -132,6 +132,7 @@ class PermissionPresetsHelper $this->permissionResolver->setAllOperationsOfPermissionExcept($permHolder, 'attachment_types', PermissionData::ALLOW, ['import']); $this->permissionResolver->setAllOperationsOfPermissionExcept($permHolder, 'currencies', PermissionData::ALLOW, ['import']); $this->permissionResolver->setAllOperationsOfPermissionExcept($permHolder, 'measurement_units', PermissionData::ALLOW, ['import']); + $this->permissionResolver->setAllOperationsOfPermissionExcept($permHolder, 'part_custom_states', PermissionData::ALLOW, ['import']); $this->permissionResolver->setAllOperationsOfPermissionExcept($permHolder, 'suppliers', PermissionData::ALLOW, ['import']); $this->permissionResolver->setAllOperationsOfPermissionExcept($permHolder, 'projects', PermissionData::ALLOW, ['import']); diff --git a/tests/Twig/EntityExtensionTest.php b/tests/Twig/EntityExtensionTest.php index 3adb9ad2..18fe970b 100644 --- a/tests/Twig/EntityExtensionTest.php +++ b/tests/Twig/EntityExtensionTest.php @@ -23,6 +23,7 @@ declare(strict_types=1); namespace App\Tests\Twig; use App\Entity\Attachments\PartAttachment; +use App\Entity\Parts\PartCustomState; use App\Entity\ProjectSystem\Project; use App\Entity\LabelSystem\LabelProfile; use App\Entity\Parts\Category; @@ -67,6 +68,7 @@ class EntityExtensionTest extends WebTestCase $this->assertSame('currency', $this->service->getEntityType(new Currency())); $this->assertSame('measurement_unit', $this->service->getEntityType(new MeasurementUnit())); $this->assertSame('label_profile', $this->service->getEntityType(new LabelProfile())); + $this->assertSame('part_custom_state', $this->service->getEntityType(new PartCustomState())); } } From 6cea41b5e48e1adbb6da0544af2947d651c36510 Mon Sep 17 00:00:00 2001 From: Marcel Diegelmann Date: Tue, 14 Oct 2025 16:52:35 +0200 Subject: [PATCH 3/3] =?UTF-8?q?PartCustomStateEndpoint=20hinzuf=C3=BCgen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Endpoints/PartCustomStateEndpointTest.php | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/API/Endpoints/PartCustomStateEndpointTest.php diff --git a/tests/API/Endpoints/PartCustomStateEndpointTest.php b/tests/API/Endpoints/PartCustomStateEndpointTest.php new file mode 100644 index 00000000..ac353d9c --- /dev/null +++ b/tests/API/Endpoints/PartCustomStateEndpointTest.php @@ -0,0 +1,69 @@ +. + */ + +declare(strict_types=1); + + +namespace App\Tests\API\Endpoints; + +class PartCustomStateEndpointTest extends CrudEndpointTestCase +{ + + protected function getBasePath(): string + { + return '/api/part_custom_states'; + } + + public function testGetCollection(): void + { + $this->_testGetCollection(); + self::assertJsonContains([ + 'hydra:totalItems' => 7, + ]); + } + + public function testGetItem(): void + { + $this->_testGetItem(1); + $this->_testGetItem(2); + $this->_testGetItem(3); + } + + public function testCreateItem(): void + { + $this->_testPostItem([ + 'name' => 'Test API', + 'parent' => '/api/part_custom_states/1', + ]); + } + + public function testUpdateItem(): void + { + $this->_testPatchItem(5, [ + 'name' => 'Updated', + 'parent' => '/api/part_custom_states/2', + ]); + } + + public function testDeleteItem(): void + { + $this->_testDeleteItem(4); + } +}