Git Product home page Git Product logo

Comments (5)

iiian avatar iiian commented on July 20, 2024

Hey @marklawlor , glad you found the tool useful.

Can you describe your workflow for me? How are new properties being generated, and why is it infeasible to keep them in sync by hand after the initial migration?

If I understand correctly, it sounds like you're asking for "don't bother applying conventions if the table or field already has a map annotation applied.

I'm a bit swamped at work right now, so it could be awhile before I get around to it, but if you wanted to create a PR for this, I would happily merge it in because making the tool idempotent is a reasonable idea.

from prisma-case-format.

marklawlor avatar marklawlor commented on July 20, 2024

Can you describe your workflow for me? How are new properties being generated, and why is it infeasible to keep them in sync by hand after the initial migration?

We would like to keep our database in snake_case and JS in camelCase/PascalCase for legacy and stylist reasons. It's not infeasible to maintain by hand, and we have been doing so for quite a while - however someone evitiable forgets to add a @map() and accidently pushes a camelCase column.

Prisma has no linting tool, so we rely on PRs to catch human error but mistakes happen. I would like to use this CLI in our CI pipeline:

  • On PR creation run prisma-case-format
  • If the CLI changes the schema we can fail the PR as a column and/or @map() value is missing.

If I understand correctly, it sounds like you're asking for "don't bother applying conventions if the table or field already has a map annotation applied.

No. I would like a flag to also apply a case convention to the @map() attribute. If a @map() is missing (and the generated column will be in the wrong case) it should add a @map() attribute OR if the @Map() is incorrect, it should be updated to the correct case.

from prisma-case-format.

iiian avatar iiian commented on July 20, 2024

Gotcha. Thanks for correcting me there. I see now that --map-[field|table]-case= are new properties you're proposing. I had not considered using this tool as a small "aftermarket" CI for prisma schemas, but I see the value in what you're proposing.

I probably have time to get around to it in the next few weeks, either when work calms down or the mood strikes.

You could use --dry-run to diff the changes against your schema, or I could add a --check or --detect-drift flag that yields a number of validations to stderr.

from prisma-case-format.

iiian avatar iiian commented on July 20, 2024

@marklawlor, I've pushed out [email protected] which corresponds to this pull request.

Per your suggestion, you can get ongoing convention-drift-checking by calling

prisma-case-format \
  --file=<du jour> \
  --dry-run \
  --field-case=<du jour> \
  --table-case=<du jour> \
  --map-field-case=snake \
  --map-table-case=snake

I teed up quite a few tests to make sure everything is on the up and up, but it would be great if you could pull this beta version and run it on your setup, even just once, to see if you can spot any obvious bugs.

from prisma-case-format.

marklawlor avatar marklawlor commented on July 20, 2024

That works really well 👍

from prisma-case-format.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.