我正在尝试对一个SQLite数据库运行迁移脚本。以下是我在尝试迁移查询时收到的错误:
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: SQLITE_ERROR: near "categoryId": syntax error] {
errno: 1,
code: 'SQLITE_ERROR'
}
我正在运行用于创建表的SQL查询
CREATE TABLE IF NOT EXISTS "Category" (
id INTEGER PRIMARY KEY NOT NULL,
name VARCHAR NOT NULL );
CREATE TABLE IF NOT EXISTS "Location"(
id INTEGER PRIMARY KEY NOT NULL,
name VARCHAR NOT NULL );
CREATE TABLE IF NOT EXISTS "Job" (
id INTEGER PRIMARY KEY NOT NULL,
createdAt datetime NOT NULL default current_time,
title VARCHAR NOT NULL,
description VARCHAR NOT NULL,
locationId INTEGER NOT NULL,
FOREIGN KEY(locationId) REFERENCES Location(id),
categoryId INTEGER NOT NULL,
FOREIGN KEY(categoryId) REFERENCES Category(id) );
1条答案
按热度按时间hujrc8aj1#
在定义约束之前,您需要定义所有列,因此将脚本中倒数第二行和倒数第三行互换: