Doctrine make:migration unknown database type - symfony

I am trying to start using Doctrine, but I encountered a problem when I created entity through php bin/console make:entity, then I tried to make migration with php bin/console make:migration but I get this error message:
Uknown database type _int4 requested, Doctrine\DBAL\Platforms\PostgreSqlPlatform may not support it.
I am using postgres 9.4 and doctrine 2.6

In symfony config/packages/doctrine.yaml you can just map the type to data type that you want.
doctrine:
dbal:
mapping_types:
_int4: string

Related

doctrine schema update wants to drop migration_verions table symfony

When I try to run doctrine:schema:update --complete --dump-sql on a Symfony dockerized application, the output is showing below:
ALTER TABLE offer DROP FOREIGN KEY FK_29D6873EC1EA42F3;
DROP TABLE doctrine_migration_versions;
I expect that the table migration_versions should not be deleted!
I am using mariadb:10.9.4 mysql
Add schema_filter to your doctrine.yaml
doctrine:
dbal:
url: '%env(DATABASE_URL)%'
schema_filter: "~^(doctrine_migration_versions$)~"
And try to launch the command without the --complete option
You can read better explanation on this on one of my old answer :
Symfony 5 - Doctrine with schema_filter not working

Cannot generate Entity from existing Oracle DB

Following symfony's documentation to create entities from exiting database,I get an error when running the first command:
php bin/console doctrine:mapping:import --force AppBundle yml
The error is:
[Symfony\Component\Debug\Exception\ContextErrorException]
Warning: file_put_contents(C:\WebApp\src\AppBundle/Resources/config/doctrine/"user".orm.yml): failed to open stream: Invalid argument
How can I fix it?
Looks like User is a reserved word within Oracle databases, so when I created the table, Oracle created a table named "user" with double quotes. So when trying to generate the entity, doctrine cannot find the table user and found an invalid argument "user" with double quotes in it. The way I solved the problem is by using another name other than user.
Hope this helps someone on the future.
php bin/console doctrine:mapping:import --force AppBundle yml
change to
php bin/console doctrine:mapping:import AppBundle yml --force
more details:
The doctrine:mapping:import command imports mapping information
from an existing database:
php app/console doctrine:mapping:import "MyCustomBundle" xml
You can also optionally specify which entity manager to import from with the
--em option:
php app/console doctrine:mapping:import "MyCustomBundle" xml --em=default
If you don't want to map every entity that can be found in the database, use the
--filter option. It will try to match the targeted mapped entity with the
provided pattern string.
php app/console doctrine:mapping:import "MyCustomBundle" xml --filter=MyMatchedEntity
Use the --force option, if you want to override existing mapping files:
php app/console doctrine:mapping:import "MyCustomBundle" xml --force

Unknown Entity namespace alias 'PirastruFormBuilderBundle'

It has been now 2 days that i'm looking for a solution to this error but in vain :
Unknown Entity namespace alias 'PirastruFormBuilderBundle'
in fact i installed the sonata form builder with sonata page bundle using the composer but i don't know why i'm getting this error.
i don't know which part of codes should i copie here so please don't hesitate to ask me for it
sonata_form_builder:
resource: '#PirastruFormBuilderBundle/Controller/FormBuilderController.php'
type: annotation
Thanks !!
EDIT
when i run this : php app/console config:dump-reference
PirastruFormBuilderBundle | pirastru_form_builder |
and when i run this : php app/console doctrine:mapping:info i got
[Exception] You do not have any mapped Doctrine ORM entities
according to the current configuration. If you have entities or
mapping files you should check your mapping configuration for errors.
well i managed to solve the problem ! i had just to add a getManager in my FormBuilderBlockService
This problem can be caused by some (mis)configurations :
Bundle
app/console config:dump-reference
This command let you know if the Bundle is referenced.
Mapping
app/console doctrine:mapping:info
This command let you know if the Bundle is mapped.
It's typically a mapping issue :
Unknown Entity namespace alias '***Bundle'
The better solution is to add auto_mapping to true in config.yml, like this :
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
But it can be solved by others way, you can have a look to : Symfony : What is the meaning of auto_mapping and auto_generate_proxy_classes
Best regards,

Create Entities from existing DB

Newest Version Symfony2 and using MAMP on a MAC. Following command:
php app/console doctrine:mapping:convert yml ./src/Acme/DemoBundle/Resources/config/doctrine/metadata/orm --from-database --force
My Error:
[Doctrine\DBAL\DBALException]
Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.
Don't have any idea. What is wrong?
A connection to my db is working. Because I tried to create a table and the output was that the table exist.
Sorry, I missed it and here is the solution of my question.
http://symfony.com/doc/current/cookbook/doctrine/dbal.html#registering-custom-mapping-types-in-the-schematool

Symfony2 + doctrine2: Switch to metadata driver "yml"

a short question: How to switch to the another metadata driver than annotation. How to set the metadata driver "yml" in the config.yml?
I`ve searched google and the symfony2 docu, but didnt find anything :(
thanks
You should be able to do that with the doctrine:mapping:convert command
php app/console doctrine:mapping:convert --force yml ./src/
Double check all the options available before you run the command, though
php app/console help doctrine:mapping:convert
I realize this is an older question but you can explicitly require that doctrine use the yml driver for meta data like this:
doctrine:
orm:
entity_managers:
mappings:
MyBundleName:
type: yml
dir: path/to/ymlmetadata
Be aware that if you use this configuration style then you have to put the "defaults" config node under entity_managers instead of its usual location.

Resources