Skip to content
This repository has been archived by the owner on Aug 5, 2019. It is now read-only.

Don't add CREATE SCHEMA public commands to down migrations #551

Merged
merged 7 commits into from
May 29, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version182.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE checklist_information DROP CONSTRAINT FK_3FB5A813B16D08A7');
$this->addSql('DROP TABLE checklist');
$this->addSql('DROP TABLE checklist_information');
Expand Down
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version183.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE checklist DROP CONSTRAINT FK_5C696D2F65CF370E');
$this->addSql('DROP INDEX IDX_5C696D2F65CF370E');
$this->addSql('ALTER TABLE checklist DROP last_modified_by');
Expand Down
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version186.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE checklist DROP satisfied_with_pa_expenses');
}
}
1 change: 0 additions & 1 deletion app/DoctrineMigrations/Version193.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE checklist DROP satisfied_with_health_and_lifestyle');
}
}
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version196.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE checklist RENAME COLUMN future_significant_decisions TO future_significant_financial_decisions');
}
}
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version198.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP TABLE prof_deputy_other_cost');
$this->addSql('CREATE INDEX created_on_idx ON report_submission (created_on)');

Expand Down
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version201.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('DROP TABLE prof_deputy_interim_cost');
}
}
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version204.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE checklist DROP deputy_charge_allowed_by_court');
$this->addSql('ALTER TABLE casrec ADD registration_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
$this->addSql('ALTER TABLE casrec ADD last_logged_in TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
Expand Down
1 change: 0 additions & 1 deletion app/DoctrineMigrations/Version205.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE report DROP prof_dc_estimate_hc');
$this->addSql('DROP TABLE prof_deputy_estimate_cost');
}
Expand Down
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version206.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE report DROP prof_dc_estimate_more_info');
$this->addSql('ALTER TABLE report DROP prof_dc_estimate_more_info_details');
}
Expand Down
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version207.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE checklist DROP payments_match_cost_certificate');
$this->addSql('ALTER TABLE checklist DROP prof_costs_reasonable_and_proportionate');
$this->addSql('ALTER TABLE checklist DROP has_deputy_overcharged_from_previous_estimates');
Expand Down
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version208.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE report ADD prof_dc_hc_agreed BOOLEAN DEFAULT NULL');
}
}
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version210.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE checklist DROP next_billing_estimate_satisfactory');
}
}
1 change: 0 additions & 1 deletion app/DoctrineMigrations/Version211.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public function down(Schema $schema)
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE report ADD prof_dc_hc_fixed BOOLEAN DEFAULT NULL');
$this->addSql('ALTER TABLE report ADD prof_dc_hc_assessed BOOLEAN DEFAULT NULL');
$this->addSql('ALTER TABLE report DROP prof_dc_how_charged');
Expand Down
2 changes: 0 additions & 2 deletions app/DoctrineMigrations/Version212.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('CREATE SCHEMA public');
$this->addSql('ALTER TABLE document ADD deleted_at TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL');
}
}
5 changes: 5 additions & 0 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ services:
- { name: doctrine.event_listener, event: prePersist, method: prePersist }
- { name: doctrine.event_listener, event: preRemove, method: preRemove }

fixDefaultSchemaListener:
class: AppBundle\EventListener\FixDefaultSchemaListener
tags:
- { name: doctrine.event_listener, event: postGenerateSchema, method: postGenerateSchema }

opg_digideps.casrec_verification_service:
class: AppBundle\Service\CasrecVerificationService
arguments: [ "@em" ]
Expand Down
25 changes: 25 additions & 0 deletions src/AppBundle/EventListener/FixDefaultSchemaListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace AppBundle\EventListener;

use Doctrine\Common\EventSubscriber;
use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs;

class FixDefaultSchemaListener implements EventSubscriber
{
public function getSubscribedEvents()
{
return array(
'postGenerateSchema',
);
}

public function postGenerateSchema(GenerateSchemaEventArgs $Args)
{
$Schema = $Args->getSchema();

if (! $Schema->hasNamespace('public')) {
$Schema->createNamespace('public');
}
}
}