How to use Git on Laravel with Voyager? [closed]

2019-08-26 08:40发布

问题:

Can someone help me using admin Voyager using git? For example, If you need to add new content type, how to add git for future push and deploy it on the remote server?

回答1:

Git - as well as SVN, Mercurial, and others - only operates on the filesystem. MySQL and Postgres databases are not technically a part of your project's filesystem, so you can't add those changes to a traditional VCS.

Outside of changing your database from MySQL / Postgres to SQLite (which incidentally is stored as a file in your project directory), Git will have nothing to do with your database.

If you really want to go through the hassle of keeping your database version controlled on the filesystem, then you can potentially look into the following:

  1. Create a MySQL dump of everything you want to store. Look into webhooks to run a command to import the dump after every push. Update the dump as necessary.
  2. Use migrations and seeds to keep a snapshot of your database. Look into webhooks to run the appropriate artisan commands to tear down and re-migrate and seed the database after every push. Update your seeds as necessary.
  3. Switch to SQLite. I don't know if this will even work because I don't even know if Voyager is compatible with SQLite.

Outside of that, you should probably look into a deployment process for your database that involves tools like Capistrano to manage what you need.