-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add the --force flag to enable non-interactive db reset
#3480
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
Conversation
waspc/cli/exe/Main.hs
Outdated
| "start" : optionalStartArgs -> runCommand $ Command.Start.Db.start optionalStartArgs | ||
| -- These commands require an existing and running database. | ||
| ["reset"] -> runCommandThatRequiresDbRunning Command.Db.Reset.reset | ||
| "reset" : optionalResetArgs -> runCommandThatRequiresDbRunning $ Command.Db.Reset.reset optionalResetArgs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed the pattern that migrate-dev command used.
| parseResetArgs :: [String] -> Either String ResetArgs | ||
| parseResetArgs resetArgs = do | ||
| go resetArgs defaultResetArgs | ||
| where | ||
| go :: [String] -> ResetArgs -> Either String ResetArgs | ||
| go [] currentResetArgs = Right currentResetArgs | ||
| go ("--force" : rest) currentResetArgs = go rest $ currentResetArgs {_force = True} | ||
| go unknown _ = Left $ "Unknown reset arg(s): " ++ unwords unknown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to use the optparse-applicative even though it's quite simple, it's a way to future-proof our arg parsing (we want to move it completely to optparse-applicative at some point).
Take a look at https://github.com/wasp-lang/wasp/blob/main/waspc/cli/src/Wasp/Cli/Command/BuildStart.hs#L26
Carlos built some nice parsing helpers which you can use 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems very nice, just confused as to why we send the name to withArguments, seems only for logging.
That seems a bit out of place to me, but I won't touch it.
infomiho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, I'd swap out custom argument parsing for a proper parser. Otherwise, I'm okay with the naming and the addition.
| prismaArgs = | ||
| [ "migrate", | ||
| "reset", | ||
| "--schema", | ||
| SP.fromAbsFile schema, | ||
| "--skip-generate", | ||
| -- NOTE(martin): We do "--skip-seed" here because I just think seeding | ||
| -- happening automatically on reset is too aggressive / confusing. | ||
| "--skip-seed" | ||
| ] | ||
| ++ if force resetArgs then ["--force"] else [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I commented on this line, I thought you can move the whole prismaArgs where it was previously, but I won't block on this.
RAW
infomiho
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job
Description
Adds the
--forceflag option towasp db resetcommand, which just relays the--forceflag to the prisma CLI. This makes it reset the database without any interaction (no y/n needed).I picked the option which stays in line with the prisma workflow the most.
Possible variations:
--force)Type of change
Checklist
I tested my change in a Wasp app to verify that it works as intended.
🧪 Tests and apps:
examples/kitchen-sink/e2e-tests.waspc/data/Cli/templates, as needed.examples/, as needed.examples/tutorials) I updated the tutorial in the docs (and vice versa).📜 Documentation:
web/docs/.🆕 Changelog: (if change is more than just code/docs improvement)
waspc/ChangeLog.mdwith a user-friendly description of the change.web/docs/migration-guides/.versioninwaspc/waspc.cabalto reflect the changes I introduced.