PHPackages                             shasoft/db-schema - 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. shasoft/db-schema

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

shasoft/db-schema
=================

Versioning/migrating database changes

v2.0.1(2y ago)1302MITPHP

Since Dec 29Pushed 2y ago1 watchersCompare

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

READMEChangelog (5)Dependencies (5)Versions (6)Used By (2)

Версионная миграция структуры базы данных через PHP атрибуты
------------------------------------------------------------

[](#версионная-миграция-структуры-базы-данных-через-php-атрибуты)

Простой пример определения таблицы БД:

```
#[Title('Таблица для примера')]
class TabExample
{
    #[Title('Идентификатор')]
    protected ColumnId $id;
    #[Title('Имя')]
    protected ColumnString $name;
    // Первичный ключ
    #[Columns('id')]
    protected IndexPrimary $pkKey;
}
```

В данном примере через класс TabExample определяется таблица, содержащая два поля и один индекс. Миграции для указанного примера создаются следующим образом:

```
    // Получить миграции
    $migrations = DbSchemaMigrations::get([
            // Класс таблицы
            TabExample::class,
        ],
        // Драйвер для получения миграций
        DbSchemaDriverMySql::class
    );
    // Создать PDO соединение
    $pdo = new \PDO(
        'mysql:dbname=cmg-db-test;host=localhost',
        'root'
    );
    // Выполнить миграции
    $migrations->run($pdo);
```

В результате выполнения миграций в БД создастся таблица БД с помощью следующего SQL кода

```
CREATE TABLE `tabexample`(
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Идентификатор',
    `name` VARCHAR(255) NULL COMMENT 'Имя',
    PRIMARY KEY(`id`) USING BTREE
) COMMENT 'Таблица для примера';
```

Можно отменить последнии миграции с помощью следующего кода

```
// Отменить последнии миграции
$migrations->cancel($pdo);
```

эти миграции будут отменены с помощью следующего SQL кода

```
DROP TABLE IF EXISTS
    `tabexample`
```

[Подробнее](docs/index.md)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Total

5

Last Release

847d ago

Major Versions

v1.0.2 → v2.02024-01-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/ff2e881a6fbb7a667371c481ae1455d87d4a8c35cd19f23bcd7e8be9eaa65886?d=identicon)[shasoft](/maintainers/shasoft)

---

Tags

schemamigrationdatabaseversioning

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/shasoft-db-schema/health.svg)

```
[![Health](https://phpackages.com/badges/shasoft-db-schema/health.svg)](https://phpackages.com/packages/shasoft-db-schema)
```

###  Alternatives

[odan/phinx-migrations-generator

Migration generator for Phinx

235847.8k23](/packages/odan-phinx-migrations-generator)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[dragon-code/laravel-data-dumper

Adding data from certain tables when executing the `php artisan schema:dump` console command

3418.6k](/packages/dragon-code-laravel-data-dumper)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
