[symfony-users] Re: sf1.1 and doctrine - trouble with generated sql

2008-11-26 Thread Necho

Hello!

I have the same problem! When i start the command line :
symfony doctrine:build-all, I have an error :

sqlstate 42000 Syntax error or access violation: 1072 Key column
'envdomaine_id doesn't exist in table. Failing query.

My schema.yml :

Envdomaine:
  tableName:envdomaine
  columns:
id:
  type: integer(8)
  notnull:  true
  autoincrement:true
  primary:  true
DesignationDomaine:
  type: string(40)
Remarque:
  type: string(2147483647)
created_at:
  type: timestamp
updated_at:
  type: timestamp
EnrARCHIVE:
  type: boolean
  notnull:  true
  relations:
Envpersonnel:
  local:id
  foreign:  Domaine_id
Envservice:
  local:id
  foreign:  Domaine_id
Envsite:
  local:id
  foreign:  Domaine_id
  options:
type: INNODB

Envpersonnel:
  tableName:envpersonnel
  columns:
id:
  type: integer(8)
  notnull:  true
  autoincrement:true
  primary:  true
NumeroPersonnel:
  type: string(25)
InitialesPersonnel:
  type: string(6)
NomPersonnel:
  type: string(40)
PrenomPersonnel:
  type: string(30)
Domaine_id:
  type: integer(8)
Service_id:
  type: integer(8)
Site_id:
  type: integer(8)
  relations:
Envdomaine:
Envservice:
Envsite:
  options:
type: INNODB

Envservice:
  tableName:envservice
  columns:
id:
  type: integer(8)
  notnull:  true
  autoincrement:true
  primary:  true
CodeService:
  type: string(40)
DesignationService:
  type: string(80)
Domaine_id:
  type: integer(8)
  relations:
Envdomaine:
Envpersonnel:
  local:id
  foreign:  Service_id
  options:
type: INNODB

Envsite:
  tableName:envsite
  columns:
id:
  type: integer(8)
  notnull:  true
  autoincrement:true
  primary:  true
DesignationSite:
  type: string(80)
Domaine_id:
  type: integer(8)
  relations:
Envdomaine:
Envpersonnel:
  local:id
  foreign:  Site_id
  options:
type: INNODB

Help me please !
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---



[symfony-users] Re: sf1.1 and doctrine - trouble with generated sql

2008-10-30 Thread Jonathan Wage
User.id and Rating.user_id must be the same type and length in order for a
foreign key to be defined between the two.

- Jon

On Thu, Oct 30, 2008 at 5:41 PM, Tobias Daur <[EMAIL PROTECTED]> wrote:

>
> Hi together,
>
> I'm not shure how to solve problems, i get, while inserting the
> generated sql.
> I'm using sf1.1 with the sfDoctrinePlugin.
>
> Snippet of my schema.yml with a 1:n relation:
> -
> User:
>  actAs:
>Timestampable:
>  columns:
>first_name: string(255)
>last_name: string(255)
>nick: string(255)
>password: string(255)
>street: string(255)
>postcode: string(5)
>city: string(255)
> Rating:
>  columns:
>created_at: timestamp
>user_id: integer(4)
>  relations:
>Users:
>  class: User
>  foreignAlias: Ratings
> -
>
> If i do now a
> symfony cc
> symfony doctrine:build-model
> symfony doctrine:build-sql backend
> symfony doctrine:insert-sql backend
>
> i get an error:
> -
>  SQLSTATE[42000]: Syntax error or access violation: 1072 Key column
> 'user_id' doesn't exist in table. Failing Query: CREATE TABLE rating (id
> BIGINT AUTO_INCREMENT, created_at DATETIME, INDEX user_id_idx (user_id),
> PRIMARY KEY(id)) ENGINE = INNODB
> -
>
> There is no "user_id"-field in the table "rating" (wich i thought
> doctrine would add by itself), and it is impossible to produce a Index
> on a not existing field.
>
> So, i add the field to the schema:
>
> -
> User:
>  actAs:
>Timestampable:
>  columns:
>first_name: string(255)
>last_name: string(255)
>nick: string(255)
>password: string(255)
>street: string(255)
>postcode: string(5)
>city: string(255)
> Rating:
>  columns:
>created_at: timestamp
>user_id: integer(4)
>  relations:
>Users:
>  class: User
>  foreignAlias: Ratings
> -
>
> Now i - get an error:
> -
> SQLSTATE[HY000]: General error: 1005 Can't create table
> './fragjupp/#sql-bb2_e.frm' (errno: 150). Failing Query: ALTER TABLE
> rating ADD FOREIGN KEY (user_id) REFERENCES user(id)
> -
>
> Yes, that's right, the field "user_id" in the sql-query was already
> added:
> -
> CREATE TABLE rating (id BIGINT AUTO_INCREMENT, created_at DATETIME,
> user_id INT, INDEX user_id_idx (user_id), PRIMARY KEY(id)) ENGINE =
> INNODB;
> -
> So it can't be added as a foreign key.
>
> Now, i'm trapped. In both cases i get an error.
>
> How do I have to write my schema.yml, that this works without errors?
>
> thanks for your ideas
>
> Tobias
>
>
> >
>


-- 
Jonathan H. Wage
Open Source Software Developer & Evangelist
http://www.jwage.com
http://www.doctrine-project.org
http://www.symfony-project.org

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~--~~~~--~~--~--~---