CodefyPHP FrameworkCodefyPHP Framework
  • Home
  • Community
    • Forum
    • Github
    • YouTube
  • News
  • Home
  • Community
    • Forum
    • Github
    • YouTube
  • News
home/Knowledge Base/Qubus/Migrations
Popular Search:installation, codex, mail

Migrations

39 views 0

Written by Joshua
August 14, 2024

In the skeleton starter app, a config file for database migrations can be found at bootstrap/phpmig.php. Codefy Migrations is a fork of phpmig.

Getting Started

You can generate migrations by using the migrate:generate command. Migration files follow this naming convention: versionnumber_name.php, where version number is made of 0-9 and name is CamelCase or snake_case. Each migration file should contain a class with the same name as the file in CamelCase.

❯ php codex migrate:generate CreateTemplateTable
+f ./database/migrations/20230908035134_CreateTemplateTable.php

❯ php codex migrate:status
+--------+------------------+-----------------------+                                                                                                                 
| Status | Migration ID     | Migration Name        |
+--------+------------------+-----------------------+
| down   |  20230908035134  | CreateTemplateTable   |
+--------+------------------+-----------------------+

❯ php codex migrate
 == 20230908035134 CreateTemplateTable migrating
 == 20230908035134 CreateTemplateTable migrated 0.0090s

❯ php codex migrate:status
+--------+------------------+-----------------------+                                                                                                                  
| Status | Migration ID     | Migration Name        |
+--------+------------------+-----------------------+
| up     |  20230908035134  | CreateTemplateTable   |
+--------+------------------+-----------------------+

Rollback

Rollback the last run migration:

❯ php codex migrate:rollback 

To rollback all migrations up to a specific migration you can specify the rollback target:

❯ php codex migrate:rollback -t 20220925064056
// or
❯ php codex migrate:rollback --target 20220925064056

Revert all migrations by specifying 0:

❯ php codex migrate:rollback -t 0

You can also rollback a specific migration using the down command:

❯ php codex migrate:down 20220925064056
Edit on Github

Last Updated on August 14, 2024 by Joshua

Related Articles
  • Mailer
  • Logger
  • Filesystem
  • Database
  • Event Dispatcher
  • Routing

Didn't find your answer? Check out the Forum

Leave A Comment Cancel reply

You must be logged in to post a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Database

Filesystem  

  • Copyright 2025 CodefyPHP.com. All Rights Reserved

Popular Search:installation, codex, mail