Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17992
| From | Marek S <precz@spamowi.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Symfony 4 - how to get to the documentation of setting up event subscribers? |
| Date | 2019-06-14 20:30 +0200 |
| Organization | ATMAN - ATM S.A. |
| Message-ID | <qe0p50$bqt$1@node2.news.atman.pl> (permalink) |
| References | <qdrf5n$j7j$1@node2.news.atman.pl> <gmev4hFi9soU1@mid.individual.net> <qdu78n$37q$1@node2.news.atman.pl> <gmhe05F45bsU1@mid.individual.net> |
W dniu 2019-06-14 o 13:16, Arno Welzel pisze:
>
> Ok - maybe the other way: why do you need to handle migration events?
> What exactly is the your case which can not be solved using the
> migration itself?
Yeah, you are right. Making the question precise, instead of general,
will allow to get answer easier.
Below I attached automatically created migration (first one).
Assumptions to this:
1. The database is a PostgreSQL.
2. Database contains 3 namespaces: public, external, ext.
3. Only public namespace is dedicated to Symfony.
4. Other namespaces contain third party objects, which will be used by
Symfony from time to time. For now, let's keep them not touched.
5. The migrations are created via console (doctrine:migrations:migrate)
Each of exported migrations contain bugs:
$this->addSql('CREATE SCHEMA public');
$this->addSql('CREATE SCHEMA exclude');
$this->addSql('CREATE SCHEMA exc');
Executing such a code will result exception saying that existing schema
can not be created.
My intention is do not fix migration files manually. Instead of this: do
something in events which allows to ignore creating schema(s). Also I
would like to avoid patching bugged (for years) Doctrine's code.
Especially when I'm new in this environment.
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20190609003956 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->abortIf($this->connection->getDatabasePlatform()->getName() !==
'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('CREATE TABLE task (task_id BIGSERIAL NOT NULL,
title VARCHAR(255) NOT NULL, status BOOLEAN DEFAULT \'false\' NOT NULL,
PRIMARY KEY(task_id))');
}
public function down(Schema $schema): void {
// 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('CREATE SCHEMA exclude');
$this->addSql('CREATE SCHEMA exc');
$this->addSql('DROP TABLE task');
}
}
--
Pozdrawiam,
Marek
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Symfony 4 - how to get to the documentation of setting up event subscribers? Marek S <precz@spamowi.com> - 2019-06-12 20:09 +0200
Re: Symfony 4 - how to get to the documentation of setting up event subscribers? Arno Welzel <usenet@arnowelzel.de> - 2019-06-13 14:50 +0200
Re: Symfony 4 - how to get to the documentation of setting up event subscribers? Marek S <precz@spamowi.com> - 2019-06-13 21:13 +0200
Re: Symfony 4 - how to get to the documentation of setting up event subscribers? Arno Welzel <usenet@arnowelzel.de> - 2019-06-14 13:16 +0200
Re: Symfony 4 - how to get to the documentation of setting up event subscribers? Marek S <precz@spamowi.com> - 2019-06-14 20:30 +0200
Re: Symfony 4 - how to get to the documentation of setting up event subscribers? Arno Welzel <usenet@arnowelzel.de> - 2019-06-15 18:00 +0200
Re: Symfony 4 - how to get to the documentation of setting up event subscribers? Marek S <precz@spamowi.com> - 2019-06-15 22:57 +0200
Re: Symfony 4 - how to get to the documentation of setting up event subscribers? Arno Welzel <usenet@arnowelzel.de> - 2019-06-16 09:31 +0200
Re: Symfony 4 - how to get to the documentation of setting up event subscribers? Marek S <precz@spamowi.com> - 2019-06-16 14:29 +0200
Re: Symfony 4 - how to get to the documentation of setting up event subscribers? Arno Welzel <usenet@arnowelzel.de> - 2019-06-17 00:18 +0200
csiph-web