You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+35-26Lines changed: 35 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,18 +4,22 @@ Super fast and lightweight DB migration & evolution tool written in go.
4
4
5
5
migrator manages all the DB changes for you and completely eliminates manual and error-prone administrative tasks. migrator not only supports single schemas, but also comes with a multi-tenant support.
6
6
7
-
migrator can run as a HTTP REST service. Further, there is a ready-to-go migrator docker image.
7
+
migrator run as a HTTP REST service.
8
+
9
+
Further, there is an official docker image available on docker hub. migrator docker image is ultra lightweight and has a size of 15MB. Ideal for micro-services deployments!
10
+
11
+
To find out more about migrator docker container see [DOCKER.md](DOCKER.md) for more details.
8
12
9
13
# Usage
10
14
11
15
migrator exposes a simple REST API which you can use to invoke different actions:
12
16
13
-
* GET /config - returns migrator config, response is `Content-Type: application/x-yaml`
14
-
* GET /diskMigrations - returns disk migrations, response is `Content-Type: application/json`
15
-
* GET /tenants - returns tenants, response is `Content-Type: application/json`
16
-
* POST /tenants - adds new tenant, name parameter is passed as JSON, returns applied migrations, response is `Content-Type: application/json`
17
-
* GET /migrations - returns all applied migrations
18
-
* POST /migrations - applies migrations, no parameters required, returns applied migrations, response is `Content-Type: application/json`
17
+
* GET /config - returns migrator config (`application/x-yaml`)
18
+
* GET /diskMigrations - returns disk migrations (`application/json`)
19
+
* GET /tenants - returns tenants (`application/json`)
20
+
* POST /tenants - adds new tenant, name parameter is passed as JSON parameter, returns applied migrations (`application/json`)
21
+
* GET /migrations - returns all applied migrations (`application/json`)
22
+
* POST /migrations - applies migrations, no parameters required, returns applied migrations (`application/json`)
Port is configurable in `migrator.yaml` and defaults to 8080. Should you need HTTPS capabilities I encourage you to use nginx/apache/haproxy for TLS offloading.
32
36
33
-
There is an official docker image available on docker hub. migrator docker image is ultra lightweight and has a size of 15MB. Ideal for micro-services deployments!
37
+
# Versions
34
38
35
-
To find out more about migrator docker container see [DOCKER.md](DOCKER.md) for more details.
39
+
Please navigate to https://github.com/lukaszbudnik/migrator/releases for a complete list of versions, features, and changes.
36
40
37
41
# Configuration
38
42
@@ -51,14 +55,20 @@ tenantSelectSQL: "select name from migrator.migrator_tenants"
51
55
tenantInsertSQL: "insert into migrator.migrator_tenants (name) values ($1)"
52
56
# optional, override only if you have a specific schema placeholder, default is:
53
57
schemaPlaceHolder: {schema}
54
-
# required, single schemas directories, these are subdirectories of baseDir
55
-
singleSchemas:
58
+
# required, directories of single schema SQL migrations, these are subdirectories of baseDir
59
+
singleMigrations:
56
60
- public
57
61
- ref
58
62
- config
59
-
# optional, tenant schemas directories, these are subdirectories of baseDir
60
-
tenantSchemas:
63
+
# optional, directories of tenant schemas SQL migrations, these are subdirectories of baseDir
64
+
tenantMigrations:
61
65
- tenants
66
+
# optional, directories of single SQL scripts which are applied always, these are subdirectories of baseDir
67
+
singleScripts:
68
+
- config-scripts
69
+
# optional, directories of tenant SQL script which are applied always for all tenants, these are subdirectories of baseDir
70
+
tenantScripts:
71
+
- tenants-scripts
62
72
# optional, default is:
63
73
port: 8080
64
74
# the webhook configuration section is optional
@@ -123,25 +133,22 @@ Currently migrator supports the following databases and their flavours:
123
133
124
134
You can apply your first migrations with migrator in literally a couple of minutes. There are some test migrations which are placed in `test/migrations` directory as well as some docker scripts for setting up test databases.
125
135
126
-
Let's start.
136
+
The quick start guide shows you how to either build the migrator locally or use the official docker image.
137
+
138
+
Steps 1 & 2 are required either way (migrator source code contains sample configuration & setup files together with some test migrations).
139
+
Step 3 is for building migrator locally, step 4 is for running the migrator container.
140
+
Step 5 is running examples and enjoying migrator ;)
127
141
128
142
## 1. Get the migrator project
129
143
130
-
For building migrator from source code `go get` is required:
144
+
Get the source code the usual go way:
131
145
132
146
```
133
147
go get -d -v github.com/lukaszbudnik/migrator
134
148
cd $GOPATH/src/github.com/lukaszbudnik/migrator
135
149
```
136
150
137
-
migrator supports the following Go versions: 1.8, 1.9, 1.10, and 1.11 (all built on Travis).
138
-
139
-
For running migrator on docker Go is not required and `git clone` is enough:
migrator aims to support 3 latest Go versions (built automatically on Travis).
145
152
146
153
## 2. Setup test DB container
147
154
@@ -153,7 +160,7 @@ migrator comes with helper scripts to setup test DB containers. Let's use postgr
153
160
154
161
Script will start container called `migrator-postgres`.
155
162
156
-
Further, apart of starting test DB container, the script also generates a ready-to-use test config file. We will use it too.
163
+
Further, apart of starting test DB container, the script also generates a ready-to-use test config file. We will use it later.
157
164
158
165
## 3. Build and run migrator
159
166
@@ -167,6 +174,8 @@ go build
167
174
168
175
> Note: There are 2 git variables injected into the production build (branch/tag and commit sha). When migrator is built like above it prints empty branch/tag and commit sha. This is OK for local development. If you want to inject proper values take a look at `Dockerfile` for details.
169
176
177
+
## 4. Run migrator from official docker image
178
+
170
179
When running migrator from docker we need to update `migrator.yaml` (generated in step 2) as well as provide a link to `migrator-postgres` container:
In above error requests we used `X-Request-Id` header. This header can be used with all requests for request tracing and/or auditing purposes.
208
+
In above error requests I used optional `X-Request-Id` header. This header can be used with all requests for tracing and/or auditing purposes.
200
209
201
210
# Customisation
202
211
@@ -254,7 +263,7 @@ The `ultimate-coverage.sh` script loops through 5 different containers (3 MySQL
254
263
255
264
# License
256
265
257
-
Copyright 2016-2018 Łukasz Budnik
266
+
Copyright 2016-2019 Łukasz Budnik
258
267
259
268
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
0 commit comments