addSql('CREATE TABLE cancellation_policies (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, free_window_hours SMALLINT DEFAULT 24 NOT NULL, penalty_mode VARCHAR(10) DEFAULT \'none\' NOT NULL, penalty_value INT DEFAULT 0 NOT NULL, deposit_refundable TINYINT DEFAULT 0 NOT NULL, credit_refundable TINYINT DEFAULT 1 NOT NULL, no_show_threshold SMALLINT DEFAULT 3 NOT NULL, risk_tag_uuid VARCHAR(36) DEFAULT NULL, active TINYINT DEFAULT 1 NOT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, entity_type VARCHAR(10) NOT NULL, entity_id INT NOT NULL, service_item_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_52BE2A1D17F50A6 (uuid), INDEX IDX_52BE2A1DDEB00C2 (service_item_id), INDEX idx_cancel_policies_tenant (entity_type, entity_id, active), UNIQUE INDEX uniq_cancel_policy_scope (entity_type, entity_id, service_item_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4'); $this->addSql('CREATE TABLE no_show_records (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, recorded_at INT NOT NULL, entity_type VARCHAR(10) NOT NULL, entity_id INT NOT NULL, patient_record_id INT NOT NULL, appointment_id INT NOT NULL, recorded_by INT DEFAULT NULL, UNIQUE INDEX UNIQ_C373420D17F50A6 (uuid), INDEX IDX_C373420EB76A733 (patient_record_id), INDEX IDX_C37342082D4278B (recorded_by), INDEX idx_no_show_patient (patient_record_id, recorded_at), INDEX idx_no_show_tenant (entity_type, entity_id, recorded_at), UNIQUE INDEX uniq_no_show_appointment (appointment_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4'); $this->addSql('CREATE TABLE waitlist_entries (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, branch_id INT DEFAULT NULL, desired_from INT NOT NULL, desired_to INT NOT NULL, preferred_day_parts JSON DEFAULT NULL, priority SMALLINT DEFAULT 0 NOT NULL, status VARCHAR(12) DEFAULT \'waiting\' NOT NULL, notified_at INT DEFAULT NULL, notify_count SMALLINT DEFAULT 0 NOT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, entity_type VARCHAR(10) NOT NULL, entity_id INT NOT NULL, patient_record_id INT NOT NULL, service_item_id INT NOT NULL, converted_appointment_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_E74550EED17F50A6 (uuid), INDEX IDX_E74550EEEB76A733 (patient_record_id), INDEX IDX_E74550EEDDEB00C2 (service_item_id), INDEX IDX_E74550EE4B79C8F8 (converted_appointment_id), INDEX idx_waitlist_match (service_item_id, branch_id, status, desired_from, desired_to), INDEX idx_waitlist_tenant (entity_type, entity_id, status, created_at), INDEX idx_waitlist_patient (patient_record_id, status), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4'); $this->addSql('ALTER TABLE cancellation_policies ADD CONSTRAINT FK_52BE2A1DDEB00C2 FOREIGN KEY (service_item_id) REFERENCES service_items (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE no_show_records ADD CONSTRAINT FK_C373420EB76A733 FOREIGN KEY (patient_record_id) REFERENCES patient_records (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE no_show_records ADD CONSTRAINT FK_C373420E5B533F9 FOREIGN KEY (appointment_id) REFERENCES appointments (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE no_show_records ADD CONSTRAINT FK_C37342082D4278B FOREIGN KEY (recorded_by) REFERENCES users (id) ON DELETE SET NULL'); $this->addSql('ALTER TABLE waitlist_entries ADD CONSTRAINT FK_E74550EEEB76A733 FOREIGN KEY (patient_record_id) REFERENCES patient_records (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE waitlist_entries ADD CONSTRAINT FK_E74550EEDDEB00C2 FOREIGN KEY (service_item_id) REFERENCES service_items (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE waitlist_entries ADD CONSTRAINT FK_E74550EE4B79C8F8 FOREIGN KEY (converted_appointment_id) REFERENCES appointments (id) ON DELETE SET NULL'); } public function down(Schema $schema): void { // this down() migration is auto-generated, please modify it to your needs $this->addSql('ALTER TABLE cancellation_policies DROP FOREIGN KEY FK_52BE2A1DDEB00C2'); $this->addSql('ALTER TABLE no_show_records DROP FOREIGN KEY FK_C373420EB76A733'); $this->addSql('ALTER TABLE no_show_records DROP FOREIGN KEY FK_C373420E5B533F9'); $this->addSql('ALTER TABLE no_show_records DROP FOREIGN KEY FK_C37342082D4278B'); $this->addSql('ALTER TABLE waitlist_entries DROP FOREIGN KEY FK_E74550EEEB76A733'); $this->addSql('ALTER TABLE waitlist_entries DROP FOREIGN KEY FK_E74550EEDDEB00C2'); $this->addSql('ALTER TABLE waitlist_entries DROP FOREIGN KEY FK_E74550EE4B79C8F8'); $this->addSql('DROP TABLE cancellation_policies'); $this->addSql('DROP TABLE no_show_records'); $this->addSql('DROP TABLE waitlist_entries'); } }