question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Seeding not working in 2.23.0 in Windows

See original GitHub issue

Bug description

When seeding the database, prisma/seed.ts doesn’t seem to be getting called, despite saying that it seeded my database. I tried wrapping lines 30-37 in an export const seed = () => { ... }; and also with export default function() { ... }. In all three cases, none of the console.log() calls are logged, and the database is not updated. I also know that it knows prisma/seed.ts exists, as when I delete the file it errors. Reproduction steps are mostly just following the code at Start from scratch | TypeScript & MySQL | Prisma Docs and prisma-examples/seed.ts at latest · prisma/prisma-examples.

(Note: when switching the version of prisma and @prisma/client back to 2.22.1, bug no longer occurs and functionality is normal. Breaks again when switching back to 2.23.0)

How to reproduce

  1. Generate a new nodejs project with yarn init
  2. Run yarn add @prisma/client and yarn add --dev @types/node prisma ts-node typescript
  3. Run prisma init
  4. Set DATABASE_URL in .env file
  5. Create tsconfig.json
  6. Run prisma migrate dev --name init
  7. Create seed.ts in folder with schema.prisma
  8. Run prisma db seed --preview-feature
  9. See output (no console.logs are called, database doesn’t update)

Expected behavior

No response

Prisma information

.env:

DATABASE_URL="mysql://xxx:yyy@zzz/prismabugrepo"
DEBUG="*"

tsconfig.json:

{
  "compilerOptions": {
    "sourceMap": true,
    "outDir": "dist",
    "strict": true,
    "lib": ["esnext"],
    "esModuleInterop": true
  }
}

prisma/schema.prisma:

datasource db {
  provider = "mysql"
  url      = env("DATABASE_URL")
}

generator client {
  provider = "prisma-client-js"
}

model User {
  id          String   @id @default(uuid())
  joinedAt    DateTime @default(now())
  username    String   @unique
  displayName String?
}

prisma/seed.ts:

import {Prisma, PrismaClient} from "@prisma/client";

console.log("Top of script");

const prisma = new PrismaClient({
  log: ["query", "info", "warn", "error"]
});

const main = async () => {
  console.log("Start seeding...");

  const userData: Prisma.UserCreateInput[] = [
    {
      username: "user123",
      displayName: "User One Two Three"
    }
  ];

  for (const u of userData) {
    const user = await prisma.user.create({
      data: u
    });

    console.log(`Created user with ID ${user.id}`);
  }

  console.log("Finished seeding.");
};

main()
  .catch((e) => {
    console.error(e);
    process.exit(1);
  })
  .finally(async () => {
    await prisma.$disconnect();
  });

console.log("Bottom of script");

Console Output:

C:\Programming\prisma-bug-repro> prisma db seed --preview-feature
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Running seed from prisma\seed.ts ...

Your database has been seeded.
C:\Programming\prisma-bug-repro>

Environment & setup

  • OS: Windows 10 Version 20H2 (OS build 19042.985)
  • Database: MySQL
  • Node.js version: 16.0.0

Prisma Version

prisma               : 2.23.0
@prisma/client       : 2.23.0
Current platform     : windows
Query Engine         : query-engine adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\query-engine-windows.exe)
Migration Engine     : migration-engine-cli adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\migration-engine-wi
ndows.exe)
Introspection Engine : introspection-core adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\introspection-engine-
windows.exe)
Format Binary        : prisma-fmt adf5e8cba3daf12d456d911d72b6e9418681b28b (at node_modules\@prisma\engines\prisma-fmt-windows.exe)
Default Engines Hash : adf5e8cba3daf12d456d911d72b6e9418681b28b
Studio               : 0.393.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:30
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

23reactions
pantharshit00commented, May 23, 2021

I can confirm this regression. We will fix this.

9reactions
MikaStarkcommented, Jun 30, 2021

Same issue too with 2.26

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I seed an mssql db using Prisma and createMany
I have run the prisma generate and prisma db push commands successfully. My database and tables are created and Prisma connects to it...
Read more >
How to Turn Off Seeding (Disable Upload) after downloading ...
This video shows you how to disable the seeding on utorrent.Note: I'm not responsible for torrenting, this is just a tutorial to prevent ......
Read more >
Bedtools Documentation - Read the Docs
However, we found that the web-based tools were too cumbersome when working with large datasets generated by current sequencing technologies.
Read more >
NEWS - third_party/glib - Git at Google - fuchsia Git repositories
#1522 Trash not working on NTFS folder accessed from symlink. - #1523 GIO NetworkMonitor doesn't reflect the current network state.
Read more >
Changelog for mbed TLS 2.23.0 - ABI laboratory
mbed TLS ChangeLog (Sorted per branch, date) = mbed TLS 2.23.0 branch released ... Changes * Fix warnings about signedness issues in format...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found