8

If I already have an existing Laravel Jetstream (Inertia) project which was installed without the --teams option is there a way to go back and install support for teams given that I have already created multiple controllers, models, migrations and other customizations within the app?

Joseph
  • 2,737
  • 1
  • 30
  • 56

1 Answers1

9

AS A TEST, I did it here on my Jetstream LIVEWIRE project, by reinstalling Jetstream with --teams. It's doable, but beware of some side effects.

What I did:

  1. Publish Jetstream view files, if you haven't already:

    php artisan vendor:publish --tag=jetstream-views
    
  2. Update Jetstream to version 2.0 (upgrade guide)

  3. Reinstall Jetstream with options --teams:

    php artisan jetstream:install livewire --teams
    

    Warning: This will install the remaining actions, models, factories, and tests and will update several files, among those some view files, including on the layout views folder, so be careful and have them in source control or in a backup BEFORE trying this. Some view files will change entirely, so you will have to manually merge the changes with your old ones.

  4. Run the migrations that were created

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
sjardim
  • 321
  • 3
  • 5
  • I had to take an additional step to get the application running. I had to remove the pre-existing user(s) who were already registered and re-register them to get the application to work, because the accounts were missing the required Teams configurations applied at registration. – Carl Peterson Nov 24 '21 at 15:26
  • 1
    I can confirm that re-running the command with `--teams` will just add/change the files that are required to add teams support. Carefully check if the changed file modifications are okay. If you just installed jetstream, they should be okay. I only had to check my jetstream config, as i've enabled the token support. Make sure to delete the session migration file, as this is being added twice. What I did not test was with existing users already created, I've reset my database. – NicoHood May 29 '22 at 20:24
  • This was a good solution. Start by working on a clean branch/commit state. Then, once the install is finished you can go through and compare files. This was mostly easy. There may be a few updates you need to incorporate, or tweaks to the otherwise unchanged logic. In addition to moving any mods to old migrations into a new one, I also created a console Command which went through and created a personal team for each user, which also moved any "user" things to that team. Once you've tested locally, update the server, run the migrations and then that command to fix old users etc. – Elliot Jul 28 '22 at 02:44