Hi, I have a problem with relationships in the database. I think the
code will present the brightest situations.
SCHEMA.YML:
----------------------------------------------------
Activitie:
connection: doctrine
tableName: activitie
columns:
id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: true
a_user_id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: false
relations:
Users:
local: a_user_id
foreign: id
onDelete: cascade
CommentsActivities:
class: CommentsActivitie
local: id
foreign: ca_activitie_id
type: many
CommentsActivitie:
connection: doctrine
tableName: comments_activitie
columns:
id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: false
ca_activitie_id:
type: integer(4)
fixed: false
unsigned: false
primary: true
autoincrement: false
relations:
Activitie:
local: ca_activitie_id
foreign: id
onDelete: cascade
User:
connection: doctrine
tableName: user
relations:
Activities:
class: Activity
local: id
foreign: a_user_id
type: many
----------------------------------------------------
SCHEMA.SQL
----------------------------------------------------
ALTER TABLE activitie ADD CONSTRAINT
activitie_id_comments_activitie_ca_activitie_id FOREIGN KEY (id)
REFERENCES comments_activitie(ca_activitie_id);
ALTER TABLE activitie ADD CONSTRAINT activitie_a_user_id_user_id
FOREIGN KEY (a_user_id) REFERENCES user(id);
----------------------------------------------------
When i use insert-sql function i got error (example)
----------------------------------------------------
>> doctrine creating tables
SQLSTATE[HY000]: General error: 1005 Can't create table
'activityjunkie.#sql-ad8_1b' (errno: 121). Failing Query: "ALTER TABLE
activitie ADD CONSTRAINT activitie_id_member_pocket_mp_activitie_id
FOREIGN KEY (id) REFERENCES member_pocket(mp_activitie_id)". Failing
Query: ALTER TABLE activitie ADD CONSTRAINT
activitie_id_member_pocket_mp_activitie_id FOREIGN KEY (id) REFERENCES
member_pocket(mp_activitie_id)
------------------------------------------------------
If we look at schema.sql we can see that delete:cascade doesnt appear,
and we have wrong foreign key in activitie. Can you explain me what i
did wrong?
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en