Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tuxboy/sdam
Manage the database migrations for your PHP app
https://github.com/tuxboy/sdam
automatic fast migration mysql-database php
Last synced: 10 days ago
JSON representation
Manage the database migrations for your PHP app
- Host: GitHub
- URL: https://github.com/tuxboy/sdam
- Owner: TuxBoy
- Created: 2018-07-14T15:34:38.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-23T08:15:18.000Z (about 6 years ago)
- Last Synced: 2024-11-10T00:38:00.439Z (10 days ago)
- Topics: automatic, fast, migration, mysql-database, php
- Language: PHP
- Homepage:
- Size: 63.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/TuxBoy/SDAM.svg?branch=master)](https://travis-ci.org/TuxBoy/Migration)
# SDAM (Simple Database Auto Migration)
Manage the database migrations for your PHP app, this library was made for your migration to be launched
automatically in your applicationThere is a demo of use [here](https://github.com/TuxBoy/Migration-demo)
## Installation
````json
"require": {
"tuxboy/sdam": "dev-master",
},
"repositories": [
{
"type": "vcs",
"url": "[email protected]:tuxboy/sdam.git"
}
],
````OR with packagist
```bash
$ composer require tuxboy/sdam
```## How to use it
````php
\SDAM\Config::current()->configure(
[
\SDAM\Config::DATABASE => [
'dbname' => 'database_name',
'user' => 'root',
'password' => '',
'host' => 'localhost',
'driver' => 'pdo_mysql',
], // OR use .env for the database config
\SDAM\Config::ENV_FILE => 'path/your/.env'
\SDAM\Config::ENTITY_PATH => 'App\Entity\\',
\SDAM\Config::AUTO_DROP_FIELD => false, // Optional (default value is true)
]
);// Run migration engine in your app
$maintainer = new Maintainer([Entity::class]);
$maintainer->run();// OR use middleware class
$maintainer = new \SDAM\Middleware\MaintainerMiddleware([\App\Entity\Post::class], $config);
$app->pipe($maintainer);
````Middleware are constructed with these parameters
* Entities list, **string[]**
* $config, **string[]**## Usage
Create your Entity class, Post entity for example :
```php
namespace App\Entity;/**
* Post
*
* @storeName custom_table_name
*/
class Post
{/**
* @length 60
* @var string
*/
public $name;/**
* @var string
*/
public $slug;/**
* @store false
* @var string
*/
public $tmp_property;/**
* @text
* @var string
*/
public $content;
}
```
(*You can see the list of possible annotations in the class AnnotationsName*)Just start the migration, either by a simple F5 if you have it enabled in your application (middleware) or other.
The table will be created in your database.## Todo
- [X] Manage relationship belongsToMany
- [ ] Better manage the tables that already exist when creating (Delete php warning)
- [ ] Completed the factory system.