-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cleanup closed_day_excluded_stores foreign keys
- when the original migration was moved from project-base to the framework package, the key names were changed - see Version20231124121921 and deleted Version20230524064748 in shopsys/shopsys@1a99756
- Loading branch information
1 parent
590282c
commit 401988f
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
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,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Shopsys\MigrationBundle\Component\Doctrine\Migrations\AbstractMigration; | ||
|
||
class Version20240613235059 extends AbstractMigration | ||
{ | ||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function up(Schema $schema): void | ||
{ | ||
$dropForeignKeysQueries = $this->sql( | ||
' | ||
SELECT string_agg(\'ALTER TABLE \' || quote_ident(c.relname) || \' DROP CONSTRAINT \' || quote_ident(con.conname), \'; \') | ||
FROM pg_constraint con | ||
JOIN pg_class c ON con.conrelid = c.oid | ||
WHERE c.relname = \'closed_day_excluded_stores\' AND con.contype = \'f\';', | ||
)->fetchOne(); | ||
|
||
foreach (explode('; ', $dropForeignKeysQueries) as $dropForeignKeyQuery) { | ||
$this->sql($dropForeignKeyQuery); | ||
} | ||
|
||
$this->sql('ALTER TABLE closed_day_excluded_stores ADD CONSTRAINT FK_B4EC517608F9E8F FOREIGN KEY (closed_day_id) REFERENCES closed_days (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
$this->sql('ALTER TABLE closed_day_excluded_stores ADD CONSTRAINT FK_B4EC517B092A811 FOREIGN KEY (store_id) REFERENCES stores (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
} | ||
|
||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |