tighten / onramp

Easing the onramp for new or non-PHP developers to become Laravel devs.
https://onramp.dev/
MIT License
157 stars 56 forks source link

Sync and seed data from production #537

Closed tammytee closed 1 year ago

tammytee commented 1 year ago

Closes #239

Summary

This PR creates a command to generate JSON seeder files from the production database so maintainers and contributors can seed their local database with up-to-date content.

Usage

The command to generate/update the JSON seeder files is as follows:

php artisan generate:seeds-from-db {--override} {--all}

The --all option can be used to sync all content tables from production and automatically override the contents of any existing seeder files during the update. When this option is omitted, users can choose which data they'd like to sync:

image

The --override option can be used to automatically override the contents of any existing seeder files when updating a single table. Otherwise, the user will need to confirm this action during the update:

image

With the seeder files in place, users should run the following command to update their local development data:

php artisan migrate:fresh --seed

Implementation

For now, maintainers should periodically run the command to update the seeder files and commit those changes to the repo. This can especially be done when new resources etc are added to the production site via Nova.

Maintainer Note: Be sure to set the following env variables to connect to the Forge server where Onramp is hosted

TUNNELER_USER=
TUNNELER_HOSTNAME=
TUNNELER_PORT=

Future Improvements

To eliminate the need for manually updating these files, we should implement running a scheduled command that regenerates the seeder files for us and commits those changes from the server (h/t @darkboywonder). When this happens we should:

tammytee commented 1 year ago

I reviewed this and everything looks good to me. Can't approve it myself 😄 - @darkboywonder