PHPackages                             phphleb/migration - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. phphleb/migration

ActiveLibrary[Database &amp; ORM](/categories/database)

phphleb/migration
=================

Primitive migrations for the HLEB2 framework

v2.0.3(1y ago)3347↓25%2MITPHPPHP &gt;=8.2.0

Since Jan 8Pushed 1y ago1 watchersCompare

[ Source](https://github.com/phphleb/migration)[ Packagist](https://packagist.org/packages/phphleb/migration)[ RSS](/packages/phphleb-migration/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (13)Used By (2)

Basic migrations
================

[](#basic-migrations)

[![HLEB2](https://camo.githubusercontent.com/838b21da13ac6fa4384590a6a151d564a2832887c0a085cd911223d700ca379c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f484c45422d322d6461726b6379616e)](https://github.com/phphleb/hleb) [![PHP](https://camo.githubusercontent.com/b5d4f7901c58ad1ddfff679966f426cc25a9354bab763846b9a7276c2feab4e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e322d626c7565)](https://camo.githubusercontent.com/b5d4f7901c58ad1ddfff679966f426cc25a9354bab763846b9a7276c2feab4e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e322d626c7565) [![License: MIT](https://camo.githubusercontent.com/fdf4c838e998efe42a2cfb3c27b8addedc9f7ddd1ecfecc4b19254f784232b7a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542532302846726565292d627269676874677265656e2e737667)](https://github.com/phphleb/hleb/blob/master/LICENSE)

Basic migrations for the [HLEB2](https://github.com/phphleb/hleb) PHP framework.

These migrations implement a minimal set of standard actions, their main purpose is to execute prepared queries and record their execution in the database, preventing repetition. To achieve this, the framework must be connected to a database.

Support for **MySQL** / **MariaDB** / **PostgreSQL**

#### Installation

[](#installation)

```
composer require phphleb/migration
```

#### Deployment (when using the HLEB2 framework)

[](#deployment-when-using-the-hleb2-framework)

```
php console phphleb/migration add
```

#### Usage

[](#usage)

Next, you can create a migration template using the console command:

```
php console migration/create example_name
```

This command will create a new migration in the project's `database/migrations` (or migrations if it doesn't exist) folder with the name 'MigrationXXXexamplename.php' (where XXX index is the current UNIX time in milliseconds). If the `database/migrations` or `migrations` folder is not in the project root directory, you need to create it manually. If this folder is not suitable for you, you will need to rewrite the console command classes specifying the directory and use your own; deployment of the library in this case is optional. However, if a single database is used, these two location options should suffice (only one of them should be used).

In the 'MigrationXXXexamplename' class of the migration file, there is an up() method where one or more SQL queries can be added using the **addS**ql(...) method. Similarly, the **down**() method contains queries that roll back the **up**() method's execution. Be cautious with rolling back migrations, many do not use it, but if it is mandatory for the project, you must keep it up to date.

```
