Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate schema by annotated entities without DB connection #62

Open
scapital opened this issue Mar 16, 2023 · 2 comments
Open

Generate schema by annotated entities without DB connection #62

scapital opened this issue Mar 16, 2023 · 2 comments

Comments

@scapital
Copy link

Is it possible generate schema only use info form entity, not to load actual schema from DB?

Problem:
I use "cycle/orm and co" among with symfony. Schema is compiled while cache:clear, cache:clear is run while docker build.
As there is no db connection, this error occur.

[PDOException (7)]
SQLSTATE[08006] [7] could not translate host name "db" to address: Name does not resolve
Exception trace:
at /srv/app/vendor/cycle/database/src/Driver/Driver.php:637
PDO->__construct() at /srv/app/vendor/cycle/database/src/Driver/Driver.php:637
Cycle\Database\Driver\Driver->createPDO() at /srv/app/vendor/cycle/database/src/Driver/Postgres/PostgresDriver.php:213
Cycle\Database\Driver\Postgres\PostgresDriver->createPDO() at /srv/app/vendor/cycle/database/src/Driver/Driver.php:200
Cycle\Database\Driver\Driver->connect() at /srv/app/vendor/cycle/database/src/Driver/Driver.php:653
Cycle\Database\Driver\Driver->getPDO() at /srv/app/vendor/cycle/database/src/Driver/Driver.php:487
Cycle\Database\Driver\Driver->prepare() at /srv/app/vendor/cycle/database/src/Driver/Driver.php:443
Cycle\Database\Driver\Driver->statement() at /srv/app/vendor/cycle/database/src/Driver/Driver.php:457
Cycle\Database\Driver\Driver->statement() at /srv/app/vendor/cycle/database/src/Driver/Driver.php:253
Cycle\Database\Driver\Driver->query() at /srv/app/vendor/cycle/database/src/Driver/Postgres/PostgresHandler.php:71
Cycle\Database\Driver\Postgres\PostgresHandler->hasTable() at /srv/app/vendor/cycle/database/src/Schema/AbstractTable.php:99
Cycle\Database\Schema\AbstractTable->__construct() at /srv/app/vendor/cycle/database/src/Driver/Postgres/PostgresHandler.php:31
Cycle\Database\Driver\Postgres\PostgresHandler->getSchema() at /srv/app/vendor/cycle/database/src/Table.php:88
Cycle\Database\Table->getSchema() at /srv/app/vendor/cycle/schema-builder/src/Registry.php:161
Cycle\Schema\Registry->linkTable() at /srv/app/vendor/cycle/annotated/src/Entities.php:80
Cycle\Annotated\Entities->run() at /srv/app/vendor/cycle/schema-builder/src/Compiler.php:57
Cycle\Schema\Compiler->compile() at /srv/app/package/CycleORMBundle/src/Service/SchemaCompiler.php:26

As a workaround, I do cache:clear at startup time.
But it loads DB, every kubernetes pod get schema from DB at the same time.

@roxblnfk
Copy link
Member

Looks like a good feature request.
We'll discuss it. Btw I recommend to store ORM schema as a PHP file in git.

@scapital
Copy link
Author

Btw I recommend to store ORM schema as a PHP file in git.

Yes, I though about it. Trigger re-generate schema just after migration:(up|down) is finished.
For small-size team it will work, but for mid+, a lot of git conflict while merge can be a really annoying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

3 participants