I'm trying to make a simple migration tool that ru...
# orm-help
m
I'm trying to make a simple migration tool that runs migrations from .sql scripts using:
Copy code
const sql = fs.readFileSync(path.join(basePath, fileName), {
  encoding: 'utf8'
});

await db.executeRaw(sql);
But I get:
Copy code
PrismaClientKnownRequestError: Raw query failed. Code: `1064`. Message: `You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE IF NOT EXISTS `IndustrySector` (
  `id` int NOT NULL AUTO_INCREMEN' at line 31`
    at PrismaClientFetcher.request (D:\dev\perimetre\export-connect-backend\node_modules\@prisma\client\src\runtime\getPrismaClient.ts:902:15)
    at processTicksAndRejections (internal/process/task_queues.js:97:5) {
  code: 'P2010',
  meta: {
    code: '1064',
    message: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE TABLE IF NOT EXISTS `IndustrySector` (\r\n" +
      "  `id` int NOT NULL AUTO_INCREMEN' at line 31"
  }
}
Even though if I copy the contents of the sql file and use it with something like Mysql Workbench oh php my admin it works fine. Is
executeRaw
not suited for that? Is there other way that I can do this?
j
Can you share your SQL?
m
Hmmm, I don't know if I can share it all for privacy/disclosure agreement reasons. But I think I can share this specific section privately with you. Does that work?
j
Yes, then I would quickly try to reproduce.