【发布时间】:2010-11-26 00:21:14
【问题描述】:
更新
我现在回到了以前的教义版本,现在错误是:
Invalid schema element named "Roles" at path "RoleResource->columns->relations"
这是相同的 yaml 文件(见下文)
我对教义命令行工具有疑问。当我给出命令“build-all-reload”时,出现以下错误:
SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'role_id' doesn't exist in table. Failing Query: "CREATE TABLE resource (id BIGINT AUTO_INCREMENT, name VARCHAR(20), INDEX role_id_idx (role_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = INNODB". Failing Query: CREATE TABLE resource (id BIGINT AUTO_INCREMENT, name VARCHAR(20), INDEX role_id_idx (role_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = INNODB
我的 yaml 文件如下所示:
detect_relations: true
options:
type: INNODB
collate: utf8_general_ci
charset: utf8
Log:
columns:
id:
type: integer
primary: true
autoincrement: true
priority: tinyint
priorityName: string(10)
title: string(250)
message: text
actAs:
Timestampable:
created:
type: timestamp
format: Y-m-d H:i:s
updated:
disabled: true
User:
columns:
id:
type: integer
primary: true
autoincrement: true
username: string(50)
password: string(40)
actAs:
Timestampable:
created:
type: timestamp
format: Y-m-d H:i:s
updated:
type: timestamp
format: Y-m-d H:i:s
Role:
columns:
id:
type: integer
primary: true
autoincrement: true
name: string(20)
attributes:
export: all
validate: true
RoleResource:
columns:
role_id:
type: integer
primary: true
resource_id:
type: integer
primary: true
relations:
Role:
foreignAlias: RoleResource
Resource:
foreignAlias: RoleResource
Resource:
columns:
id:
type: integer
primary: true
autoincrement: true
name: string(20)
relations:
Roles:
foreignAlias: Resources
class: Role
refClass: RoleResource
Menu:
columns:
id:
type: integer
primary: true
autoincrement: true
label: string(20)
Artical:
columns:
id:
type: integer
primary: true
autoincrement: true
title: string
content: longtext
css: longtext
js: longtext
我不知道如何解决这个问题。
有人可以帮帮我吗?
【问题讨论】:
-
它似乎试图在资源表中的 role_id 列上添加索引,但该表不包含该列。您确定这是您的构建命令正在执行的架构文件吗?
-
我确定,但看起来学说缓存了文件。
-
我过去也遇到过这种情况。试试看是否可以在某处找到临时文件夹并删除其中的所有架构片段。我在家里的 Win7 上运行 XAMPP,在我的情况下,临时文件夹位于 XAMPP 文件夹中。您可能需要在每次构建时重复此操作。由于某种原因,似乎影响了最新版本的 Doctrine 1.2。