https://github.com/trysharpen/versionna
Sharpen Versionna is a PHP migration system to manage versioning of Manticoresearch. It includes a CLI tool to keep your Manticore index schemas and your data on sync.
https://github.com/trysharpen/versionna
database database-migrations database-schema database-versioning full-text-search fulltext indexing manticore-search manticoresearch migration migration-automation migrations php search search-engine sql versioning
Last synced: 3 months ago
JSON representation
Sharpen Versionna is a PHP migration system to manage versioning of Manticoresearch. It includes a CLI tool to keep your Manticore index schemas and your data on sync.
- Host: GitHub
- URL: https://github.com/trysharpen/versionna
- Owner: trysharpen
- License: mit
- Created: 2022-05-15T10:10:15.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-12-31T10:45:55.000Z (over 3 years ago)
- Last Synced: 2025-10-25T13:31:31.300Z (5 months ago)
- Topics: database, database-migrations, database-schema, database-versioning, full-text-search, fulltext, indexing, manticore-search, manticoresearch, migration, migration-automation, migrations, php, search, search-engine, sql, versioning
- Language: PHP
- Homepage: https://trysharpen.com/versionna
- Size: 17.9 MB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# versionna
[](https://packagist.org/packages/Sharpen/versionna)
[](https://github.com/trysharpen/versionna/actions/workflows/tests.yml)
[](https://github.com/trysharpen/versionna/actions/workflows/phpstan.yml)
[](https://packagist.org/packages/Sharpen/versionna)
Manticoresearch migration tool. Keep updated your index schemas up to date using an executable CLI script or integrate it programmatically in your application code.

# Table of contents
- [versionna](#versionna)
- [Table of contents](#table-of-contents)
- [project progress and roadmap](#project-progress-and-roadmap)
- [Installation](#installation)
- [Usage](#usage)
- [Create migration](#create-migration)
- [CLI](#cli)
- [programmatically](#programmatically)
- [Apply migrations](#apply-migrations)
- [CLI](#cli-1)
- [programmatically](#programmatically-1)
- [Rollback migration](#rollback-migration)
- [CLI](#cli-2)
- [programmatically](#programmatically-2)
- [List migrations applied history](#list-migrations-applied-history)
- [CLI](#cli-3)
- [programmatically](#programmatically-3)
- [List pending migrations](#list-pending-migrations)
- [CLI](#cli-4)
- [programmatically](#programmatically-4)
## project progress and roadmap
- [x] Add CI pipeline
- [x] Add PHP versions supported
- [x] 8.0
- [x] 8.1
- [x] 8.2
- [x] PhpStan
- [x] PHPUnit run tests
- Pre-commit linter and tests checks
- [x] Add Grumphp
- [x] PHPStan
- [x] PHPUnit
- [ ] Add a logger implementation
- [x] Add docker-compose stack files for testing and development
- [ ] Add code documentation
- [x] Write a complete README file explaining all
- [ ] Add unit and integration tests
- [x] Add command line interface feature
- [x] Add cli application metadata such as name, description, etc.
- [x] Created structure of the CLI application
- [x] Executable script (bin/versionna)
- [ ] Add commands
- [x] list
- [ ] make:config
- [x] make:migration
- [x] migration:list:pending
- [x] migration:list:migrated
- [x] migrate
- [x] rollback
- [ ] rollback with --steps
- [x] fresh
- [ ] refresh
- [ ] refresh with --steps
- [ ] reset
- [ ] status
- [x] help
- [x] Add drivers to support multiple DBs engines dialects
- [x] Add driver for SQLite
- [x] Add driver for MySQL
- [x] Add driver for PostgreSQL
- [ ] Create a Laravel package
- [ ] Create a Symfony package
## Installation
```sh
composer require sharpen/versionna
```
## Usage
First of all, you need to install the package.
```sh
composer require sharpen/versionna
```
After been installed, you need to create a directory.
That directory will contain the migration files sorted by creation date.
You have two different ways to use this package:
- programmatically
- CLI
You can create your own integration with `versionna` using the programmatically way as you can see in hte **examples** directory in this repository.
In each section of these documentation you will see both: programmatically and CLI version to create, migrate, rollback, list applied and pending migrations.
### Create migration
#### CLI
To create a migration file you have to use the make:migration and the class name (the migration class name that extends Migration class) using
snake_case_style.
This class name should be a descriptive name. It's better a long name for two reasons:
- to better understand what the migration does
- and for avoid duplicated class names
```sh
./vendor/bin/versionna make:migration -c config.php create_products_index
```
#### programmatically
```php
create();
echo 'Migration created successfully';
```
### Apply migrations

#### CLI
There are two available commands for apply pending migrations using the Command Line Interface
```sh
./vendor/bin/versionna migrate -c config.php
```
```sh
./vendor/bin/versionna migrate:up -c config.php
```
#### programmatically
```php
dbConnection($dbConnection)
->manticoreConnection($manticoreConnection)
->migrationsPath($configuration['migrations_path'])
->migrationTable($migrationTable);
if (! $migrationTable->exists()) {
echo 'Migration table doesn\'t exist';
exit(1);
} elseif (! $director->hasPendingMigrations()) {
echo 'No pending migrations';
exit(0);
}
try {
$director->migrate();
} catch (Exception $exception) {
echo $exception->getMessage();
exit(1);
}
echo 'Applied all migrations';
```
### Rollback migration

#### CLI
There are two available commands to rollback applied migrations using the Command Line Interface
```sh
./vendor/bin/versionna rollback -c config.php
```
```sh
./vendor/bin/versionna migrate:down -c config.php
```
#### programmatically
```php
dbConnection($dbConnection)
->manticoreConnection($manticoreConnection)
->migrationsPath($configuration['migrations_path'])
->migrationTable($migrationTable);
$steps = 1;
$director->undoMigrations($steps);
```
### List migrations applied history

#### CLI
For list pending migrations using the Command Line tool
```sh
./vendor/bin/versionna migration:list:pending -c config.php
```
#### programmatically
```php
getAll($ascending);
if ($migrations) {
$migrationsDone = array_map(
function ($migration) {
return $migration->toArray();
},
$migrations,
);
var_dump($migrationsDone);
} else {
echo 'The migration table is empty';
}
```
### List pending migrations

#### CLI
For list pending migrations using the Command Line tool
```sh
./vendor/bin/versionna migration:list:pending -c config.php
```
#### programmatically
```php
dbConnection($dbConnection)
->manticoreConnection($manticoreConnection)
->migrationsPath($configuration['migrations_path'])
->migrationTable($migrationTable);
$pendingMigrations = $director->getPendingMigrations();
if (count($pendingMigrations) > 0) {
array_map(
function ($migration) {
return ['name' => $migration];
},
array_values(array_keys($pendingMigrations)),
);
} else {
echo 'ManticoreSearch is up to date! no pending migrations';
}
```