I think theres a bug when generating resources from a file.
devSarry opened this issue · 1 comments
devSarry commented
When trying to create a resource with a relationship like
User:
hasMany: messages
fields:
name:
schema: string:50
rules: required|min:3
tags: fillable
email:
schema: string unique
rules: required|email|unique:users,email
tags: fillable
password:
schema: string
rules: required|min:6
tags: fillable
Message:
belongsTo: user
belongsToMany: channel
fields:
text:
schema: text
rules: required
tags: fillable
add: timestamps softDeletes
and you run wn:resources /path/to/file.yaml
it will generate a duplicate column for the foriegn key
public function up()
{
Schema::create('messages', function(Blueprint $table) {
$table->increments('id');
$table->text('text');
$table->integer('user_id');
$table->integer('user_id')->unsigned();
$table->foreign('user_id')
->references('id')
->on('users');
$table->timestamps();
$table->softDeletes();
});
}
Also after a bit of testing and poking around I think there should be option or a flag to prevent the resource from running a migration.
webNeat commented
@dopyoman Thank you for testing and finding this bug, I fixed it and made a new release https://github.com/webNeat/lumen-generators/releases/tag/1.3.1
I have also opened a new issue Add possibility to not run migrations when using wn:resources
because I am closing this one.
Fell free to reopen it if the bug seems not to be fixed.