migrations/Version20241023094753.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20241023094753 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return '';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->addSql('CREATE TABLE referral (
  19.             id BIGINT UNSIGNED NOT NULL,
  20.             referred_by_id BIGINT UNSIGNED DEFAULT NULL,
  21.             code VARCHAR(10) DEFAULT NULL,
  22.             is_enabled TINYINT(1) DEFAULT 0 NOT NULL,
  23.             duration_days_per_referred_user INT UNSIGNED NOT NULL,
  24.             referred_by_ended_at DATETIME DEFAULT NULL,
  25.             referral_activity_commission_percent INT UNSIGNED NOT NULL,
  26.             INDEX IDX_73079D00758C8114 (referred_by_id),
  27.             INDEX idx_referral_code (code),
  28.             PRIMARY KEY(id)
  29.         ) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
  30.         $this->addSql('ALTER TABLE referral ADD CONSTRAINT FK_73079D00BF396750 FOREIGN KEY (id) REFERENCES user (id) ON DELETE CASCADE');
  31.         $this->addSql('ALTER TABLE referral ADD CONSTRAINT FK_73079D00758C8114 FOREIGN KEY (referred_by_id) REFERENCES user (id)');
  32.     }
  33.     public function down(Schema $schema): void
  34.     {
  35.         // this down() migration is auto-generated, please modify it to your needs
  36.         $this->addSql('ALTER TABLE referral DROP FOREIGN KEY FK_73079D00BF396750');
  37.         $this->addSql('ALTER TABLE referral DROP FOREIGN KEY FK_73079D00758C8114');
  38.         $this->addSql('DROP TABLE referral');
  39.     }
  40. }