From 937c2a459d294361526c3c80c20f717ee243a3c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20=C3=81lvarez?= Date: Tue, 24 May 2022 17:07:26 +0200 Subject: [PATCH] not working --- migrations/Version20220520203412.php | 31 ------- migrations/Version20220522111615.php | 34 -------- migrations/Version20220522115037.php | 48 ----------- migrations/Version20220522153147.php | 64 --------------- migrations/Version20220522154942.php | 81 ------------------- migrations/Version20220523093709.php | 49 ----------- migrations/Version20220523110817.php | 36 --------- migrations/Version20220523114408.php | 32 -------- migrations/Version20220523132530.php | 47 ----------- migrations/Version20220523152033.php | 47 ----------- migrations/Version20220523155141.php | 48 ----------- migrations/Version20220523155631.php | 52 ------------ migrations/Version20220524145056.php | 49 +++++++++++ ...24080445.php => Version20220524145844.php} | 10 +-- src/DataFixtures/MerFixtures.php | 12 +-- src/Entity/MerBeDM.php | 18 ++++- src/Entity/MerDM.php | 20 ++--- src/Entity/MerDT.php | 20 ++--- src/Entity/MerParaDM.php | 18 ++++- src/Entity/MerParaDT.php | 18 ++++- src/Repository/MerServiceRepository.php | 40 +++++---- 21 files changed, 153 insertions(+), 621 deletions(-) delete mode 100644 migrations/Version20220520203412.php delete mode 100644 migrations/Version20220522111615.php delete mode 100644 migrations/Version20220522115037.php delete mode 100644 migrations/Version20220522153147.php delete mode 100644 migrations/Version20220522154942.php delete mode 100644 migrations/Version20220523093709.php delete mode 100644 migrations/Version20220523110817.php delete mode 100644 migrations/Version20220523114408.php delete mode 100644 migrations/Version20220523132530.php delete mode 100644 migrations/Version20220523152033.php delete mode 100644 migrations/Version20220523155141.php delete mode 100644 migrations/Version20220523155631.php create mode 100644 migrations/Version20220524145056.php rename migrations/{Version20220524080445.php => Version20220524145844.php} (87%) diff --git a/migrations/Version20220520203412.php b/migrations/Version20220520203412.php deleted file mode 100644 index 393b0d1..0000000 --- a/migrations/Version20220520203412.php +++ /dev/null @@ -1,31 +0,0 @@ -addSql('CREATE TABLE entity1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(255) NOT NULL)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE entity1'); - } -} diff --git a/migrations/Version20220522111615.php b/migrations/Version20220522111615.php deleted file mode 100644 index b64fe8c..0000000 --- a/migrations/Version20220522111615.php +++ /dev/null @@ -1,34 +0,0 @@ -addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)'); - $this->addSql('CREATE TABLE toothbrush1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, brand VARCHAR(255) NOT NULL)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE employee1'); - $this->addSql('DROP TABLE toothbrush1'); - } -} diff --git a/migrations/Version20220522115037.php b/migrations/Version20220522115037.php deleted file mode 100644 index b9080d8..0000000 --- a/migrations/Version20220522115037.php +++ /dev/null @@ -1,48 +0,0 @@ -addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL)'); - $this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)'); - $this->addSql('CREATE TABLE toothbrush2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, brand VARCHAR(255) NOT NULL)'); - $this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38'); - $this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1'); - $this->addSql('DROP TABLE employee1'); - $this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, CONSTRAINT FK_2250E3BCA25DC38 FOREIGN KEY (toothbrush1_id) REFERENCES toothbrush1 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1'); - $this->addSql('DROP TABLE __temp__employee1'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE person2'); - $this->addSql('DROP TABLE toothbrush2'); - $this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38'); - $this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1'); - $this->addSql('DROP TABLE employee1'); - $this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL)'); - $this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1'); - $this->addSql('DROP TABLE __temp__employee1'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)'); - } -} diff --git a/migrations/Version20220522153147.php b/migrations/Version20220522153147.php deleted file mode 100644 index c8a45f6..0000000 --- a/migrations/Version20220522153147.php +++ /dev/null @@ -1,64 +0,0 @@ -addSql('CREATE TABLE employee3 (id INTEGER NOT NULL, job VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); - $this->addSql('CREATE TABLE person3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush3_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_D4808643A02C14B3 ON person3 (toothbrush3_id)'); - $this->addSql('CREATE TABLE toothbrush3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, brand VARCHAR(255) NOT NULL)'); - $this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38'); - $this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1'); - $this->addSql('DROP TABLE employee1'); - $this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, CONSTRAINT FK_2250E3BCA25DC38 FOREIGN KEY (toothbrush1_id) REFERENCES toothbrush1 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1'); - $this->addSql('DROP TABLE __temp__employee1'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)'); - $this->addSql('DROP INDEX IDX_A387B6D5189073D6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__person2 AS SELECT id, toothbrush2_id, age, name, discr, job FROM person2'); - $this->addSql('DROP TABLE person2'); - $this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL, CONSTRAINT FK_A387B6D5189073D6 FOREIGN KEY (toothbrush2_id) REFERENCES toothbrush2 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('INSERT INTO person2 (id, toothbrush2_id, age, name, discr, job) SELECT id, toothbrush2_id, age, name, discr, job FROM __temp__person2'); - $this->addSql('DROP TABLE __temp__person2'); - $this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP TABLE employee3'); - $this->addSql('DROP TABLE person3'); - $this->addSql('DROP TABLE toothbrush3'); - $this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38'); - $this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1'); - $this->addSql('DROP TABLE employee1'); - $this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL)'); - $this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1'); - $this->addSql('DROP TABLE __temp__employee1'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)'); - $this->addSql('DROP INDEX IDX_A387B6D5189073D6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__person2 AS SELECT id, toothbrush2_id, age, name, discr, job FROM person2'); - $this->addSql('DROP TABLE person2'); - $this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL)'); - $this->addSql('INSERT INTO person2 (id, toothbrush2_id, age, name, discr, job) SELECT id, toothbrush2_id, age, name, discr, job FROM __temp__person2'); - $this->addSql('DROP TABLE __temp__person2'); - $this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)'); - } -} diff --git a/migrations/Version20220522154942.php b/migrations/Version20220522154942.php deleted file mode 100644 index eeb8160..0000000 --- a/migrations/Version20220522154942.php +++ /dev/null @@ -1,81 +0,0 @@ -addSql('DROP INDEX UNIQ_2250E3BCA25DC38'); - $this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1'); - $this->addSql('DROP TABLE employee1'); - $this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, CONSTRAINT FK_2250E3BCA25DC38 FOREIGN KEY (toothbrush1_id) REFERENCES toothbrush1 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1'); - $this->addSql('DROP TABLE __temp__employee1'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)'); - $this->addSql('CREATE TEMPORARY TABLE __temp__employee3 AS SELECT id, job FROM employee3'); - $this->addSql('DROP TABLE employee3'); - $this->addSql('CREATE TABLE employee3 (id INTEGER NOT NULL, job VARCHAR(255) NOT NULL, PRIMARY KEY(id), CONSTRAINT FK_CC5E8290BF396750 FOREIGN KEY (id) REFERENCES person3 (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('INSERT INTO employee3 (id, job) SELECT id, job FROM __temp__employee3'); - $this->addSql('DROP TABLE __temp__employee3'); - $this->addSql('DROP INDEX IDX_A387B6D5189073D6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__person2 AS SELECT id, toothbrush2_id, age, name, discr, job FROM person2'); - $this->addSql('DROP TABLE person2'); - $this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL, CONSTRAINT FK_A387B6D5189073D6 FOREIGN KEY (toothbrush2_id) REFERENCES toothbrush2 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('INSERT INTO person2 (id, toothbrush2_id, age, name, discr, job) SELECT id, toothbrush2_id, age, name, discr, job FROM __temp__person2'); - $this->addSql('DROP TABLE __temp__person2'); - $this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)'); - $this->addSql('DROP INDEX UNIQ_D4808643A02C14B3'); - $this->addSql('CREATE TEMPORARY TABLE __temp__person3 AS SELECT id, toothbrush3_id, age, name, discr FROM person3'); - $this->addSql('DROP TABLE person3'); - $this->addSql('CREATE TABLE person3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush3_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, CONSTRAINT FK_D4808643A02C14B3 FOREIGN KEY (toothbrush3_id) REFERENCES toothbrush3 (id) NOT DEFERRABLE INITIALLY IMMEDIATE)'); - $this->addSql('INSERT INTO person3 (id, toothbrush3_id, age, name, discr) SELECT id, toothbrush3_id, age, name, discr FROM __temp__person3'); - $this->addSql('DROP TABLE __temp__person3'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_D4808643A02C14B3 ON person3 (toothbrush3_id)'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('DROP INDEX UNIQ_2250E3BCA25DC38'); - $this->addSql('CREATE TEMPORARY TABLE __temp__employee1 AS SELECT id, toothbrush1_id, job, age, name FROM employee1'); - $this->addSql('DROP TABLE employee1'); - $this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL)'); - $this->addSql('INSERT INTO employee1 (id, toothbrush1_id, job, age, name) SELECT id, toothbrush1_id, job, age, name FROM __temp__employee1'); - $this->addSql('DROP TABLE __temp__employee1'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)'); - $this->addSql('CREATE TEMPORARY TABLE __temp__employee3 AS SELECT id, job FROM employee3'); - $this->addSql('DROP TABLE employee3'); - $this->addSql('CREATE TABLE employee3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, job VARCHAR(255) NOT NULL)'); - $this->addSql('INSERT INTO employee3 (id, job) SELECT id, job FROM __temp__employee3'); - $this->addSql('DROP TABLE __temp__employee3'); - $this->addSql('DROP INDEX IDX_A387B6D5189073D6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__person2 AS SELECT id, toothbrush2_id, age, name, discr, job FROM person2'); - $this->addSql('DROP TABLE person2'); - $this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL, job VARCHAR(255) DEFAULT NULL)'); - $this->addSql('INSERT INTO person2 (id, toothbrush2_id, age, name, discr, job) SELECT id, toothbrush2_id, age, name, discr, job FROM __temp__person2'); - $this->addSql('DROP TABLE __temp__person2'); - $this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)'); - $this->addSql('DROP INDEX UNIQ_D4808643A02C14B3'); - $this->addSql('CREATE TEMPORARY TABLE __temp__person3 AS SELECT id, toothbrush3_id, age, name, discr FROM person3'); - $this->addSql('DROP TABLE person3'); - $this->addSql('CREATE TABLE person3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush3_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL, discr VARCHAR(255) NOT NULL)'); - $this->addSql('INSERT INTO person3 (id, toothbrush3_id, age, name, discr) SELECT id, toothbrush3_id, age, name, discr FROM __temp__person3'); - $this->addSql('DROP TABLE __temp__person3'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_D4808643A02C14B3 ON person3 (toothbrush3_id)'); - } -} diff --git a/migrations/Version20220523093709.php b/migrations/Version20220523093709.php deleted file mode 100644 index 11133c9..0000000 --- a/migrations/Version20220523093709.php +++ /dev/null @@ -1,49 +0,0 @@ -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, offer_id INTEGER DEFAULT NULL, api_key VARCHAR(255) DEFAULT NULL, service_id VARCHAR(255) DEFAULT NULL)'); - $this->addSql('DROP TABLE employee1'); - $this->addSql('DROP TABLE employee3'); - $this->addSql('DROP TABLE person2'); - $this->addSql('DROP TABLE person3'); - $this->addSql('DROP TABLE toothbrush1'); - $this->addSql('DROP TABLE toothbrush2'); - $this->addSql('DROP TABLE toothbrush3'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE TABLE employee1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush1_id INTEGER DEFAULT NULL, job VARCHAR(255) NOT NULL COLLATE BINARY, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL COLLATE BINARY)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_2250E3BCA25DC38 ON employee1 (toothbrush1_id)'); - $this->addSql('CREATE TABLE employee3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, job VARCHAR(255) NOT NULL COLLATE BINARY)'); - $this->addSql('CREATE TABLE person2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush2_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL COLLATE BINARY, discr VARCHAR(255) NOT NULL COLLATE BINARY, job VARCHAR(255) DEFAULT NULL COLLATE BINARY)'); - $this->addSql('CREATE INDEX IDX_A387B6D5189073D6 ON person2 (toothbrush2_id)'); - $this->addSql('CREATE TABLE person3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, toothbrush3_id INTEGER DEFAULT NULL, age INTEGER NOT NULL, name VARCHAR(255) NOT NULL COLLATE BINARY, discr VARCHAR(255) NOT NULL COLLATE BINARY)'); - $this->addSql('CREATE UNIQUE INDEX UNIQ_D4808643A02C14B3 ON person3 (toothbrush3_id)'); - $this->addSql('CREATE TABLE toothbrush1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, brand VARCHAR(255) NOT NULL COLLATE BINARY)'); - $this->addSql('CREATE TABLE toothbrush2 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, brand VARCHAR(255) NOT NULL COLLATE BINARY)'); - $this->addSql('CREATE TABLE toothbrush3 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, brand VARCHAR(255) NOT NULL COLLATE BINARY)'); - $this->addSql('DROP TABLE mer_service'); - } -} diff --git a/migrations/Version20220523110817.php b/migrations/Version20220523110817.php deleted file mode 100644 index 66037a0..0000000 --- a/migrations/Version20220523110817.php +++ /dev/null @@ -1,36 +0,0 @@ -addSql('ALTER TABLE mer_service ADD COLUMN activation_code VARCHAR(255) DEFAULT NULL'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_service AS SELECT id, mcc_mnc, metadata, discr, product_code, offer_id, api_key, service_id FROM mer_service'); - $this->addSql('DROP TABLE mer_service'); - $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, offer_id INTEGER DEFAULT NULL, api_key VARCHAR(255) DEFAULT NULL, service_id VARCHAR(255) DEFAULT NULL)'); - $this->addSql('INSERT INTO mer_service (id, mcc_mnc, metadata, discr, product_code, offer_id, api_key, service_id) SELECT id, mcc_mnc, metadata, discr, product_code, offer_id, api_key, service_id FROM __temp__mer_service'); - $this->addSql('DROP TABLE __temp__mer_service'); - } -} diff --git a/migrations/Version20220523114408.php b/migrations/Version20220523114408.php deleted file mode 100644 index caeafa6..0000000 --- a/migrations/Version20220523114408.php +++ /dev/null @@ -1,32 +0,0 @@ -addSql('CREATE TABLE mer_para_sub (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, service_id INTEGER NOT NULL, red_code VARCHAR(255) DEFAULT NULL)'); - $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 TABLE mer_para_sub'); - } -} diff --git a/migrations/Version20220523132530.php b/migrations/Version20220523132530.php deleted file mode 100644 index 55178a3..0000000 --- a/migrations/Version20220523132530.php +++ /dev/null @@ -1,47 +0,0 @@ -addSql('DROP INDEX IDX_E4F82A3DED5CA9E6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_para_sub AS SELECT id, service_id, red_code 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, red_code VARCHAR(255) DEFAULT 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, red_code, sub_date) SELECT id, service_id, red_code, DATETIME() 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_E4F82A3DED5CA9E6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_para_sub AS SELECT id, service_id, red_code 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, red_code VARCHAR(255) DEFAULT NULL)'); - $this->addSql('INSERT INTO mer_para_sub (id, service_id, red_code) SELECT id, service_id, red_code 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/Version20220523152033.php b/migrations/Version20220523152033.php deleted file mode 100644 index 34a3e0a..0000000 --- a/migrations/Version20220523152033.php +++ /dev/null @@ -1,47 +0,0 @@ -addSql('DROP INDEX IDX_E4F82A3DED5CA9E6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_para_sub AS SELECT id, service_id, 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, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable) - , unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) - , pin INTEGER DEFAULT NULL, 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, sub_date, unsub_date) SELECT id, service_id, 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_E4F82A3DED5CA9E6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_para_sub AS SELECT id, service_id, 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, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable) - , unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) - , red_code VARCHAR(255) DEFAULT NULL)'); - $this->addSql('INSERT INTO mer_para_sub (id, service_id, sub_date, unsub_date) SELECT id, service_id, 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/Version20220523155141.php b/migrations/Version20220523155141.php deleted file mode 100644 index 0ea8ad8..0000000 --- a/migrations/Version20220523155141.php +++ /dev/null @@ -1,48 +0,0 @@ -addSql('DROP INDEX IDX_E4F82A3DED5CA9E6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_para_sub AS SELECT id, service_id, sub_date, unsub_date, pin 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, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable) - , unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) - , pin INTEGER DEFAULT NULL, status INTEGER NOT NULL, 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, sub_date, unsub_date, pin, status) SELECT id, service_id, sub_date, unsub_date, pin, 1 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_E4F82A3DED5CA9E6'); - $this->addSql('CREATE TEMPORARY TABLE __temp__mer_para_sub AS SELECT id, service_id, pin, 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, 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, sub_date, unsub_date) SELECT id, service_id, pin, 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/Version20220523155631.php b/migrations/Version20220523155631.php deleted file mode 100644 index a692f3b..0000000 --- a/migrations/Version20220523155631.php +++ /dev/null @@ -1,52 +0,0 @@ -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('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, sub_date, unsub_date, pin, status 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, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable) - , unsub_date DATETIME DEFAULT NULL --(DC2Type:datetime_immutable) - , pin INTEGER DEFAULT NULL, status INTEGER NOT NULL, 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, sub_date, unsub_date, pin, status) SELECT id, service_id, sub_date, unsub_date, pin, status 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 TABLE mer_be_sub'); - $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/Version20220524145056.php new file mode 100644 index 0000000..ada21a5 --- /dev/null +++ b/migrations/Version20220524145056.php @@ -0,0 +1,49 @@ +addSql('CREATE TABLE entity1 (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name VARCHAR(255) NOT NULL)'); + $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('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_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) + , 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 + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('DROP TABLE entity1'); + $this->addSql('DROP TABLE mer_be_sub'); + $this->addSql('DROP TABLE mer_dm'); + $this->addSql('DROP TABLE mer_dt'); + $this->addSql('DROP TABLE mer_para_sub'); + $this->addSql('DROP TABLE mer_service'); + } +} diff --git a/migrations/Version20220524080445.php b/migrations/Version20220524145844.php similarity index 87% rename from migrations/Version20220524080445.php rename to migrations/Version20220524145844.php index d975ed2..93e1b17 100644 --- a/migrations/Version20220524080445.php +++ b/migrations/Version20220524145844.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20220524080445 extends AbstractMigration +final class Version20220524145844 extends AbstractMigration { public function getDescription(): string { @@ -30,12 +30,12 @@ final class Version20220524080445 extends AbstractMigration $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, sub_date, unsub_date, pin, status FROM mer_para_sub'); + $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, sub_date DATETIME NOT NULL --(DC2Type:datetime_immutable) + $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) - , pin INTEGER DEFAULT NULL, status INTEGER NOT NULL, 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, sub_date, unsub_date, pin, status) SELECT id, service_id, sub_date, unsub_date, pin, status FROM __temp__mer_para_sub'); + , 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)'); } diff --git a/src/DataFixtures/MerFixtures.php b/src/DataFixtures/MerFixtures.php index 84bd696..e7cb6f7 100644 --- a/src/DataFixtures/MerFixtures.php +++ b/src/DataFixtures/MerFixtures.php @@ -4,6 +4,8 @@ namespace App\DataFixtures; use App\Entity\MerBeDM; use App\Entity\MerBeSub; +use App\Entity\MerDM; +use App\Entity\MerDT; use App\Entity\MerParaDM; use App\Entity\MerParaDT; use App\Entity\MerParaSub; @@ -17,27 +19,27 @@ class MerFixtures extends Fixture { $ser1 = new MerParaDM(); $ser1->setMccMnc(12345) - ->setOfferId(221) + ->setPlatform((new MerDM())->setOfferId(221)) ->setProductCode('code1'); $ser2 = new MerParaDM(); $ser2->setMccMnc(12345) - ->setOfferId(223) + ->setPlatform((new MerDM())->setOfferId(223)) ->setProductCode('code2'); $ser3 = new MerParaDT(); $ser3->setMccMnc(12345) - ->setServiceId('ser-vi-ce1') + ->setPlatform((new MerDT())->setServiceId('ser-vi-ce1')) ->setApiKey('api1'); $ser4 = new MerParaDT(); $ser4->setMccMnc(12341) - ->setServiceId('ser-vi-ce2') + ->setPlatform((new MerDT())->setServiceId('ser-vi-ce2')) ->setApiKey('api2'); $ser5 = new MerBeDM(); $ser5->setMccMnc(12341) - ->setOfferId(112) + ->setPlatform((new MerDM())->setOfferId(112)) ->setActivationCode('active1'); $sub1 = new MerParaSub(); diff --git a/src/Entity/MerBeDM.php b/src/Entity/MerBeDM.php index 95e7cfa..41d273a 100644 --- a/src/Entity/MerBeDM.php +++ b/src/Entity/MerBeDM.php @@ -8,8 +8,6 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: MerBeDMRepository::class)] class MerBeDM extends MerService { - use MerDM; - // #[ORM\Id] // #[ORM\GeneratedValue] // #[ORM\Column(type: 'integer')] @@ -18,6 +16,10 @@ 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; @@ -34,4 +36,16 @@ 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 2eb8acb..6d48778 100644 --- a/src/Entity/MerDM.php +++ b/src/Entity/MerDM.php @@ -5,21 +5,21 @@ namespace App\Entity; use App\Repository\MerDMRepository; use Doctrine\ORM\Mapping as ORM; -//#[ORM\Entity(repositoryClass: MerDMRepository::class)] -trait MerDM +#[ORM\Entity(repositoryClass: MerDMRepository::class)] +class MerDM { -// #[ORM\Id] -// #[ORM\GeneratedValue] -// #[ORM\Column(type: 'integer')] -// private $id; + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: 'integer')] + private $id; #[ORM\Column(type: 'integer')] private $offer_id; -// public function getId(): ?int -// { -// return $this->id; -// } + public function getId(): ?int + { + return $this->id; + } public function getOfferId(): ?int { diff --git a/src/Entity/MerDT.php b/src/Entity/MerDT.php index 66cc709..8430ed3 100644 --- a/src/Entity/MerDT.php +++ b/src/Entity/MerDT.php @@ -5,21 +5,21 @@ namespace App\Entity; use App\Repository\MerDTRepository; use Doctrine\ORM\Mapping as ORM; -//#[ORM\Entity(repositoryClass: MerDTRepository::class)] -trait MerDT +#[ORM\Entity(repositoryClass: MerDTRepository::class)] +class MerDT { -// #[ORM\Id] -// #[ORM\GeneratedValue] -// #[ORM\Column(type: 'integer')] -// private $id; + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: 'integer')] + private $id; #[ORM\Column(type: 'string', length: 255)] private $service_id; -// public function getId(): ?int -// { -// return $this->id; -// } + public function getId(): ?int + { + return $this->id; + } public function getServiceId(): ?string { diff --git a/src/Entity/MerParaDM.php b/src/Entity/MerParaDM.php index ba24013..dc44db9 100644 --- a/src/Entity/MerParaDM.php +++ b/src/Entity/MerParaDM.php @@ -8,8 +8,6 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: MerParaDMRepository::class)] class MerParaDM extends MerService { - use MerDM; - // #[ORM\Id] // #[ORM\GeneratedValue] // #[ORM\Column(type: 'integer')] @@ -18,6 +16,10 @@ 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; @@ -34,4 +36,16 @@ 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 51f8476..c362089 100644 --- a/src/Entity/MerParaDT.php +++ b/src/Entity/MerParaDT.php @@ -8,8 +8,6 @@ use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: MerParaDTRepository::class)] class MerParaDT extends MerService { - use MerDT; - // #[ORM\Id] // #[ORM\GeneratedValue] // #[ORM\Column(type: 'integer')] @@ -18,6 +16,10 @@ 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; @@ -34,4 +36,16 @@ 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/Repository/MerServiceRepository.php b/src/Repository/MerServiceRepository.php index 133370e..e7bbe9c 100644 --- a/src/Repository/MerServiceRepository.php +++ b/src/Repository/MerServiceRepository.php @@ -80,22 +80,30 @@ class MerServiceRepository extends ServiceEntityRepository // ->getResult() // ; - $rsm = new ResultSetMapping(); - $rsm->addEntityResult($this->getClassName(), 's'); - $rsm->addFieldResult('s', 'id', 'id'); - $rsm->addMetaResult('s', 'discr', 'discr'); - $rsm->setDiscriminatorColumn('s', 'discr'); +// $rsm = new ResultSetMapping(); +// $rsm->addEntityResult($this->getClassName(), 's'); +// $rsm->addFieldResult('s', 'id', 'id'); +// $rsm->addMetaResult('s', 'discr', 'discr'); +// $rsm->setDiscriminatorColumn('s', 'discr'); +// +// $query = $this->getEntityManager() +// ->createNativeQuery('SELECT m.id, m.discr FROM mer_service m WHERE offer_id = :offer_id', $rsm); +// $query->setParameter('offer_id', $offerId); +// +// $res = $query->getResult(); +// +// foreach ($res as $k => $obj) { +// $this->getEntityManager()->refresh($obj); +// } +// +// return $res; - $query = $this->getEntityManager() - ->createNativeQuery('SELECT m.id, m.discr FROM mer_service m WHERE offer_id = :offer_id', $rsm); - $query->setParameter('offer_id', $offerId); - - $res = $query->getResult(); - - foreach ($res as $k => $obj) { - $this->getEntityManager()->refresh($obj); - } - - return $res; + return $this->createQueryBuilder('s') + ->leftJoin('s.platform_id', 'p') + ->andWhere('p.offer_id = :offer_id') + ->setParameter('offer_id', $offerId) + ->getQuery() + ->getResult() + ; } }