Я создаю настольное приложение с электроном Js, используя базу данных SQLite с typeOrm. Я добавил новый столбец к существующей сущности User
, которая уже имеет некоторые данные, когда я запустил имя, я получил ошибку, показанную ниже. Как добавить новый столбец в объект, который уже находится в производстве.
@Entity('user')
export class User {
@Column({
type: "int",
default: 0
})
newColumn: number;
}
Я получил эту ошибку:
query: DROP TABLE "user"
query failed: DROP TABLE "user"
error: [Error: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed] {
errno: 19,
code: 'SQLITE_CONSTRAINT'
}
query: ROLLBACK
(node:6600) UnhandledPromiseRejectionWarning: QueryFailedError: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed
at new QueryFailedError (C:\xampp\htdocs\desktop-app\node_modules\typeorm\error\QueryFailedError.js:11:28)
at Statement.handler (C:\xampp\htdocs\desktop-app\node_modules\typeorm\driver\sqlite\SqliteQueryRunner.js:48:38)
at Statement.replacement (C:\xampp\htdocs\desktop-app\node_modules\sqlite3\lib\trace.js:19:31)
at Statement.replacement (C:\xampp\htdocs\desktop-app\node_modules\sqlite3\lib\trace.js:19:31)
(node:6600) UnhandledPromiseRejectionWarning: QueryFailedError: SQLITE_CONSTRAINT: FOREIGN KEY constraint failed
at new QueryFailedError (C:\xampp\htdocs\desktop-app\node_modules\typeorm\error\QueryFailedError.js:11:28)
at Statement.handler (C:\xampp\htdocs\desktop-app\node_modules\typeorm\driver\sqlite\SqliteQueryRunner.js:48:38)
at Statement.replacement (C:\xampp\htdocs\desktop-app\node_modules\sqlite3\lib\trace.js:19:31)
at Statement.replacement (C:\xampp\htdocs\desktop-app\node_modules\sqlite3\lib\trace.js:19:31)
(node:6600) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6600) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6600) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:6600) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.