diff --git a/README.md b/README.md index c3f126867e5cdc123911e694a68cc078fd0dd0ec..c66b963e2ecb1d91b52511f784eee99eea39c72c 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,9 @@ docker exec -it symfony_app php bin/console make:migration Apply the migration file in the db ``` docker exec -it symfony_app php bin/console doctrine:migrations:migrate +``` + +Rollback to the previous migrate version +``` +php bin/console doctrine:migrations:migrate prev ``` \ No newline at end of file diff --git a/web_app/migrations/Version20250223162147.php b/web_app/migrations/Version20250223162147.php deleted file mode 100644 index 0ce2234cea73599edebdf8ad0c28532c47ebb166..0000000000000000000000000000000000000000 --- a/web_app/migrations/Version20250223162147.php +++ /dev/null @@ -1,35 +0,0 @@ -<?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 Version20250223162147 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 wishlist_item (wish_list_id INT NOT NULL, item_id INT NOT NULL, INDEX IDX_6424F4E8D69F3311 (wish_list_id), INDEX IDX_6424F4E8126F525E (item_id), PRIMARY KEY(wish_list_id, item_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('ALTER TABLE wishlist_item ADD CONSTRAINT FK_6424F4E8D69F3311 FOREIGN KEY (wish_list_id) REFERENCES wish_list (id) ON DELETE CASCADE'); - $this->addSql('ALTER TABLE wishlist_item ADD CONSTRAINT FK_6424F4E8126F525E FOREIGN KEY (item_id) REFERENCES item (id) ON DELETE CASCADE'); - } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE wishlist_item DROP FOREIGN KEY FK_6424F4E8D69F3311'); - $this->addSql('ALTER TABLE wishlist_item DROP FOREIGN KEY FK_6424F4E8126F525E'); - $this->addSql('DROP TABLE wishlist_item'); - } -} diff --git a/web_app/migrations/Version20250223155752.php b/web_app/migrations/Version20250225195907.php similarity index 83% rename from web_app/migrations/Version20250223155752.php rename to web_app/migrations/Version20250225195907.php index 12eff6717352d30f42611696b2c9305832686522..967136ed04015b05e8c97cb6ff264ec0ba41992b 100644 --- a/web_app/migrations/Version20250223155752.php +++ b/web_app/migrations/Version20250225195907.php @@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration; /** * Auto-generated Migration: Please modify to your needs! */ -final class Version20250223155752 extends AbstractMigration +final class Version20250225195907 extends AbstractMigration { public function getDescription(): string { @@ -24,14 +24,14 @@ final class Version20250223155752 extends AbstractMigration $this->addSql('CREATE TABLE purchase (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, wish_list_id INT NOT NULL, item_id INT NOT NULL, url_proof VARCHAR(255) DEFAULT NULL, message VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_6117D13BA76ED395 (user_id), INDEX IDX_6117D13BD69F3311 (wish_list_id), INDEX IDX_6117D13B126F525E (item_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE user (id INT AUTO_INCREMENT NOT NULL, user_name VARCHAR(255) DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, surname VARCHAR(255) DEFAULT NULL, email VARCHAR(255) NOT NULL, password VARCHAR(255) NOT NULL, is_blocked TINYINT(1) DEFAULT NULL, role VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', UNIQUE INDEX UNIQ_8D93D649E7927C74 (email), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE wish_list (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, name VARCHAR(255) NOT NULL, expiration_date DATETIME DEFAULT NULL, is_active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_5B8739BDA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); - $this->addSql('CREATE TABLE wish_list_item (id INT AUTO_INCREMENT NOT NULL, wish_list_id INT NOT NULL, item_id INT NOT NULL, INDEX IDX_9A7FA711D69F3311 (wish_list_id), INDEX IDX_9A7FA711126F525E (item_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); + $this->addSql('CREATE TABLE wishlist_item (wish_list_id INT NOT NULL, item_id INT NOT NULL, INDEX IDX_6424F4E8D69F3311 (wish_list_id), INDEX IDX_6424F4E8126F525E (item_id), PRIMARY KEY(wish_list_id, item_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('CREATE TABLE wish_list_member (id INT AUTO_INCREMENT NOT NULL, wish_list_id INT NOT NULL, user_id INT NOT NULL, can_edit TINYINT(1) NOT NULL, is_accepted TINYINT(1) DEFAULT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_F4CA81DFD69F3311 (wish_list_id), INDEX IDX_F4CA81DFA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); $this->addSql('ALTER TABLE purchase ADD CONSTRAINT FK_6117D13BA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); $this->addSql('ALTER TABLE purchase ADD CONSTRAINT FK_6117D13BD69F3311 FOREIGN KEY (wish_list_id) REFERENCES wish_list (id)'); $this->addSql('ALTER TABLE purchase ADD CONSTRAINT FK_6117D13B126F525E FOREIGN KEY (item_id) REFERENCES item (id)'); $this->addSql('ALTER TABLE wish_list ADD CONSTRAINT FK_5B8739BDA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); - $this->addSql('ALTER TABLE wish_list_item ADD CONSTRAINT FK_9A7FA711D69F3311 FOREIGN KEY (wish_list_id) REFERENCES wish_list (id)'); - $this->addSql('ALTER TABLE wish_list_item ADD CONSTRAINT FK_9A7FA711126F525E FOREIGN KEY (item_id) REFERENCES item (id)'); + $this->addSql('ALTER TABLE wishlist_item ADD CONSTRAINT FK_6424F4E8D69F3311 FOREIGN KEY (wish_list_id) REFERENCES wish_list (id) ON DELETE CASCADE'); + $this->addSql('ALTER TABLE wishlist_item ADD CONSTRAINT FK_6424F4E8126F525E FOREIGN KEY (item_id) REFERENCES item (id) ON DELETE CASCADE'); $this->addSql('ALTER TABLE wish_list_member ADD CONSTRAINT FK_F4CA81DFD69F3311 FOREIGN KEY (wish_list_id) REFERENCES wish_list (id)'); $this->addSql('ALTER TABLE wish_list_member ADD CONSTRAINT FK_F4CA81DFA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'); } @@ -43,15 +43,15 @@ final class Version20250223155752 extends AbstractMigration $this->addSql('ALTER TABLE purchase DROP FOREIGN KEY FK_6117D13BD69F3311'); $this->addSql('ALTER TABLE purchase DROP FOREIGN KEY FK_6117D13B126F525E'); $this->addSql('ALTER TABLE wish_list DROP FOREIGN KEY FK_5B8739BDA76ED395'); - $this->addSql('ALTER TABLE wish_list_item DROP FOREIGN KEY FK_9A7FA711D69F3311'); - $this->addSql('ALTER TABLE wish_list_item DROP FOREIGN KEY FK_9A7FA711126F525E'); + $this->addSql('ALTER TABLE wishlist_item DROP FOREIGN KEY FK_6424F4E8D69F3311'); + $this->addSql('ALTER TABLE wishlist_item DROP FOREIGN KEY FK_6424F4E8126F525E'); $this->addSql('ALTER TABLE wish_list_member DROP FOREIGN KEY FK_F4CA81DFD69F3311'); $this->addSql('ALTER TABLE wish_list_member DROP FOREIGN KEY FK_F4CA81DFA76ED395'); $this->addSql('DROP TABLE item'); $this->addSql('DROP TABLE purchase'); $this->addSql('DROP TABLE user'); $this->addSql('DROP TABLE wish_list'); - $this->addSql('DROP TABLE wish_list_item'); + $this->addSql('DROP TABLE wishlist_item'); $this->addSql('DROP TABLE wish_list_member'); } } diff --git a/web_app/src/Entity/WishListItem.php b/web_app/src/Entity/WishListItem.php deleted file mode 100644 index bbc25da8e3ee3950d92a06ce800bc62ad446fa33..0000000000000000000000000000000000000000 --- a/web_app/src/Entity/WishListItem.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -namespace App\Entity; - -use App\Repository\WishListItemRepository; -use Doctrine\ORM\Mapping as ORM; - -#[ORM\Entity(repositoryClass: WishListItemRepository::class)] -class WishListItem -{ - #[ORM\Id] - #[ORM\GeneratedValue] - #[ORM\Column] - private ?int $id = null; - - #[ORM\ManyToOne(targetEntity: WishList::class)] - #[ORM\JoinColumn(nullable: false)] - private ?int $wishList = null; - - #[ORM\ManyToOne(targetEntity: Item::class)] - #[ORM\JoinColumn(nullable: false)] - private ?int $item = null; - - public function getId(): ?int - { - return $this->id; - } - - public function getWishList(): ?int - { - return $this->wishList; - } - - public function setWishList(int $wishList): static - { - $this->wishList = $wishList; - - return $this; - } - - public function getItem(): ?int - { - return $this->item_id; - } - - public function setItem(int $item): static - { - $this->item = $item; - - return $this; - } -}