<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241023094753 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE referral (
id BIGINT UNSIGNED NOT NULL,
referred_by_id BIGINT UNSIGNED DEFAULT NULL,
code VARCHAR(10) DEFAULT NULL,
is_enabled TINYINT(1) DEFAULT 0 NOT NULL,
duration_days_per_referred_user INT UNSIGNED NOT NULL,
referred_by_ended_at DATETIME DEFAULT NULL,
referral_activity_commission_percent INT UNSIGNED NOT NULL,
INDEX IDX_73079D00758C8114 (referred_by_id),
INDEX idx_referral_code (code),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE referral ADD CONSTRAINT FK_73079D00BF396750 FOREIGN KEY (id) REFERENCES user (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE referral ADD CONSTRAINT FK_73079D00758C8114 FOREIGN KEY (referred_by_id) REFERENCES user (id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE referral DROP FOREIGN KEY FK_73079D00BF396750');
$this->addSql('ALTER TABLE referral DROP FOREIGN KEY FK_73079D00758C8114');
$this->addSql('DROP TABLE referral');
}
}