BadClassNameException testing Migration


#1

Hi,

I’m in the very early stages of the (fairly steep) learning curve of moving a project of mine from UserFrosting 0.2.2 to 4.1.2 (so much to learn!).

I’m just trying to follow the very simple tutorial in the docs with the Site sprinkle and have hit a snag at the first example of a database Migration.

I’ve created site\src\Database\Migrations\v100\dummy.php in sprinkles

with the contents taken from the Database Migrations chapter of the docs:

<?php

namespace UserFrosting\Sprinkle\Site\Database\Migrations\v100;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Schema\Builder;
use UserFrosting\System\Bakery\Migration;

class MembersTable extends Migration
{
    public function up()
    {
        if (!$this->schema->hasTable('members')) {  
            $this->schema->create('members', function (Blueprint $table) {
                $table->increments('id');
                $table->integer('user_id')->unsigned()->unique();
                $table->string('city', 255)->nullable();
                $table->timestamps();

                $table->engine = 'InnoDB';
                $table->collation = 'utf8_unicode_ci';
                $table->charset = 'utf8';
                $table->foreign('user_id')->references('id')->on('users');
                $table->index('user_id');
            });
        }
    }

    public function down()
    {
        $this->schema->drop('members');
    }
}

But when I run
bakery migrate

I get
[UserFrosting\Sprinkle\Core\Util\BadClassNameException]
Unable to find the migration class ‘\UserFrosting\Sprinkle\Site\Database\Migrations\v100\dummy’.

I have already run a composer update and the site sprinkle is seen and used. What am I missing?

Thanks
Andrew


#2

The name of the file needs to match the name of the migration (ignoring the file extension).


#3

Got it, thanks - sorry was being a bit slow there, appreciate the help.