diff --git a/.env b/.env index b8b2f78..4d48e91 100644 --- a/.env +++ b/.env @@ -24,5 +24,5 @@ APP_SECRET=927b6476c39dc61a41e55ee144b865f2 # # DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db" # DATABASE_URL="mysql://db_user:db_password@127.0.0.1:3306/db_name?serverVersion=5.7&charset=utf8mb4" -DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db" +DATABASE_URL="sqlite:///%kernel.project_dir%/var/app2.db" ###< doctrine/doctrine-bundle ### diff --git a/migrations/Version20220524145844.php b/migrations/Version20220524145844.php deleted file mode 100644 index 93e1b17..0000000 --- a/migrations/Version20220524145844.php +++ /dev/null @@ -1,65 +0,0 @@ -addSql('DROP INDEX IDX_CA4C3EB8ED5CA9E6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_be_sub AS SELECT id, service_id, code, status, sub_date, unsub_date FROM mer_be_sub'); - $this->addSql('DROP TABLE mer_be_sub'); - $this->addSql('CREATE TABLE mer_be_sub (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, service_id INTEGER NOT NULL, code VARCHAR(255) DEFAULT NULL, status INTEGER NOT NULL, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable) - , unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) - , CONSTRAINT FK_CA4C3EB8ED5CA9E6 FOREIGN KEY (service_id) REFERENCES mer_service (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('INSERT INTO mer_be_sub (id, service_id, code, status, sub_date, unsub_date) SELECT id, service_id, code, status, sub_date, unsub_date FROM __temp__mer_be_sub'); - $this->addSql('DROP TABLE __temp__mer_be_sub'); - $this->addSql('CREATE INDEX IDX_CA4C3EB8ED5CA9E6 ON mer_be_sub (service_id)'); - $this->addSql('DROP INDEX IDX_E4F82A3DED5CA9E6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_para_sub AS SELECT id, service_id, pin, status, sub_date, unsub_date FROM mer_para_sub'); - $this->addSql('DROP TABLE mer_para_sub'); - $this->addSql('CREATE TABLE mer_para_sub (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, service_id INTEGER NOT NULL, pin INTEGER DEFAULT NULL, status INTEGER NOT NULL, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable) - , unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) - , CONSTRAINT FK_E4F82A3DED5CA9E6 FOREIGN KEY (service_id) REFERENCES mer_service (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('INSERT INTO mer_para_sub (id, service_id, pin, status, sub_date, unsub_date) SELECT id, service_id, pin, status, sub_date, unsub_date FROM __temp__mer_para_sub'); - $this->addSql('DROP TABLE __temp__mer_para_sub'); - $this->addSql('CREATE INDEX IDX_E4F82A3DED5CA9E6 ON mer_para_sub (service_id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP INDEX IDX_CA4C3EB8ED5CA9E6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_be_sub AS SELECT id, service_id, code, status, sub_date, unsub_date FROM mer_be_sub'); - $this->addSql('DROP TABLE mer_be_sub'); - $this->addSql('CREATE TABLE mer_be_sub (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, service_id INTEGER NOT NULL, code VARCHAR(255) DEFAULT NULL, status INTEGER NOT NULL, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable) - , unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) - )'); - $this->addSql('INSERT INTO mer_be_sub (id, service_id, code, status, sub_date, unsub_date) SELECT id, service_id, code, status, sub_date, unsub_date FROM __temp__mer_be_sub'); - $this->addSql('DROP TABLE __temp__mer_be_sub'); - $this->addSql('CREATE INDEX IDX_CA4C3EB8ED5CA9E6 ON mer_be_sub (service_id)'); - $this->addSql('DROP INDEX IDX_E4F82A3DED5CA9E6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_para_sub AS SELECT id, service_id, pin, status, sub_date, unsub_date FROM mer_para_sub'); - $this->addSql('DROP TABLE mer_para_sub'); - $this->addSql('CREATE TABLE mer_para_sub (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, service_id INTEGER NOT NULL, pin INTEGER DEFAULT NULL, status INTEGER NOT NULL, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable) - , unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) - )'); - $this->addSql('INSERT INTO mer_para_sub (id, service_id, pin, status, sub_date, unsub_date) SELECT id, service_id, pin, status, sub_date, unsub_date FROM __temp__mer_para_sub'); - $this->addSql('DROP TABLE __temp__mer_para_sub'); - $this->addSql('CREATE INDEX IDX_E4F82A3DED5CA9E6 ON mer_para_sub (service_id)'); - } -} diff --git a/migrations/Version20220524145056.php b/migrations/Version20220524155905.php similarity index 80% rename from migrations/Version20220524145056.php rename to migrations/Version20220524155905.php index ada21a5..4d0f647 100644 --- a/migrations/Version20220524145056.php +++ b/migrations/Version20220524155905.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20220524145056 extends AbstractMigration +final class Version20220524155905 extends AbstractMigration { public function getDescription(): string { @@ -25,15 +25,16 @@ final class Version20220524145056 extends AbstractMigration , unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) )'); $this->addSql('CREATE INDEX IDX_CA4C3EB8ED5CA9E6 ON mer_be_sub (service_id)'); - $this->addSql('CREATE TABLE mer_dm (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, offer_id INTEGER NOT NULL)'); - $this->addSql('CREATE TABLE mer_dt (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, service_id VARCHAR(255) NOT NULL)'); + $this->addSql('CREATE TABLE mer_dm (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, ott_id INTEGER DEFAULT NULL, offer_id INTEGER NOT NULL)'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_C03EF7C6396F71CA ON mer_dm (ott_id)'); + $this->addSql('CREATE TABLE mer_dt (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, ott_id INTEGER DEFAULT NULL, service_id VARCHAR(255) NOT NULL)'); + $this->addSql('CREATE UNIQUE INDEX UNIQ_A4555F06396F71CA ON mer_dt (ott_id)'); $this->addSql('CREATE TABLE mer_para_sub (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, service_id INTEGER NOT NULL, pin INTEGER DEFAULT NULL, status INTEGER NOT NULL, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable) , unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) )'); $this->addSql('CREATE INDEX IDX_E4F82A3DED5CA9E6 ON mer_para_sub (service_id)'); - $this->addSql('CREATE TABLE mer_service (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, platform_id INTEGER NOT NULL, mcc_mnc INTEGER DEFAULT NULL, metadata CLOB DEFAULT NULL --(DC2Type:json) + $this->addSql('CREATE TABLE mer_service (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, mcc_mnc INTEGER DEFAULT NULL, metadata CLOB DEFAULT NULL --(DC2Type:json) , discr VARCHAR(255) NOT NULL, product_code VARCHAR(255) DEFAULT NULL, api_key VARCHAR(255) DEFAULT NULL, activation_code VARCHAR(255) DEFAULT NULL)'); - $this->addSql('CREATE INDEX IDX_E9ABEA72FFE6496F ON mer_service (platform_id)'); } public function down(Schema $schema): void diff --git a/src/DataFixtures/MerFixtures.php b/src/DataFixtures/MerFixtures.php index e7cb6f7..d5ca638 100644 --- a/src/DataFixtures/MerFixtures.php +++ b/src/DataFixtures/MerFixtures.php @@ -19,27 +19,27 @@ class MerFixtures extends Fixture { $ser1 = new MerParaDM(); $ser1->setMccMnc(12345) - ->setPlatform((new MerDM())->setOfferId(221)) + ->setPlatform((new MerDM())->setOfferId(221)->setPlatform($ser1)) ->setProductCode('code1'); $ser2 = new MerParaDM(); $ser2->setMccMnc(12345) - ->setPlatform((new MerDM())->setOfferId(223)) + ->setPlatform((new MerDM())->setOfferId(223)->setPlatform($ser2)) ->setProductCode('code2'); $ser3 = new MerParaDT(); $ser3->setMccMnc(12345) - ->setPlatform((new MerDT())->setServiceId('ser-vi-ce1')) + ->setPlatform((new MerDT())->setServiceId('ser-vi-ce1')->setPlatform($ser3)) ->setApiKey('api1'); $ser4 = new MerParaDT(); $ser4->setMccMnc(12341) - ->setPlatform((new MerDT())->setServiceId('ser-vi-ce2')) + ->setPlatform((new MerDT())->setServiceId('ser-vi-ce2')->setPlatform($ser4)) ->setApiKey('api2'); $ser5 = new MerBeDM(); $ser5->setMccMnc(12341) - ->setPlatform((new MerDM())->setOfferId(112)) + ->setPlatform((new MerDM())->setOfferId(112)->setPlatform($ser5)) ->setActivationCode('active1'); $sub1 = new MerParaSub(); diff --git a/src/Entity/MerBeDM.php b/src/Entity/MerBeDM.php index 41d273a..c746f0d 100644 --- a/src/Entity/MerBeDM.php +++ b/src/Entity/MerBeDM.php @@ -6,7 +6,7 @@ use App\Repository\MerBeDMRepository; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: MerBeDMRepository::class)] -class MerBeDM extends MerService +class MerBeDM extends MerService implements OttInterface { // #[ORM\Id] // #[ORM\GeneratedValue] @@ -16,10 +16,6 @@ class MerBeDM extends MerService #[ORM\Column(type: 'string', length: 255)] private $activation_code; - #[ORM\OneToOne(targetEntity: MerDM::class, cascade: ['persist'])] - #[ORM\JoinColumn(nullable: false)] - private MerDM $platform; - // public function getId(): ?int // { // return $this->id; @@ -36,16 +32,4 @@ class MerBeDM extends MerService return $this; } - - public function getPlatform(): ?MerDM - { - return $this->platform; - } - - public function setPlatform(?MerDM $platform): self - { - $this->platform = $platform; - - return $this; - } } diff --git a/src/Entity/MerDM.php b/src/Entity/MerDM.php index 6d48778..be9d540 100644 --- a/src/Entity/MerDM.php +++ b/src/Entity/MerDM.php @@ -6,7 +6,7 @@ use App\Repository\MerDMRepository; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: MerDMRepository::class)] -class MerDM +class MerDM extends Platform { #[ORM\Id] #[ORM\GeneratedValue] diff --git a/src/Entity/MerDT.php b/src/Entity/MerDT.php index 8430ed3..f2fb7f7 100644 --- a/src/Entity/MerDT.php +++ b/src/Entity/MerDT.php @@ -6,7 +6,7 @@ use App\Repository\MerDTRepository; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: MerDTRepository::class)] -class MerDT +class MerDT extends Platform { #[ORM\Id] #[ORM\GeneratedValue] diff --git a/src/Entity/MerParaDM.php b/src/Entity/MerParaDM.php index dc44db9..9648293 100644 --- a/src/Entity/MerParaDM.php +++ b/src/Entity/MerParaDM.php @@ -6,7 +6,7 @@ use App\Repository\MerParaDMRepository; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: MerParaDMRepository::class)] -class MerParaDM extends MerService +class MerParaDM extends MerService implements OttInterface { // #[ORM\Id] // #[ORM\GeneratedValue] @@ -16,10 +16,6 @@ class MerParaDM extends MerService #[ORM\Column(type: 'string', length: 255)] private $product_code; - #[ORM\OneToOne(targetEntity: MerDM::class, cascade: ['persist'])] - #[ORM\JoinColumn(nullable: false)] - private MerDM $platform; - // public function getId(): ?int // { // return $this->id; @@ -36,16 +32,4 @@ class MerParaDM extends MerService return $this; } - - public function getPlatform(): ?MerDM - { - return $this->platform; - } - - public function setPlatform(?MerDM $platform): self - { - $this->platform = $platform; - - return $this; - } } diff --git a/src/Entity/MerParaDT.php b/src/Entity/MerParaDT.php index c362089..1487df4 100644 --- a/src/Entity/MerParaDT.php +++ b/src/Entity/MerParaDT.php @@ -6,7 +6,7 @@ use App\Repository\MerParaDTRepository; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: MerParaDTRepository::class)] -class MerParaDT extends MerService +class MerParaDT extends MerService implements OttInterface { // #[ORM\Id] // #[ORM\GeneratedValue] @@ -16,10 +16,6 @@ class MerParaDT extends MerService #[ORM\Column(type: 'string', length: 255)] private $api_key; - #[ORM\OneToOne(targetEntity: MerDT::class, cascade: ['persist'])] - #[ORM\JoinColumn(nullable: false)] - private MerDT $platform; - // public function getId(): ?int // { // return $this->id; @@ -36,16 +32,4 @@ class MerParaDT extends MerService return $this; } - - public function getPlatform(): ?MerDT - { - return $this->platform; - } - - public function setPlatform(?MerDT $platform): self - { - $this->platform = $platform; - - return $this; - } } diff --git a/src/Entity/MerService.php b/src/Entity/MerService.php index 9386ea4..eea2e9b 100644 --- a/src/Entity/MerService.php +++ b/src/Entity/MerService.php @@ -3,6 +3,7 @@ namespace App\Entity; use App\Repository\MerServiceRepository; +use Doctrine\DBAL\Platforms\OraclePlatform; use Doctrine\ORM\Mapping as ORM; #[ORM\InheritanceType('SINGLE_TABLE')] @@ -26,6 +27,9 @@ abstract class MerService #[ORM\Column(type: 'json', nullable: true)] private $metadata = []; + #[ORM\OneToOne(targetEntity: Platform::class, cascade: ['persist'], mappedBy: 'ott')] + private Platform $platform; + public function getId(): ?int { return $this->id; @@ -54,4 +58,16 @@ abstract class MerService return $this; } + + public function getPlatform(): ?Platform + { + return $this->platform; + } + + public function setPlatform(?Platform $platform): self + { + $this->platform = $platform; + + return $this; + } } diff --git a/src/Entity/OttInterface.php b/src/Entity/OttInterface.php new file mode 100644 index 0000000..cae4cbc --- /dev/null +++ b/src/Entity/OttInterface.php @@ -0,0 +1,8 @@ +ott; + } + + public function setPlatform(?MerService $ott): self + { + $this->ott = $ott; + + return $this; + } +} \ No newline at end of file