Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get Laravel 5 to recognize Bosnadev\Database\Schema\Blueprint #14

Open
RyanSimon opened this issue Jul 12, 2015 · 1 comment
Open

Comments

@RyanSimon
Copy link

I'm having an issue getting migrations to work with this package.

The problem seems to be a class loading issue, but I'm not 100% sure. Here's what my migration file looks like:

use Bosnadev\Database\Schema;
use Bosnadev\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class TestMigration extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('test', function(Blueprint $table)
        {
            $table->engine = "InnoDB";

                $table->increments('id');
            $table->uuid('public_uid');
            $table->uuid('private_uid');

            $table->softDeletes();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('test');
    }
}

Here's the error I get when trying to migrate:

[ErrorException]                                                                                                                                                                              
  Argument 1 passed to TestMigration::{closure}() must be an instance of Bosnadev\Database\Schema\Blueprint, instance of Illuminate\Database\Schema\Blueprint given, called in /Users/mydir/LaravelProjects/laravel5/vendor/illuminate/database/Schema/Builder.php on line 132 and defined

I'm hoping other users, or @mirzap might be able to help me troubleshoot this issue. Thanks!

@mirzap
Copy link
Member

mirzap commented Jul 13, 2015

This is an extension of a PostgreSQL connector so you don't need $table->engine = "InnoDB";
I think you could do just fine if you use Illuminate Blueprint:

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

since my Blueprint is already hooked to SchemaBuilder. Just add DatabaseServiceProvider to the service providers in config/app.php:

....
Bosnadev\Database\DatabaseServiceProvider::class,

I tested it:

<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class Test extends Migration
{
    public function up()
    {
        Schema::create('test', function(Blueprint $table)
        {
            $table->engine = "InnoDB";

            $table->increments('id');
            $table->uuid('public_uid');
            $table->uuid('private_uid');

            $table->softDeletes();
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::drop('test');
    }
}

and here is a result:

postgres=# \c homestead
You are now connected to database "homestead" as user "postgres".
homestead=# \d+ test

                                                           Table "public.test"
   Column    |              Type              |                     Modifiers                     | Storage | Stats target | Description 
-------------+--------------------------------+---------------------------------------------------+---------+--------------+-------------
 id          | integer                        | not null default nextval('test_id_seq'::regclass) | plain   |              | 
 public_uid  | uuid                           | not null                                          | plain   |              | 
 private_uid | uuid                           | not null                                          | plain   |              | 
 deleted_at  | timestamp(0) without time zone |                                                   | plain   |              | 
 created_at  | timestamp(0) without time zone | not null                                          | plain   |              | 
 updated_at  | timestamp(0) without time zone | not null                                          | plain   |              | 
Indexes:
    "test_pkey" PRIMARY KEY, btree (id)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants