Skip to content

Commit bcea673

Browse files
committed
Update documentation
1 parent f06a67d commit bcea673

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,48 @@
11
# simple-db-migrator
22
A simple database migration tool written in PHP
3+
4+
# Quick introduction.
5+
6+
1. This is a simple database migration commandline application written in php.
7+
2. It has following dependencies.
8+
* `symfony/console` for argument parsing ( of cli interface )
9+
* `psr/log` for managing and priting log messages.
10+
3. Contents of each SQL file is run as single transaction.
11+
4. The migrator tool will save the `down` migration (rollback SQL statement) in DB and cross verify it with the current version of the rollback SQL statement present in the disk and complain if both are different.
12+
13+
# Usage
14+
15+
Migrations are arranged in the following directory structure.
16+
```
17+
├── migrations
18+
│   ├── down
19+
│   │   ├── 001.sql
20+
│   │   ├── 002.sql
21+
│   │   ├── 003.sql
22+
│   │   └── 004.sql
23+
│   └── up
24+
│   ├── 001.sql
25+
│   ├── 002.sql
26+
│   ├── 003.sql
27+
│   └── 004.sql
28+
└── simple-db-migrator.php
29+
30+
```
31+
32+
To create a new migration, Just create respective `xxx.sql` file in `up` and `down` directories.
33+
34+
## Run initial migration ( ie, create db_migration table )
35+
```bash
36+
# '-s' option stands for 'setup'
37+
php simple-db-migrator.php -s
38+
```
39+
40+
## Apply all pending migrations ( up )
41+
```bash
42+
php simple-db-migrator.php -u
43+
```
44+
45+
## Rollback last migration ( down )
46+
```bash
47+
php simple-db-migrator.php -d
48+
```

0 commit comments

Comments
 (0)