addSql('CREATE TABLE resource_group (id INT AUTO_INCREMENT NOT NULL, type VARCHAR(255) NOT NULL, label VARCHAR(50) NOT NULL, position INT NOT NULL, svg_element_id VARCHAR(50) DEFAULT NULL, UNIQUE INDEX uniq_resource_group_label (type, label), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4'); $this->addSql('ALTER TABLE resource ADD group_id INT DEFAULT NULL'); // SET NULL rather than RESTRICT: a group is configuration describing the building, and // removing a room must leave its desks bookable rather than blocking the delete. The // plan falls back to drawing them without a frame. $this->addSql('ALTER TABLE resource ADD CONSTRAINT FK_BC91F416FE54D947 FOREIGN KEY (group_id) REFERENCES resource_group (id) ON DELETE SET NULL'); $this->addSql('CREATE INDEX IDX_BC91F416FE54D947 ON resource (group_id)'); } public function down(Schema $schema): void { $this->addSql('ALTER TABLE resource DROP FOREIGN KEY FK_BC91F416FE54D947'); $this->addSql('DROP INDEX IDX_BC91F416FE54D947 ON resource'); $this->addSql('ALTER TABLE resource DROP group_id'); $this->addSql('DROP TABLE resource_group'); } }