S
S
Sergey Pugovkin2019-09-27 12:49:11
PHP
Sergey Pugovkin, 2019-09-27 12:49:11

How to create a migration file in byjg/migration-cli?

I don’t understand how https://github.com/byjg/migration-cli
works How to create a migration file, their structure looks like this:

<root dir>
     |
     +-- base.sql
     |
     +-- /migrations
              |
              +-- /up
                   |
                   +-- 00001.sql
                   +-- 00002.sql
              +-- /down
                   |
                   +-- 00000.sql
                   +-- 00001.sql

00000.sql
00001.sql
How to create them?
Suppose I made changes to the database, how can I add them to the migration?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Pugovkin, 2019-09-27
@Driver86

In short, you need to do it yourself:
https://github.com/byjg/migration/issues/21
Throw files like 00146.sql into the up and down folders with commands like DROP TABLE and CREATE TABLE

N
Nujabes37, 2019-09-27
@Nujabes37

Your script is wrong.
> Let's say I made changes to the database, how can I add them to the migration?
You create a migration that has two methods:
1. up - changing the structure of the database or table
2. down - rolling back these changes.
And the command to create an empty migration is in the documentation.
migrate create /path/to/sql

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question