diff --git a/.vscode/extensions.json b/.vscode/extensions.json index bdef820..1612a87 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,3 +1,3 @@ { - "recommendations": ["svelte.svelte-vscode"] + "recommendations": [] } diff --git a/Vagrantfile b/Vagrantfile index 05a8fd6..d52d88e 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -21,6 +21,7 @@ Vagrant.configure('2') do |config| if File.exist?('.vagrant.config.yml.dist') settingsDist = YAML.load(File.read('.vagrant.config.yml.dist')) end + # TODO: Handle empty file "in `merge': no implicit conversion of nil into Hash (TypeError)" if File.exist?('.vagrant.config.yml') settingsCustom = YAML.load(File.read('.vagrant.config.yml')) end diff --git a/api/migrations/Version20240502173703.php b/api/migrations/Version20240502173703.php new file mode 100644 index 0000000..05f64af --- /dev/null +++ b/api/migrations/Version20240502173703.php @@ -0,0 +1,41 @@ +addSql('ALTER TABLE card DROP FOREIGN KEY FK_161498D3BC3F045D'); + $this->addSql('ALTER TABLE card ADD CONSTRAINT FK_161498D3BC3F045D FOREIGN KEY (user_login_id) REFERENCES user (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE invitee DROP FOREIGN KEY FK_F7AADF3D759A837E'); + $this->addSql('ALTER TABLE invitee DROP FOREIGN KEY FK_F7AADF3D4ACC9A20'); + $this->addSql('ALTER TABLE invitee ADD CONSTRAINT FK_F7AADF3D759A837E FOREIGN KEY (table_to_sit_id) REFERENCES `table` (id) ON DELETE SET NULL'); + $this->addSql('ALTER TABLE invitee ADD CONSTRAINT FK_F7AADF3D4ACC9A20 FOREIGN KEY (card_id) REFERENCES card (id) ON DELETE SET NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE invitee DROP FOREIGN KEY FK_F7AADF3D759A837E'); + $this->addSql('ALTER TABLE invitee DROP FOREIGN KEY FK_F7AADF3D4ACC9A20'); + $this->addSql('ALTER TABLE invitee ADD CONSTRAINT FK_F7AADF3D759A837E FOREIGN KEY (table_to_sit_id) REFERENCES `table` (id)'); + $this->addSql('ALTER TABLE invitee ADD CONSTRAINT FK_F7AADF3D4ACC9A20 FOREIGN KEY (card_id) REFERENCES card (id)'); + $this->addSql('ALTER TABLE card DROP FOREIGN KEY FK_161498D3BC3F045D'); + $this->addSql('ALTER TABLE card ADD CONSTRAINT FK_161498D3BC3F045D FOREIGN KEY (user_login_id) REFERENCES user (id)'); + } +} diff --git a/api/src/Entity/Card.php b/api/src/Entity/Card.php index cca4d0c..ef5b877 100644 --- a/api/src/Entity/Card.php +++ b/api/src/Entity/Card.php @@ -20,8 +20,8 @@ class Card #[ORM\OneToMany(mappedBy: 'card', targetEntity: Invitee::class)] private Collection $invitees; - #[ORM\OneToOne(inversedBy: 'card', cascade: ['persist', 'remove'])] - #[ORM\JoinColumn(nullable: true)] + #[ORM\OneToOne(inversedBy: 'card', cascade: ['persist'])] + #[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')] private ?User $userLogin = null; public function __construct() diff --git a/api/src/Entity/Invitee.php b/api/src/Entity/Invitee.php index 5493efe..1a6f2b1 100644 --- a/api/src/Entity/Invitee.php +++ b/api/src/Entity/Invitee.php @@ -35,10 +35,11 @@ class Invitee private ?string $allergies = null; #[ORM\ManyToOne(inversedBy: 'invitees')] - #[ORM\JoinColumn(name: 'table_to_sit_id')] + #[ORM\JoinColumn(name: 'table_to_sit_id', onDelete: 'SET NULL')] private ?Table $table = null; #[ORM\ManyToOne(inversedBy: 'invitees')] + #[ORM\JoinColumn(onDelete: 'SET NULL')] private ?Card $card = null; public function __construct(string $firstname, string $lastname) diff --git a/api/src/Entity/User.php b/api/src/Entity/User.php index 8b11348..d2210a7 100644 --- a/api/src/Entity/User.php +++ b/api/src/Entity/User.php @@ -31,7 +31,7 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface #[ORM\Column(nullable: false)] private string $password; - #[ORM\OneToOne(mappedBy: 'userLogin', cascade: ['persist', 'remove'])] + #[ORM\OneToOne(mappedBy: 'userLogin', cascade: ['persist'])] private ?Card $card = null; public function __construct(string $username, UserPasswordHasherInterface $passwordHasher, string $password)