node.jsbetter-sqlite3

SqliteError: no such table: main.old_profiles. But there is no such table in a code. Better-sqllite3


I got an error:

\node_modules\better-sqlite3\lib\methods\wrappers.js:5
        return this[cppdb].prepare(sql, this, false);
                           ^
SqliteError: no such table: main.old_profiles
    at Database.prepare (\node_modules\better-sqlite3\lib\methods\wrappers.js:5:21)
    at parsePhotos (file:///photo-filler/app.js:401:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///app.js:91:13 {
  code: 'SQLITE_ERROR'
}

The SQL for the error on line 401:

const insert = db.prepare('INSERT INTO photos (profileId, href, img, description) VALUES (@profileId, @href, @img, @description)');

And there is no references of that "main.old_profiles" table anywhere in the code.


Solution

  • Ok, it was foreign key reference

    FOREIGN KEY (profileId) REFERENCES "old_profiles"(id)