Is there any way, when using Doctrine, to create a table like another? I know in MySQL there is a function to do so:
CREATE TABLE user2 LIKE user;
and tables user and user2 will be identical. Can this be done in Doctrine?
I imagine that what you are looking for is to define (let's use your example) on the schema level that user2 inherits from user when your model is generated. You can do this by using doctrine's concrete inheritance which is described in the documentation.
So, in your schema.yml:
User:
columns:
name: string
User2:
inheritance:
extends: User
type: concrete
columns:
something: int
This way user2 will be a separate table and contain the same columns ("name") as previously defined in user. I'm not sure why you would like two identical tables, but that is most definitely possible using the above method.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With