0

使用syncdb以下架构时创建:

CREATE TABLE "MyApp_supervisor" (
    "id" integer NOT NULL PRIMARY KEY,
    "supervisor_id" integer NOT NULL REFERENCES "MyApp_employee" ("id"),
    "section_id" integer NOT NULL REFERENCES "MyApp_section" ("id")
);

使用时migrate,改为:

CREATE TABLE "MyApp_supervisor" (
    "id" integer NOT NULL PRIMARY KEY,
    "supervisor_id" integer NOT NULL,
    "section_id" integer NOT NULL
);

为什么南方会这样做?我还没有注意到功能问题,但我厌倦了忽略这一点......

有人可以阐明这里发生的事情吗?

4

1 回答 1

0

这可能是因为 SQLite 仅在 3.6.19 版本中引入了外键支持,如本页所述:

本文档描述了对 SQLite 版本 3.6.19 中引入的 SQL 外键约束的支持。

看起来版本 3.6.19是在 2009 年 10 月 14 日标记的,这实际上是最近的,所以它可能还没有部署到任何地方。

我猜选择不声明外键是因为它们尚未得到广泛支持,具体取决于所使用的 SQLite 版本。(话虽这么说,外键语法以前是支持的,但只是被忽略了。)

于 2010-09-10T01:37:58.907 回答