Skip to content

I think theres a bug when generating resources from a file. #22

@devSarry

Description

@devSarry

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions