2020-11-14 01:38:56 +00:00
|
|
|
# MyVC (MySQL Version Control)
|
|
|
|
|
2020-11-15 18:24:25 +00:00
|
|
|
Utilities to ease the maintenance of MySQL or MariaDB database versioning using
|
|
|
|
a Git repository.
|
|
|
|
|
|
|
|
This project is just to bring an idea to life and is still in an early stage of
|
|
|
|
development, so it may not be fully functional.
|
|
|
|
|
|
|
|
Any help is welcomed! Feel free to contribute.
|
2020-11-14 01:38:56 +00:00
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
Required applications.
|
|
|
|
|
|
|
|
* Node.js = 12.17.0 LTS
|
2020-11-15 18:24:25 +00:00
|
|
|
* Git
|
2020-11-14 01:38:56 +00:00
|
|
|
* Docker
|
|
|
|
|
2020-11-14 15:08:27 +00:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
It's recommended to install the package globally.
|
2020-11-15 18:24:25 +00:00
|
|
|
```text
|
2020-11-14 15:08:27 +00:00
|
|
|
# npm install -g myvc
|
2020-11-17 10:53:31 +00:00
|
|
|
$ myvc [command]
|
2020-11-14 15:08:27 +00:00
|
|
|
```
|
|
|
|
|
2020-11-15 18:24:25 +00:00
|
|
|
You can also install locally and use the *npx* command to execute it.
|
|
|
|
```text
|
|
|
|
$ npm install myvc
|
2020-11-17 10:53:31 +00:00
|
|
|
$ npx myvc [command]
|
2020-11-14 01:38:56 +00:00
|
|
|
```
|
|
|
|
|
2020-11-15 18:24:25 +00:00
|
|
|
## How to use
|
2020-11-14 01:38:56 +00:00
|
|
|
|
2020-11-17 10:53:31 +00:00
|
|
|
Execute *myvc* with the desired command.
|
2020-11-15 18:24:25 +00:00
|
|
|
```text
|
2020-11-17 10:53:31 +00:00
|
|
|
$ myvc [-w|--workspace] [-e|--env] [-h|--help] command
|
2020-11-14 01:38:56 +00:00
|
|
|
```
|
2020-11-15 18:24:25 +00:00
|
|
|
The default working directory is the current one and unless otherwise indicated,
|
|
|
|
the default environment is *production*.
|
2020-11-14 01:38:56 +00:00
|
|
|
|
2020-11-17 10:53:31 +00:00
|
|
|
Available commands are:
|
|
|
|
|
|
|
|
* **pull**: Exports database routines into workspace.
|
|
|
|
* **push**: Apply changes into database, uses *test* environment by default.
|
|
|
|
* **dump**: Export database structure and fixtures.
|
2020-11-15 18:24:25 +00:00
|
|
|
* **run**: Builds and starts local database server container.
|
|
|
|
* **start**: Starts local database server container.
|
|
|
|
|
2020-11-17 10:53:31 +00:00
|
|
|
Each command can have its own specific commandline options.
|
2020-11-14 01:38:56 +00:00
|
|
|
|
|
|
|
## Basic information
|
|
|
|
|
2020-11-16 00:58:27 +00:00
|
|
|
First of all you have to import *structure.sql* into your database. This script
|
2020-11-15 18:38:23 +00:00
|
|
|
includes the tables where MyVC stores information about applied versions.
|
|
|
|
|
2020-11-16 00:58:27 +00:00
|
|
|
Create *myvc.config.json* main configuration file at the root of your project
|
|
|
|
folder, this file should include the project codename and schemas/tables wich
|
2020-11-17 10:53:31 +00:00
|
|
|
are exported when you use *pull*or *dump* commands. You have an example of a
|
|
|
|
configuration file in the root folder of this project.
|
2020-11-15 18:38:23 +00:00
|
|
|
|
2020-11-16 00:58:27 +00:00
|
|
|
### Environments
|
|
|
|
|
|
|
|
Create database connection configuration files for each environment at main
|
|
|
|
project folder using standard MySQL *.ini*. The predefined environment names
|
|
|
|
are *production* and *testing*.
|
2020-11-15 18:24:25 +00:00
|
|
|
```text
|
2020-11-14 01:38:56 +00:00
|
|
|
db.[environment].ini
|
|
|
|
```
|
|
|
|
|
2020-11-16 00:58:27 +00:00
|
|
|
### Dumps
|
|
|
|
|
2020-11-17 10:53:31 +00:00
|
|
|
Structure and fixture dumps will be created into hidden file *.dump.sql*. You
|
|
|
|
can also create your local fixture and structure files.
|
2020-11-16 00:58:27 +00:00
|
|
|
|
2020-11-17 10:53:31 +00:00
|
|
|
* *myvc.structure.sql*
|
|
|
|
* *myvc.fixtures.sql*
|
2020-11-14 01:38:56 +00:00
|
|
|
|
2020-11-15 18:24:25 +00:00
|
|
|
### Routines
|
|
|
|
|
|
|
|
Routines should be placed inside *routines* folder. All objects that have
|
2020-11-16 00:58:27 +00:00
|
|
|
PL/SQL code are considered routines. It includes events, functions, procedures,
|
|
|
|
triggers and views with the following structure.
|
2020-11-15 18:24:25 +00:00
|
|
|
```text
|
2020-11-14 01:38:56 +00:00
|
|
|
routines
|
|
|
|
`- schema
|
|
|
|
|- events
|
|
|
|
| `- eventName.sql
|
|
|
|
|- functions
|
|
|
|
| `- functionName.sql
|
|
|
|
|- procedures
|
|
|
|
| `- procedureName.sql
|
|
|
|
|- triggers
|
|
|
|
| `- triggerName.sql
|
|
|
|
`- views
|
|
|
|
`- viewName.sql
|
|
|
|
```
|
|
|
|
|
2020-11-15 18:24:25 +00:00
|
|
|
### Versions
|
2020-11-14 01:38:56 +00:00
|
|
|
|
2020-11-15 18:24:25 +00:00
|
|
|
Versions should be placed inside *changes* folder with the following structure.
|
|
|
|
```text
|
2020-11-14 01:38:56 +00:00
|
|
|
changes
|
|
|
|
|- 00001-firstVersionCodeName
|
|
|
|
| |- 00-firstExecutedScript.sql
|
|
|
|
| |- 01-secondScript.sql
|
|
|
|
| `- 99-lastScript.sql
|
|
|
|
`- 00002-secondVersion
|
|
|
|
|- 00-firstExecutedScript.sql
|
|
|
|
`- 00-sameNumbers.sql
|
|
|
|
```
|
|
|
|
## Built With
|
|
|
|
|
|
|
|
* [Git](https://git-scm.com/)
|
|
|
|
* [nodejs](https://nodejs.org/)
|
|
|
|
* [docker](https://www.docker.com/)
|