Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not force seed to be script #5624

Closed
jasonkuhrt opened this issue Feb 12, 2021 · 1 comment
Closed

Do not force seed to be script #5624

jasonkuhrt opened this issue Feb 12, 2021 · 1 comment
Assignees
Labels
kind/feedback Issue for gathering feedback. team/schema Issue for team Schema. topic: migrate
Milestone

Comments

@jasonkuhrt
Copy link
Member

jasonkuhrt commented Feb 12, 2021

Problem

I have a seed script for Prisma but I want to re-use it for testing, keeping some seed utilities for granular seeding per test groups.

Right now prisma/seed is assumed to be a script. This means as a user I need to configure my project to have two things: the module with my seed helpers and the script Prisma will execute.

I don't want to be forced to have two modules when one would be good enough.

Suggested solution

  • Only treat seed.ts as a script if there are no exports treat as a script

  • If there are ANY exports then do not treat as a script. Instead treat as a module interface. If user exports a run function call that. Maybe default too? Maybe other names? Also allow the module name/export name to be customized on cli like —seed foo:bar which would look for foo file and run bar function export.

  • Pass in useful info to the seed! For example an a schema AST so users can reflect on it to generate fake data more automatically. I’m sure lots of little nice things we could do there.

  • If the user does not export the correctly names function but it IS in the conventional disk place with the conventional file name probably we should warn because probably that is user error
    This setup would allow best of both worlds: migrate run workflow integration + module API for use in other places like tests

Alternatives

Additional context

Internal Discussion

From another GH thread:
#5161

image

I don't consider this an alternative as I agree with Brandon about confusion etc. here.

@Jolg42 Jolg42 added team/schema Issue for team Schema. topic: cli-migrate kind/feedback Issue for gathering feedback. labels Feb 12, 2021
@tomhoule tomhoule added this to the 2.18.0 milestone Feb 17, 2021
@albertoperdomo albertoperdomo modified the milestones: 2.18.0, 2.19.0 Mar 3, 2021
@albertoperdomo albertoperdomo modified the milestones: 2.19.0, 2.20.0 Mar 17, 2021
@tomhoule tomhoule modified the milestones: 2.20.0, 2.21.0 Mar 31, 2021
@tomhoule tomhoule modified the milestones: 2.21.0, 2.22.0 Apr 14, 2021
@tomhoule tomhoule modified the milestones: 2.22.0, 2.23.0 May 5, 2021
@Jolg42 Jolg42 closed this as completed May 18, 2021
@Jolg42
Copy link
Member

Jolg42 commented May 19, 2021

See 2.23.0 release notes for how to use an export when using seed https://github.com/prisma/prisma/releases/tag/2.23.0

Open a new issue or GitHub discussion if you need to report something/give feedback 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feedback Issue for gathering feedback. team/schema Issue for team Schema. topic: migrate
Projects
None yet
Development

No branches or pull requests

5 participants