README, exit code on error
This commit is contained in:
parent
24b35e2e90
commit
801b6e9539
129
README.md
129
README.md
|
@ -4,9 +4,7 @@ Utilities to ease the maintenance of MySQL or MariaDB database versioning using
|
||||||
a Git repository.
|
a Git repository.
|
||||||
|
|
||||||
This project is just to bring an idea to life and is still in an early stage of
|
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.
|
development, so any help is welcomed! Feel free to contribute.
|
||||||
|
|
||||||
Any help is welcomed! Feel free to contribute.
|
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
|
@ -35,7 +33,7 @@ $ npx myvc [command]
|
||||||
Execute *myvc* with the desired command.
|
Execute *myvc* with the desired command.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
$ myvc [-w|--workspace] [-r|--remote] [-d|--debug] [-h|--help] command
|
$ myvc [-w|--workspace] [-r|--remote] [-d|--debug] [-h|--help] command [args]
|
||||||
```
|
```
|
||||||
|
|
||||||
The default workspace directory is the current working directory and unless
|
The default workspace directory is the current working directory and unless
|
||||||
|
@ -44,7 +42,7 @@ otherwise indicated, the default remote is *local*.
|
||||||
Database versioning commands:
|
Database versioning commands:
|
||||||
|
|
||||||
* **init**: Initialize an empty workspace.
|
* **init**: Initialize an empty workspace.
|
||||||
* **pull**: Incorporates database routines changes into workspace.
|
* **pull**: Incorporate database routine changes into workspace.
|
||||||
* **push**: Apply changes into database.
|
* **push**: Apply changes into database.
|
||||||
* **version**: Creates a new version.
|
* **version**: Creates a new version.
|
||||||
|
|
||||||
|
@ -56,6 +54,84 @@ Local server management commands:
|
||||||
|
|
||||||
Each command can have its own specific commandline options.
|
Each command can have its own specific commandline options.
|
||||||
|
|
||||||
|
## Versioning commands
|
||||||
|
|
||||||
|
### init
|
||||||
|
|
||||||
|
Initializes an empty workspace.
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ myvc init
|
||||||
|
```
|
||||||
|
|
||||||
|
### pull
|
||||||
|
|
||||||
|
Incorporates database routine changes into workspace.
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ myvc pull [remote] [-f|--force] [-c|--checkout]
|
||||||
|
```
|
||||||
|
|
||||||
|
When *checkout* option is provided, it does the following steps:
|
||||||
|
|
||||||
|
1. Saves the current HEAD.
|
||||||
|
2. Check out to the last database push commit (saved in versioning tables).
|
||||||
|
3. Creates and checkout to a new branch.
|
||||||
|
4. Exports database routines.
|
||||||
|
5. Commits the new changes.
|
||||||
|
6. Checkout to the original HEAD.
|
||||||
|
7. Merge the new branch into.
|
||||||
|
8. Let the user deal with merge conflicts.
|
||||||
|
|
||||||
|
### push
|
||||||
|
|
||||||
|
Applies versions and routine changes into database.
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ myvc push [remote] [-f|--force] [-u|--user]
|
||||||
|
```
|
||||||
|
|
||||||
|
### version
|
||||||
|
|
||||||
|
Creates a new version folder, when name is not specified it generates a random
|
||||||
|
name mixing color with plant name.
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ myvc version [name]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Local server commands
|
||||||
|
|
||||||
|
### dump
|
||||||
|
|
||||||
|
Exports database structure and fixtures from remote into hidden files located
|
||||||
|
in *dump* folder.
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ myvc dump [remote]
|
||||||
|
```
|
||||||
|
|
||||||
|
### run
|
||||||
|
|
||||||
|
Builds and starts local database server container. It only rebuilds the image
|
||||||
|
when fixtures have been modified or when the day on which the image was built
|
||||||
|
is different to today.
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ myvc run [-c|--ci] [-r|--random]
|
||||||
|
```
|
||||||
|
|
||||||
|
### start
|
||||||
|
|
||||||
|
Starts local database server container. It does the minium effort, if it
|
||||||
|
doesn't exists calls the run command, if it is started does nothing. Keep in
|
||||||
|
mind that when you do not rebuild the docker you may be using an outdated
|
||||||
|
version of it.
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ myvc start
|
||||||
|
```
|
||||||
|
|
||||||
## Basic information
|
## Basic information
|
||||||
|
|
||||||
First of all you have to initalize your workspace.
|
First of all you have to initalize your workspace.
|
||||||
|
@ -78,14 +154,6 @@ names are *production* and *test*.
|
||||||
remotes/[remote].ini
|
remotes/[remote].ini
|
||||||
```
|
```
|
||||||
|
|
||||||
### Dumps
|
|
||||||
|
|
||||||
Structure and fixture dumps will be created into hidden file *dump/.dump.sql*.
|
|
||||||
You can also create your local fixture and structure files.
|
|
||||||
|
|
||||||
* *dump/structure.sql*
|
|
||||||
* *dump/fixtures.sql*
|
|
||||||
|
|
||||||
### Routines
|
### Routines
|
||||||
|
|
||||||
Routines should be placed inside *routines* folder. All objects that have
|
Routines should be placed inside *routines* folder. All objects that have
|
||||||
|
@ -109,7 +177,7 @@ triggers and views with the following structure.
|
||||||
|
|
||||||
### Versions
|
### Versions
|
||||||
|
|
||||||
Versions should be placed inside *versions* folder with the following structure.
|
Versions are placed inside *versions* folder with the following structure.
|
||||||
Don't place your PL/SQL objects here, use the routines folder!
|
Don't place your PL/SQL objects here, use the routines folder!
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
@ -125,10 +193,16 @@ Don't place your PL/SQL objects here, use the routines folder!
|
||||||
|
|
||||||
### Local server
|
### Local server
|
||||||
|
|
||||||
The local server will be created as a MariaDB Docker container using the base
|
The local server is created as a MariaDB Docker container using the base dump created with the *dump* command plus pushing local versions and changed
|
||||||
dump created with the *dump* command plus pushing local versions and changed
|
|
||||||
routines.
|
routines.
|
||||||
|
|
||||||
|
## Dumps
|
||||||
|
|
||||||
|
You can create your local fixture and structure files.
|
||||||
|
|
||||||
|
* *dump/structure.sql*
|
||||||
|
* *dump/fixtures.sql*
|
||||||
|
|
||||||
## Why
|
## Why
|
||||||
|
|
||||||
The main reason for starting this project it's because there are no fully free
|
The main reason for starting this project it's because there are no fully free
|
||||||
|
@ -140,25 +214,10 @@ a small project.
|
||||||
|
|
||||||
## Todo
|
## Todo
|
||||||
|
|
||||||
Improve the pull command to, instead of completely overwriting the routines
|
* Improve *help* option for commands.
|
||||||
directory, merge the database changes with the local SQL files. It is possible
|
* Allow to specify a custom workspace subdirectory inside project directory.
|
||||||
using a library that allows to manipulate git repositories (nodegit) and running
|
* Create a lock during push to avoid collisions.
|
||||||
the following steps:
|
* Use a custom *Dockerfile* for local database container.
|
||||||
|
|
||||||
1. Save the current HEAD.
|
|
||||||
2. Check out to the last database push commit (saved in versioning tables).
|
|
||||||
3. Create and checkout to a new branch.
|
|
||||||
4. Export database routines.
|
|
||||||
5. Commit the new changes.
|
|
||||||
5. Checkout to the original HEAD.
|
|
||||||
6. Merge the new branch into.
|
|
||||||
7. Let the user deal with merge conflicts.
|
|
||||||
|
|
||||||
Use a custom *Dockerfile* for local database container.
|
|
||||||
|
|
||||||
Allow to specify a custom workspece subdirectory inside project directory.
|
|
||||||
|
|
||||||
Create a lock during push to avoid collisions.
|
|
||||||
|
|
||||||
## Built With
|
## Built With
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,6 @@ class Dump {
|
||||||
get localOpts() {
|
get localOpts() {
|
||||||
return {
|
return {
|
||||||
operand: 'remote',
|
operand: 'remote',
|
||||||
alias: {
|
|
||||||
remote: 'r'
|
|
||||||
},
|
|
||||||
default: {
|
default: {
|
||||||
remote: 'production'
|
remote: 'production'
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,6 @@ class Version {
|
||||||
throw new Error('Version name can only contain letters or numbers');
|
throw new Error('Version name can only contain letters or numbers');
|
||||||
if (versionNames.has(versionName))
|
if (versionNames.has(versionName))
|
||||||
throw new Error('Version with same name already exists');
|
throw new Error('Version with same name already exists');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create version
|
// Create version
|
||||||
|
|
5
myvc.js
5
myvc.js
|
@ -89,9 +89,10 @@ class MyVC {
|
||||||
await command.run(this, opts);
|
await command.run(this, opts);
|
||||||
await this.unload();
|
await this.unload();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err.name == 'Error' && !opts.debug)
|
if (err.name == 'Error' && !opts.debug) {
|
||||||
console.error('Error:'.gray, err.message.red);
|
console.error('Error:'.gray, err.message.red);
|
||||||
else
|
process.exit(1);
|
||||||
|
} else
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "myvc",
|
"name": "myvc",
|
||||||
"version": "1.1.12",
|
"version": "1.1.13",
|
||||||
"author": "Verdnatura Levante SL",
|
"author": "Verdnatura Levante SL",
|
||||||
"description": "MySQL Version Control",
|
"description": "MySQL Version Control",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
|
|
Loading…
Reference in New Issue