migration file name bug fixed

This commit is contained in:
Amine Ben hammou 2015-10-07 17:37:17 +01:00
parent 4b66c5af88
commit ce54fe6d5a
25 changed files with 37 additions and 459 deletions

View File

@ -19,7 +19,7 @@ A collection of generators for [Lumen](http://lumen.laravel.com) and [Laravel 5]
- [Migration Generator](#migration-generator)
- [Pivot Table Generator](#pivot-table-generator)(New on version 1.1.0)
- [Pivot Table Generator](#pivot-table-generator) (Since version 1.1.0)
- [Controller Generator](#controller-generator)
@ -31,6 +31,8 @@ A collection of generators for [Lumen](http://lumen.laravel.com) and [Laravel 5]
- [Testing](#testing)
- [Development Notes](#development_notes)
- [Contributing](#contributing)
## Why ?
@ -365,7 +367,7 @@ wn:migration table [--schema=...] [--keys=...] [--file=...]
- **table**: the name of the table to create.
- **--file**: The migration file name. By default the name follows the patern `date_time_create_table_name.php`.
- **--file**: The migration file name (to speicify only for testing purpose). By default the name follows the patern `date_time_create_tableName_table.php`.
- **--schema**: the schema of the table using the syntax `field1:type.arg1,ag2:modifier1:modifier2.. field2:...`. The `type` could be `text`, `string.50`, `decimal.5,2` for example. Modifiers can be `unique` or `nullable` for example. [See documentation](http://laravel.com/docs/5.1/migrations#creating-columns) for the list of available types and modifiers.
@ -602,6 +604,34 @@ Product:
To test the generators, I included a fresh lumen installation under the folder `lumen-test` to which I added this package and have written some acceptance tests using [Codeception](http://codeception.com/). To run tests you just have to execute the `install.sh` to install dependencies then execute `test.sh`.
## Development Notes
- **Version 1.0.0**
- Model Generator
- Migration Generator
- Controller Generator
- Routes Generator
- Resource Generator
- Multiple Resources From File
- **Version 1.1.0**
- Pivot table generator added.
- belongsToMany relationship added to model generator.
- Multiple resources generator adds foreign keys for belongsTo relationships automatically.
- Multiple resources generator adds pivot tables for belongsToMany relationships automatically.
- Generated migrations file names changed to be supported by `migrate` command.
## Contributing
Pull requests are welcome :D

View File

@ -1,10 +0,0 @@
<?php namespace App\Http\Controllers;
class ProjectsController extends Controller {
const MODEL = "App\Project";
use RESTActions;
}

View File

@ -1,10 +0,0 @@
<?php namespace App\Http\Controllers;
class TagsController extends Controller {
const MODEL = "App\Tag";
use RESTActions;
}

View File

@ -1,21 +0,0 @@
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Project extends Model {
protected $fillable = ["name", "descr"];
protected $dates = [];
public static $rules = [
"name" => "required",
];
public function tags()
{
return $this->belongsToMany("App\Tag")->withTimestamps();
}
}

View File

@ -1,21 +0,0 @@
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Tag extends Model {
protected $fillable = ["name"];
protected $dates = [];
public static $rules = [
"name" => "required|unique",
];
public function projects()
{
return $this->belongsToMany("App\Project")->withTimestamps();
}
}

View File

@ -1,21 +0,0 @@
<?php namespace App;
use Illuminate\Database\Eloquent\Model;
class Tags extends Model {
protected $fillable = ["name"];
protected $dates = [];
public static $rules = [
"name" => "required|unique",
];
public function projects()
{
return $this->belongsToMany("App\Project")->withTimestamps();
}
}

View File

@ -2,7 +2,7 @@
require_once __DIR__.'/../vendor/autoload.php';
// Dotenv::load(__DIR__.'/../');
Dotenv::load(__DIR__.'/../');
/*
|--------------------------------------------------------------------------

View File

@ -1,29 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectTagMigration extends Migration
{
public function up()
{
Schema::create('project_tag', function(Blueprint $table) {
$table->increments('id');
$table->integer('project_id')->unsigned()->index();
$table->integer('tag_id')->unsigned()->index();
$table->foreign('project_id')
->references('id')
->on('projects');
$table->foreign('tag_id')
->references('id')
->on('tags');
$table->timestamps();
});
}
public function down()
{
Schema::drop('project_tag');
}
}

View File

@ -1,29 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectTagMigration extends Migration
{
public function up()
{
Schema::create('project_tag', function(Blueprint $table) {
$table->increments('id');
$table->integer('project_id')->unsigned()->index();
$table->integer('tag_id')->unsigned()->index();
$table->foreign('project_id')
->references('id')
->on('projects');
$table->foreign('tag_id')
->references('id')
->on('tags');
$table->timestamps();
});
}
public function down()
{
Schema::drop('project_tag');
}
}

View File

@ -1,24 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectsMigration extends Migration
{
public function up()
{
Schema::create('projects', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('descr')->nullable();
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('projects');
}
}

View File

@ -1,23 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTagsMigration extends Migration
{
public function up()
{
Schema::create('tags', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('tags');
}
}

View File

@ -1,24 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectsMigration extends Migration
{
public function up()
{
Schema::create('projects', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('descr')->nullable();
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('projects');
}
}

View File

@ -1,23 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTagsMigration extends Migration
{
public function up()
{
Schema::create('tags', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('tags');
}
}

View File

@ -1,29 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectTagMigration extends Migration
{
public function up()
{
Schema::create('project_tag', function(Blueprint $table) {
$table->increments('id');
$table->integer('project_id')->unsigned()->index();
$table->integer('tag_id')->unsigned()->index();
$table->foreign('project_id')
->references('id')
->on('projects');
$table->foreign('tag_id')
->references('id')
->on('tags');
$table->timestamps();
});
}
public function down()
{
Schema::drop('project_tag');
}
}

View File

@ -1,24 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectsMigration extends Migration
{
public function up()
{
Schema::create('projects', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('descr')->nullable();
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('projects');
}
}

View File

@ -1,23 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTagsMigration extends Migration
{
public function up()
{
Schema::create('tags', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('tags');
}
}

View File

@ -1,24 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectsMigration extends Migration
{
public function up()
{
Schema::create('projects', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('descr')->nullable();
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('projects');
}
}

View File

@ -1,23 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTagsMigration extends Migration
{
public function up()
{
Schema::create('tags', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('tags');
}
}

View File

@ -1,24 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectsMigration extends Migration
{
public function up()
{
Schema::create('projects', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('descr')->nullable();
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('projects');
}
}

View File

@ -1,23 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTagsMigration extends Migration
{
public function up()
{
Schema::create('tags', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('tags');
}
}

View File

@ -1,24 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectsMigration extends Migration
{
public function up()
{
Schema::create('projects', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->text('descr')->nullable();
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('projects');
}
}

View File

@ -1,23 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTagsMigration extends Migration
{
public function up()
{
Schema::create('tags', function(Blueprint $table) {
$table->increments('id');
$table->string('name');
// Constraints declaration
$table->timestamps();
});
}
public function down()
{
Schema::drop('tags');
}
}

View File

@ -7,7 +7,7 @@ class MigrationCommand extends BaseCommand {
{table : The table name.}
{--schema= : the schema.}
{--keys= : foreign keys.}
{--file= : name of the migration file.}
{--file= : name of the migration file (to use only for testing purpose).}
{--parsed : tells the command that arguments have been already parsed. To use when calling the command from an other command and passing the parsed arguments and options}
';
// {action : One of create, add, remove or drop options.}
@ -31,7 +31,7 @@ class MigrationCommand extends BaseCommand {
$file = $this->option('file');
if(! $file){
$file = date('Y_m_d_His_') . snake_case($name);
$file = date('Y_m_d_His_') . snake_case($name) . '_table';
}
$this->save($content, "./database/migrations/{$file}.php");

View File

@ -6,7 +6,7 @@ class PivotTableCommand extends BaseCommand {
protected $signature = 'wn:pivot-table
{model1 : Name of the first model or table}
{model2 : Name of the second model or table}
{--file= : name of the migration file.}
{--file= : name of the migration file (to use only for testing purpose).}
';
protected $description = 'Generates creation migration for a pivot table';

View File

@ -3,7 +3,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class {{name}}Migration extends Migration
class {{name}}Table extends Migration
{
public function up()