I'm using Symfony3 with Doctrine ORM 2 Annotations.
I generated entities from an existing MySQL database. I also wrote all the relations.
Before updating the Database I schema I used the command
php app/console doctrine:schema:update --dump-sql
I have all the primary keys with INT unsigned so the related foreign keys too.
Now I noted that Doctrine ORM doesn't allow to use the
options={"unsigned":true}
in
#JoinColumn
So how can I solve this issue ?
Do I have to let Doctrine rewrite all the keys ?
I dont' know what way to follow to avoid damage to the DB and data.
Related
I am working on a Django project with a database in PostgreSQL. During my schema design, I have noticed that one table is referencing many foreign keys from other tables. Just curious that how many foreign keys can be referenced from/to one table? I also searched and found that the SQL server 2014 can reference up to253 foreign keys.
I don't think there is a hard limit. I just created a table with 10001 foreign key constraints.
Of course that doesn't mean that it is sane to define that many foreign keys, and performance will suffer considerably.
I have an existing database made and currently used by a Drupal project. I need to write an app using Doctrine and this database.
I'd like to use the Doctrine ORM, but I cannot change the Database schema and it is kind of unintuitive (Drupal has kind of one table per data to store...).
Is there a way to tell Doctrine the SQL to store and read every attribute of my entities ?
Otherwise I will use Doctrine DBAL, but the simplicity of the entities interests me a lot.
I'm trying to setup a new server with foreign tables (using postgres_fdw) that weren't foreign tables previously, and I have some OneToOneFields pointing to these tables. This doesn't work out of the box - OneToOneFields use foreign keys, and postgres_fdw does not support foreign keys for foreign tables.
The foreign tables are in a read-only database on the same server.
Is there an easy way to get this working?
After a little more research, I think the answer is 'don't do that'. Handling foreign keys for foreign tables isn't implemented, and any solution that tried to bridge that gap would have serious performance and/or consistency issues.
pglogical looks like a better solution - instead of pulling the data in through postgres_fdw, replicate the tables into the new database so they're local. There are other projects for replicating just specific tables, but pglogical is included with PostgreSQL 10.
Django autogenerated above tables with syncdb, but I can't understand what are those tables for.
Sorry for silly question, but I'm just started with groups and permissions.
Django's scheme for automatically generating table names is explained here. Basically, it uses the pattern app_model. In the case of ManyToManyFields—which are implemented by creating a new table to hold the relationship—this becomes app_model1_model2s.
So:
auth_permission is the table that represents the auth.Permission model.
auth_group_permissions is the table that represents the ManyToMany relationship between auth.Group and auth.Permission.
users_user_permissions is the table that represents the ManyToManyField between users.User and auth.Permission. (I assume this is coming from an app you're using? Django's contrib.auth version should be auth_user_user_permissions.)
See the documentation for how these tables are actually used.
I have this "new" table in my database: event_comment_oauth_service which is an many-to-many relation table, between event_comment, and oauth_service.
I ran these commands to update my symfony2 entities:
php app/console doctrine:mapping:import testSiteBundle yml
php app/console doctrine:generate:entities test --path=src/
all tables are generated OK, but not the new one.
How can I generate the new table?
Doctrine2 does not act the same way as Doctrine1 for the many to many tables. If you want to have an entity, you have to create it and add one to many/many to one associations by yourself.