-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: Allow to delete the organizations
- Loading branch information
1 parent
da08569
commit 0d85a97
Showing
13 changed files
with
399 additions
and
7 deletions.
There are no files selected for viewing
137 changes: 137 additions & 0 deletions
137
migrations/Version20230511091245SetDeleteCascadeOnOrgaConstraints.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?php | ||
|
||
// This file is part of Bileto. | ||
// Copyright 2022-2023 Probesys | ||
// SPDX-License-Identifier: AGPL-3.0-or-later | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20230511091245SetDeleteCascadeOnOrgaConstraints extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Set DELETE CASCADE on organization foreign keys in authorizations and ticket tables.'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$dbPlatform = $this->connection->getDatabasePlatform()->getName(); | ||
if ($dbPlatform === 'postgresql') { | ||
$this->addSql('ALTER TABLE authorizations DROP CONSTRAINT FK_2BC15D6932C8A3DE'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE authorizations | ||
ADD CONSTRAINT FK_2BC15D6932C8A3DE | ||
FOREIGN KEY (organization_id) | ||
REFERENCES organization (id) | ||
ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE | ||
SQL); | ||
|
||
$this->addSql('ALTER TABLE ticket DROP CONSTRAINT FK_97A0ADA332C8A3DE'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE ticket | ||
ADD CONSTRAINT FK_97A0ADA332C8A3DE | ||
FOREIGN KEY (organization_id) | ||
REFERENCES organization (id) | ||
ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE | ||
SQL); | ||
|
||
$this->addSql('ALTER TABLE message DROP CONSTRAINT FK_B6BD307F700047D2'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE message | ||
ADD CONSTRAINT FK_B6BD307F700047D2 | ||
FOREIGN KEY (ticket_id) | ||
REFERENCES ticket (id) | ||
ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE | ||
SQL); | ||
} elseif ($dbPlatform === 'mysql') { | ||
$this->addSql('ALTER TABLE authorizations DROP FOREIGN KEY FK_2BC15D6932C8A3DE'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE authorizations | ||
ADD CONSTRAINT FK_2BC15D6932C8A3DE | ||
FOREIGN KEY (organization_id) | ||
REFERENCES organization (id) | ||
ON DELETE CASCADE | ||
SQL); | ||
|
||
$this->addSql('ALTER TABLE message DROP FOREIGN KEY FK_B6BD307F700047D2'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE message | ||
ADD CONSTRAINT FK_B6BD307F700047D2 | ||
FOREIGN KEY (ticket_id) | ||
REFERENCES ticket (id) | ||
ON DELETE CASCADE | ||
SQL); | ||
|
||
$this->addSql('ALTER TABLE ticket DROP FOREIGN KEY FK_97A0ADA332C8A3DE'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE ticket | ||
ADD CONSTRAINT FK_97A0ADA332C8A3DE | ||
FOREIGN KEY (organization_id) | ||
REFERENCES organization (id) | ||
ON DELETE CASCADE | ||
SQL); | ||
} | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$dbPlatform = $this->connection->getDatabasePlatform()->getName(); | ||
if ($dbPlatform === 'postgresql') { | ||
$this->addSql('ALTER TABLE ticket DROP CONSTRAINT fk_97a0ada332c8a3de'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE ticket | ||
ADD CONSTRAINT fk_97a0ada332c8a3de | ||
FOREIGN KEY (organization_id) | ||
REFERENCES organization (id) | ||
NOT DEFERRABLE INITIALLY IMMEDIATE | ||
SQL); | ||
|
||
$this->addSql('ALTER TABLE "authorizations" DROP CONSTRAINT fk_2bc15d6932c8a3de'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE "authorizations" | ||
ADD CONSTRAINT fk_2bc15d6932c8a3de | ||
FOREIGN KEY (organization_id) | ||
REFERENCES organization (id) | ||
NOT DEFERRABLE INITIALLY IMMEDIATE | ||
SQL); | ||
|
||
$this->addSql('ALTER TABLE message DROP CONSTRAINT fk_b6bd307f700047d2'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE message | ||
ADD CONSTRAINT fk_b6bd307f700047d2 | ||
FOREIGN KEY (ticket_id) | ||
REFERENCES ticket (id) | ||
NOT DEFERRABLE INITIALLY IMMEDIATE | ||
SQL); | ||
} elseif ($dbPlatform === 'mysql') { | ||
$this->addSql('ALTER TABLE `authorizations` DROP FOREIGN KEY FK_2BC15D6932C8A3DE'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE `authorizations` | ||
ADD CONSTRAINT FK_2BC15D6932C8A3DE | ||
FOREIGN KEY (organization_id) | ||
REFERENCES organization (id) | ||
SQL); | ||
|
||
$this->addSql('ALTER TABLE message DROP FOREIGN KEY FK_B6BD307F700047D2'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE message | ||
ADD CONSTRAINT FK_B6BD307F700047D2 | ||
FOREIGN KEY (ticket_id) | ||
REFERENCES ticket (id) | ||
SQL); | ||
|
||
$this->addSql('ALTER TABLE ticket DROP FOREIGN KEY FK_97A0ADA332C8A3DE'); | ||
$this->addSql(<<<SQL | ||
ALTER TABLE ticket | ||
ADD CONSTRAINT FK_97A0ADA332C8A3DE | ||
FOREIGN KEY (organization_id) | ||
REFERENCES organization (id) | ||
SQL); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{# | ||
# This file is part of Bileto. | ||
# Copyright 2022-2023 Probesys | ||
# SPDX-License-Identifier: AGPL-3.0-or-later | ||
#} | ||
|
||
{% extends 'base.html.twig' %} | ||
|
||
{% set currentPage = 'settings' %} | ||
|
||
{% block title %}{{ 'organizations.deletion.title' | trans }}{% endblock %} | ||
|
||
{% block sidebar %} | ||
{{ include('settings/_sidebar.html.twig', { current: 'organizations' }, with_context = false) }} | ||
{% endblock %} | ||
|
||
{% block body %} | ||
<main class="layout__body flow"> | ||
<div class="layout__breadcrumb"> | ||
<a href="{{ path('organizations') }}">{{ 'organizations.index.title' | trans }}</a> | ||
<h1>{{ 'organizations.deletion.title' | trans }}</h1> | ||
</div> | ||
|
||
<form action="{{ path('delete organization', { uid: organization.uid }) }}" method="post" class="wrapper-small flow"> | ||
<input type="hidden" name="_csrf_token" value="{{ csrf_token('delete organization') }}"> | ||
|
||
{{ include('alerts/_alert.html.twig', { | ||
type: 'warning', | ||
title: 'organizations.deletion.caution' | trans, | ||
message: 'organizations.deletion.going_delete' | trans({ organization: organization.name }), | ||
raw: true, | ||
}, with_context = false) }} | ||
|
||
{% if error %} | ||
{{ include('alerts/_error.html.twig', { message: error }, with_context = false) }} | ||
{% endif %} | ||
|
||
<div class="form__actions"> | ||
<button | ||
id="form-delete-organization-submit" | ||
class="button--primary" | ||
type="submit" | ||
data-turbo-confirm="{{ 'organizations.deletion.confirm' | trans }}" | ||
> | ||
{{ 'organizations.deletion.submit' | trans }} | ||
</button> | ||
</div> | ||
</form> | ||
</main> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.