- Introduced `consumables` field in `ServiceItem` to allow multiple individual items alongside inventory packages. - Created `ServiceItemConsumable` entity to manage individual consumable items linked to a service. - Updated `ServiceItemController` to handle CRUD operations for consumables. - Enhanced `ServiceDetailPage` and `ServiceItemFormModal` to display and manage consumables. - Added tests to ensure functionality for adding, updating, and validating consumables. - Updated API documentation to reflect changes in service item structure and consumables.
34 lines
1.5 KiB
PHP
34 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
/**
|
|
* اقلام کالای تکیِ هر خدمت — مکمل inventory_package_id، نه جایگزین آن.
|
|
*/
|
|
final class Version20260718085747 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Add service_item_consumables table';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('CREATE TABLE service_item_consumables (id INT AUTO_INCREMENT NOT NULL, amount INT NOT NULL, service_item_id INT NOT NULL, item_id INT NOT NULL, INDEX IDX_DC02A217DDEB00C2 (service_item_id), INDEX IDX_DC02A217126F525E (item_id), UNIQUE INDEX uniq_service_item_consumable (service_item_id, item_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4');
|
|
$this->addSql('ALTER TABLE service_item_consumables ADD CONSTRAINT FK_DC02A217DDEB00C2 FOREIGN KEY (service_item_id) REFERENCES service_items (id) ON DELETE CASCADE');
|
|
$this->addSql('ALTER TABLE service_item_consumables ADD CONSTRAINT FK_DC02A217126F525E FOREIGN KEY (item_id) REFERENCES inventory_items (id) ON DELETE CASCADE');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE service_item_consumables DROP FOREIGN KEY FK_DC02A217DDEB00C2');
|
|
$this->addSql('ALTER TABLE service_item_consumables DROP FOREIGN KEY FK_DC02A217126F525E');
|
|
$this->addSql('DROP TABLE service_item_consumables');
|
|
}
|
|
}
|