laravel-harbor
laravel-harbor copied to clipboard
Options for importing initial database
Hopefully this isn't too niche a use-case...
Harbor has automated 95% of the work needed for us to quickly send preview sites to clients. The one step that I still have to do (and can't easily delegate) is importing initial data after the site has been provisioned.
As it currently stands, one option would be to write something custom inside FORGE_DEPLOY_SCRIPT; this would need to check to see if a specific DB table was empty, and if so, import the DB either by seeding or importing from a SQL file. Either way it would likely mean commiting a command into the laravel app to only be called inside harbor environments.
While it would work in theory, a nicer alternative might be to expose some additional environment variables, for example:
FORGE_DB_SEED
This would be a boolean, which if true, would run php artisan db:seed
after the site was deployed for the first time. Useful when you want to fill the preview site with test data that's already committed in your repo.
FORGE_DB_SQL
This would be a path to a SQL file on the server; if present, it would be imported after the database was created. Useful when the preview site needs more realistic data that's not commited in the repo (due to size, data security etc).
In terms of implementation I suppose both of these would need to build and then execute a custom site command, before polling for the outcome.
Is this something others have come across / are there alternative ideas? If it seems like something useful I'm happy to look into it.