Skip to content
Snippets Groups Projects
Commit 636c2ff8 authored by PEREZ-RAMIREZ Julian's avatar PEREZ-RAMIREZ Julian
Browse files

creating just one initial migrate version

parent 7da5f83a
No related branches found
No related tags found
No related merge requests found
......@@ -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
<?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');
}
}
......@@ -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');
}
}
<?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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment