Simple Database CLI Migration Tools.
Only
- MySQL
Reflects the developer's view of religion.
$ go get github.com/lrf141/europa
// require
$ mkdir migrations
$ vim migrations/db.yaml
example yaml file.
database: sample
host: 127.0.0.1
port: 33068
user: sample
pass: sample
Run the following command. Create Raw SQL Files.
$ europa create:migrate --name "migration name"
ex)
$ europa create:migrate -n "sample_migrate"
Create Migrate: ./migrations/migrate/20191028120501_sample_migrate.up.sql [Success]
Create Migrate: ./migrations/migrate/20191028120501_sample_migrate.down.sql [Success]
$ europa run:migrate
or
$ europa run:migrate --name 20191028120501_sample_migrate
$ europa rollback:migrate
or
$ europa rollback:migrate --name 20191028120501_sample_migrate
$ europa create:seed --name "seed name"
ex)
$ europa create:seed -n "sample_seed"
Create Migrate: ./migrations/seed/20191028120501_sample_seed.up.sql [Success]
Create Migrate: ./migrations/seed/20191028120501_sample_seed.down.sql [Success]
$ europa run:seed
or
$ europa run:seed --name 20191028120501_sample_seed
$ europa rollback:seed
or
$ europa rollback:seed --name 20191028120501_sample_seed
Manage Migrate
> desc migrate_schema;
+---------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------+------------+------+-----+---------+-------+
| migrate | text | YES | | NULL | |
| flag | tinyint(1) | YES | | 0 | |
+---------+------------+------+-----+---------+-------+
ex)
> select * from migrate_schema;
+----------------------------------+------+
| migrate | flag |
+----------------------------------+------+
| 20191027021931_test_table_create | 0 |
| 20191028120501_sample_migrate | 0 |
+----------------------------------+------+
2 rows in set (0.00 sec)
migrate : Migration Name
flag = 1 : Migration Completed
flag = 0 : Migration UnCompleted
> desc seed_schema;
+-------+------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+-------+
| seed | text | YES | | NULL | |
| flag | tinyint(1) | YES | | 0 | |
+-------+------------+------+-----+---------+-------+
2 rows in set (0.00 sec)
seed : Seed Name
flag = 1 : Seed Completed
flag = 0 : Seed UnCompleted
MIT License