Closed KDederichs closed 1 year ago
a foundry issue still, sorry :D
😂🫢
Maybe you can leverage the global state and use invokable service to run the needed sql query to enable the extension?
Might be a bit harder though since I think that one's executed before the setup methods?
The db is reset before each test so, adding the extension will be needed on each test But if you use dama, it will be ran only once
Stories doesn't seem to work, something is blocking the Create Extension command when executed from those. (PG throwing FATAL: terminating connection due to administrator command)
$this->runCommand(
$this->application,
'doctrine:query:sql',
[
'sql' => 'CREATE EXTENSION IF NOT EXISTS postgis;',
'--connection' => $connection,
]
);
after
$this->runCommand(
$this->application,
'doctrine:database:create',
[
'--connection' => $connection,
]
);
works though
@KDederichs, could you switch to using migrations instead of schema
(zenstruck_foundry.database_resetter.orm.reset_mode: migrate
)? Then you can add this requirement to your migration's sql?
@kbond That just gives me this Symfony\Component\DependencyInjection\Exception\LogicException: Container extension "database_resetter" is not registered. in /srv/app/vendor/symfony/dependency-injection/ContainerBuilder.php:229
anything else that needs to be changed for that to work?
To clarify, do you have migrations for your project?
anything else that needs to be changed for that to work?
Sorry, I should have been more explicit, in config/packages/zenstruck_foundry.yaml
:
zenstruck_foundry:
database_resetter:
orm:
reset_mode: migrate
Here's the docs on the topic: https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#database-reset (bottom of this section)
Yeah I do have migrations for my project and I did add that config section, which then resulted in the aforementioned error. That's why I'm asking if there's something else that needs to be done :)
Edit: What scratch that, I just remembered I got that setup where it loads tests in prod mode to speed them up (either from here or the DAMA bundle), of course it doesn't load that in prod mode then... I'm dumb.
Works now
Hey again,
so after figuring out why https://github.com/zenstruck/foundry/issues/472 does what it does it's kinda a foundry issue still, sorry :D
What happens is when it's dropping the Database and recreating it it'll also reset the enabled extensions since those on a per database bases it seems.
Now here's the question: Is there a way to enable those extensions on database reset again? I saw you can run your own migrations every time but honestly, I'd love to avoid that.
If there's no convenient way would you be open if I made a PR for something like this?:
That way users could just specify if they want something some extensions enabled after.
Alternatively there'd also be the option of maybe adding something like this to the DatabaseResetter:
and then in the ORMDatabaseResetter's
dropAndResetDatabase
:Which would offer a bit more flexibility? Edit: Might be a bit harder though since I think that one's executed before the setup methods?