language-tools
language-tools copied to clipboard
Auto-replace updated table column names in vscode
Problem
When prototyping, and I update a column name (e.g. "foo" -> "bar"), I want VSCode to pop up and say "Hey! Do you want me to auto-update occurrences of foo -> bar inside prisma query statements in your code?"
(The UX here would be similar to how vscode handles auto-updating imports when file names change)
Suggested solution
This involves several challenges:
- Working out what constitutes a column name change on a file diff. Unlike generated migrations where this needs to be 100% correct, because we'd ask the user to confirm, we could make a best guess and ask them to confirm
- Working out what constitutes an instance of
fooin code that needs to be replaced. Some ideas:- This only works in .ts files where we can inspect the type at a character position to confirm that's a reference to the column inside a prisma selection
- Be dumb and grep for
fooand let the user hit confirm for each one (i.e. we kick into the regular search and replace UI)
Alternatives
- Kick into the regular search and replace UI
Thanks!
"update a column name" refers to changing the field name in the Prisma Schema here I guess?
Yes, sorry
All good, this makes this mostly a Prisma Language tools concern (which is for example used in the VSCode extension). I moved the issue there. I agree this would be an interesting feature, when changing the schema could directly influence your Prisma Client code.