lumen-generators icon indicating copy to clipboard operation
lumen-generators copied to clipboard

Add a possibility to rollback an action

Open ja-tomasz opened this issue 7 years ago • 2 comments

Would be good for each generator, but at least for a specific resource - that would look for migration, model, controller and routes and delete them if found. Especially useful since the "resources" generator currently creates and runs the migration. See the other isse I reported.

ja-tomasz avatar Feb 03 '17 13:02 ja-tomasz

Hello,

Rolling back any action is not a simple problem, it's like writting a mini VCS just for the generated/modified files.

I guess there are mostly two cases in which you will need a rollback:

  1. You accidently generated something you don't need. You mostly need to just delete the files/lines added by the generators. If you generated a migration that was applied, you will need to rollback migrations first, remove it, run composer dump-autoload, then re-apply migrates.

  2. You accidentally typed something wrong. You simply rerun the command with --force=true. Again if there was a migration, you should rollback migrations and delete the wrong one manually before re-running the command.

Hope this solves most of the issues :)

webNeat avatar Feb 03 '17 15:02 webNeat

yes, I use VCS to remove the generated files, but its just an additional tool you need to use.

Maybe marking the generated code (migraton, routes, factories) with some comment that would help recognizing it when using --force=true?

ja-tomasz avatar Feb 03 '17 18:02 ja-tomasz