addSql('CREATE TABLE sms_settings (id INT AUTO_INCREMENT NOT NULL, entity_type VARCHAR(10) NOT NULL, entity_id INT NOT NULL, reminder_enabled TINYINT NOT NULL, reminder_hours_before SMALLINT NOT NULL, post_visit_enabled TINYINT NOT NULL, post_visit_text LONGTEXT DEFAULT NULL, updated_at INT NOT NULL, UNIQUE INDEX uniq_sms_settings_entity (entity_type, entity_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4'); $this->addSql('CREATE TABLE sms_wallet_transactions (id INT AUTO_INCREMENT NOT NULL, uuid VARCHAR(36) NOT NULL, type VARCHAR(10) NOT NULL, amount_rials INT NOT NULL, description VARCHAR(255) DEFAULT NULL, created_at INT NOT NULL, wallet_id INT NOT NULL, payment_id INT DEFAULT NULL, UNIQUE INDEX UNIQ_377BA1E0D17F50A6 (uuid), INDEX IDX_377BA1E0712520F3 (wallet_id), INDEX IDX_377BA1E04C3A3BB (payment_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4'); $this->addSql('CREATE TABLE sms_wallets (id INT AUTO_INCREMENT NOT NULL, entity_type VARCHAR(10) NOT NULL, entity_id INT NOT NULL, balance_rials INT NOT NULL, created_at INT NOT NULL, updated_at INT NOT NULL, UNIQUE INDEX uniq_sms_wallet_entity (entity_type, entity_id), PRIMARY KEY (id)) DEFAULT CHARACTER SET utf8mb4'); $this->addSql('ALTER TABLE sms_wallet_transactions ADD CONSTRAINT FK_377BA1E0712520F3 FOREIGN KEY (wallet_id) REFERENCES sms_wallets (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE sms_wallet_transactions ADD CONSTRAINT FK_377BA1E04C3A3BB FOREIGN KEY (payment_id) REFERENCES payments (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 sms_wallet_transactions DROP FOREIGN KEY FK_377BA1E0712520F3'); $this->addSql('ALTER TABLE sms_wallet_transactions DROP FOREIGN KEY FK_377BA1E04C3A3BB'); $this->addSql('DROP TABLE sms_settings'); $this->addSql('DROP TABLE sms_wallet_transactions'); $this->addSql('DROP TABLE sms_wallets'); } }