Using Git to track mysql schema - some questions

后端 未结 8 2046
忘掉有多难
忘掉有多难 2020-12-04 10:27

If this is recommended ?

Can I ask some git command examples about how to track versions of mysql schema?

Should we use another repository other then the on

8条回答
  •  悲哀的现实
    2020-12-04 10:42

    (shameless plug)

    The dbvc commandline tool allows you to manage your database schema updates in your repository.

    It creates and uses a table _dbvc in the database which holds a list of the updates that are run. You can easily run the updates that haven't been apply to your database schema yet.

    The tool uses git to determine the correct order of executing the updates.

    DBVC usage

    Show a list of commands

    dbvc help
    

    Show help on a specific command

    dbvc help init
    

    Initialise DBVC for an existing database.

    dbvc init
    

    Create a database dump. This is used to create the DB on a new environment.

    mysqldump foobar > dev/schema.php
    

    Create the DB using the schema.

    dbvc create
    

    Add an update file. These are used to update the DB on other environments.

    echo 'ALTER TABLE `foo` ADD COLUMN `status` BOOL DEFAULT 1;' > dev/updates/add-status-to-foo.sql
    

    Mark an update as already run.

    dbvc mark add-status-to-foo
    

    Show a list of updates that need to be run.

    dbvc status
    

    Show all updates with their status.

    dbvc status --all
    

    Update the database.

    dbvc update
    

提交回复
热议问题