db-evo 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -11
- package/package.json +1 -1
package/README.md
CHANGED
@@ -38,9 +38,13 @@ migrations/
|
|
38
38
|
│ └── 01-create-posts.sql
|
39
39
|
```
|
40
40
|
|
41
|
-
2. Configure database connection in
|
41
|
+
2. Configure database connection in `.db-evorc.yaml`:
|
42
42
|
|
43
43
|
```yaml
|
44
|
+
patch: "00"
|
45
|
+
env: "default"
|
46
|
+
roots:
|
47
|
+
- "~/workspace/projects/myapp/db/migrations"
|
44
48
|
pg:
|
45
49
|
default:
|
46
50
|
dbname: myapp
|
@@ -52,8 +56,10 @@ pg:
|
|
52
56
|
|
53
57
|
3. Deploy migrations:
|
54
58
|
|
59
|
+
Run command from folder, where `.db-evorc.yaml` file placed.
|
60
|
+
|
55
61
|
```bash
|
56
|
-
db-evo deploy
|
62
|
+
db-evo deploy --env=production
|
57
63
|
```
|
58
64
|
|
59
65
|
## Commands
|
@@ -68,13 +74,18 @@ db-evo deploy
|
|
68
74
|
|
69
75
|
## Configuration
|
70
76
|
|
71
|
-
Create
|
77
|
+
Create `.db-evorc.yaml` files to configure migrations:
|
72
78
|
|
73
79
|
```yaml
|
74
80
|
# Root configuration
|
81
|
+
patch: "01" # Latest migration
|
82
|
+
env: "default"
|
83
|
+
engine: "pg" # Only supported
|
84
|
+
roots: # Each migration is a folder, so let's specify the root dir
|
85
|
+
- "~/workspace/projects/myapp/db/migrations"
|
75
86
|
pg:
|
76
87
|
default:
|
77
|
-
dbname:
|
88
|
+
dbname: myapp_dev
|
78
89
|
host: localhost
|
79
90
|
port: 5432
|
80
91
|
username: postgres
|
@@ -82,29 +93,34 @@ pg:
|
|
82
93
|
production:
|
83
94
|
dbname: myapp_prod
|
84
95
|
host: prod.example.com
|
96
|
+
```
|
85
97
|
|
98
|
+
Create `~/workspace/projects/myapp/db/migrations/01/db-evo.yaml` file to configure migration:
|
99
|
+
|
100
|
+
```yaml
|
86
101
|
# Per-migration configuration
|
87
|
-
depends: ["00"] # Require patch 00 before applying
|
88
|
-
includes: ["shared"] # Include shared migrations
|
102
|
+
depends: ["00"] # Require patch 00 before applying (optional)
|
103
|
+
includes: ["shared"] # Include shared migrations (optional)
|
89
104
|
```
|
90
105
|
|
91
106
|
## Migration Structure
|
92
107
|
|
93
|
-
Each migration patch follows this structure:
|
108
|
+
Each migration patch follows this structure (see `roots` config parameter):
|
94
109
|
|
95
110
|
```text
|
96
111
|
patch-name/
|
97
|
-
├── db-evo.yaml #
|
98
|
-
├── vars.yaml # Variables for templates (optional)
|
112
|
+
├── db-evo.yaml # Migration configuration
|
99
113
|
├── deploy/ # Forward migration scripts
|
100
114
|
│ ├── 01.sql
|
101
115
|
│ └── 02.sql
|
102
|
-
├── revert/ # Rollback scripts
|
116
|
+
├── revert/ # Rollback scripts
|
103
117
|
│ └── 01.sql
|
104
|
-
└── verify/ # Verification scripts
|
118
|
+
└── verify/ # Verification scripts
|
105
119
|
└── 01.sql
|
106
120
|
```
|
107
121
|
|
122
|
+
Each SQL script must be a valid script for `psql`.
|
123
|
+
|
108
124
|
## Options
|
109
125
|
|
110
126
|
- `--env <env>` - Target environment (default: "default")
|