You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Sqlite Custom field Changes Primary Key error **
When adding custom fields, and we have already added data to database(demo data), It causes SqliteError: FOREIGN KEY constraint failed error
To Reproduce
Steps to reproduce the behavior:
Go to 'vendure-config.ts'
Add 'customFields'
Generate migrations
Run migrations
Expected behavior
Changes have to migrated to db.
Environment (please complete the following information):
@vendure/core version:1.0.0-rc.0
Nodejs version: 12.0
Database (mysql/postgres etc): sqlite3
Temporary fix
I know that disableForeignKeysForSqLite function but it seems like doesn't work for this situation, so if you similar problem you can make it like this.
Go to 'node_modules/@vendure/core/migrate.js'
Find function runMigrations
Before try paste this code await connection.query('PRAGMA foreign_keys=OFF');
At the end of paste this code await connection.query('PRAGMA foreign_keys=ON');
The text was updated successfully, but these errors were encountered:
Ah ok I think I know what is going on here: the disableForeignKeysForSqLite function is only checking for the sqlite driver, but since then we moved over to use the better-sqlite3 driver by default, which would cause the check to fail.
**Sqlite Custom field Changes Primary Key error **
When adding custom fields, and we have already added data to database(demo data), It causes
SqliteError: FOREIGN KEY constraint failed
errorTo Reproduce
Steps to reproduce the behavior:
Expected behavior
Changes have to migrated to db.
Environment (please complete the following information):
Temporary fix
I know that disableForeignKeysForSqLite function but it seems like doesn't work for this situation, so if you similar problem you can make it like this.
await connection.query('PRAGMA foreign_keys=OFF');
await connection.query('PRAGMA foreign_keys=ON');
The text was updated successfully, but these errors were encountered: