Skip to content

Commit

Permalink
Merge pull request #2 from MarceloHoffmeister/enhancement/update
Browse files Browse the repository at this point in the history
Add more updates
  • Loading branch information
MarceloHoffmeister authored Apr 29, 2020
2 parents 4237989 + b3d0dc2 commit 9f0d4e4
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 50 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/vendor
.idea
10 changes: 10 additions & 0 deletions .idea/composerJson.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/migrator.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Migrator is based on the original laravel/framework migrator system.
Migrator is based on the original artesaos/migrator migrator lib.
Here is a copy of the original license.
----------------------------------------------------------------------------
The MIT License (MIT)
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "artesaos/migrator",
"description": "Namespaced Migrations for Laravel 5.1+",
"name": "marcelohoffmeister/migrator",
"description": "Namespaced Migrations for Laravel 6.0+",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Diego Hernandes",
"email": "diego@hernandev.com"
"name": "Marcelo Hoffmeister",
"email": "marcelohenriquehoffmeister@gmail.com"
}
],
"minimum-stability": "stable",
Expand Down
62 changes: 17 additions & 45 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# artesaos/migrator

# marcelohoffmeister/migrator

[![Latest Stable Version](https://poser.pugx.org/artesaos/migrator/v/stable)](https://packagist.org/packages/artesaos/migrator) [![Total Downloads](https://poser.pugx.org/artesaos/migrator/downloads)](https://packagist.org/packages/artesaos/migrator) [![Monthly Downloads](https://poser.pugx.org/artesaos/migrator/d/monthly)](https://packagist.org/packages/artesaos/migrator) [![License](https://poser.pugx.org/artesaos/migrator/license)](https://packagist.org/packages/artesaos/migrator)

Expand All @@ -10,19 +11,18 @@ There is no timestamp previews since the run order is based on how you register
This Package Supports Laravel starting on 5.2 up to the latest stable version.

### Installing

In order to install Migrator, run the following command into your Laravel 5.2+ project:
In order to install Migrator, run the following command into your Laravel 6.0+ project:

```
composer require artesaos/migrator
composer require marcelohoffmeister/migrator
```

After installing the Package, you can now register it's provider into your config/app.php file:

```php
'providers' => [
// other providers omitted.
Migrator\MigrationServiceProvider::class,
Migrator\MigrationServiceProvider::class,
]
```

Expand All @@ -32,20 +32,6 @@ And publish configuration: with
php artisan vendor:publish --provider="Migrator\MigrationServiceProvider"
```

### Upgrading from v1.x to v2.0.

On v1.x, this package uses the same table name as the default migration engine.

On version v2, there is a separate table used for tracking migrations, and it defaults to: `migrator_table`

If you are upgrading from v1, you may either rename the `migrations` table to `migrator_table` **OR**
publish the config file and set the migrator table name to `migrations`.

Either should work.

v2 works alongside default migrations, for projects who want to namespace migrations
but already have many migrations in place.

### Usage

As the default Laravel migrator, this one has all the original commands, to list the available options, you can see all the available options using `php artisan` command.
Expand All @@ -61,11 +47,7 @@ migrator:rollback Rollback the last database migration
migrator:status Show the status of each migration
```




#### Creating Migrations

In order to generate an empty migration, please provide the migrator with the full qualified class name, as the example.

`php artisan migrator:make 'MyApp\MyModule\Database\Migrations\CreateOrdersTable' --create=orders`
Expand All @@ -83,24 +65,18 @@ use Illuminate\Database\Migrations\Migration;
class CreateOrdersTable extends Migration
{
/**
* @var \Illuminate\Database\Schema\Builder
*/
protected $schema;
* @var \Illuminate\Database\Schema\Builder
*/ protected $schema;

/**
* Migration constructor.
*/
public function __construct()
* Migration constructor. */ public function __construct()
{
$this->schema = app('db')->connection()->getSchemaBuilder();
}

/**
* Run the migrations.
*
* @return void
*/
public function up()
* Run the migrations. * * @return void
*/ public function up()
{
$this->schema->create('orders', function (Blueprint $table) {
$table->increments('id');
Expand All @@ -109,11 +85,8 @@ class CreateOrdersTable extends Migration
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
* Reverse the migrations. * * @return void
*/ public function down()
{
$this->schema->drop('orders');
}
Expand All @@ -124,15 +97,16 @@ To declare your table fields, just follow the usual schema build practices, this

As the normal migrator, you can pass the option `--table` instead of `--create` in order to generate a update migration instead of a create one. Also, you can create a empty migration not passing any of those options.

#### Registering migrations.
**In this fork, you can pass the option --path for the fresh command. This execute the command in the specific path.**

#### Registering migrations.
Inside any service provider of your choice (usually on the same namespace that you're storing the migrations), you easily register the migrations using the *`Migrator\MigratorTrait`*:

```php
<?php

namespace MyApp\MyModule\Providers;

use Illuminate\Support\ServiceProvider;
use Migrator\MigratorTrait;
use MyApp\MyModule\Database\Migrations\CreateOrdersTable;
Expand All @@ -141,7 +115,7 @@ use MyApp\MyModule\Database\Migrations\CreateProductsTable;
class MyModuleServiceProvider extends ServiceProvider
{
use MigratorTrait;

public function register()
{
$this->migrations([
Expand All @@ -150,6 +124,4 @@ class MyModuleServiceProvider extends ServiceProvider
]);
}
}
```


```

0 comments on commit 9f0d4e4

Please sign in to comment.