dcblogdev / laravel-microsoft-graph

Laravel package for Microsoft Graph API (Microsoft365)
https://dcblog.dev/docs/laravel-microsoft-graph
Other
120 stars 51 forks source link

Migrations failing #45

Closed PaulMcITS closed 1 year ago

PaulMcITS commented 1 year ago

Hi,

The published migrations fail (in laravel 9 anyway) with Cannot declare class create_ms_graph_tokens_table, because the name is already in use

I had to change the class name to CreateMsGraphTokensTable to get the migration to run.

Cheers!

Kristianmarku commented 1 year ago

I have the same issue in Laravel 9, I tried changing the class name but still not working.

musznik commented 1 year ago

bump, same issue.

Fix:

  1. Open migration file xxx_create_ms_graph_tokens_table.php
  2. replace "class create_ms_graph_tokens_table extends Migration" with "return new class extends Migration"
  3. add ; at end
dcblogdev commented 1 year ago

Strange this used to work perfectly, but you're right @musznik changing the migration to an anonymous migration works.

I'll push a release to change this in the package.

<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('ms_graph_tokens', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id')->nullable();
            $table->string('email')->nullable();
            $table->text('access_token');
            $table->text('refresh_token')->nullable();
            $table->string('expires');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('ms_graph_tokens');
    }
};
dcblogdev commented 1 year ago

I've just released this change https://github.com/dcblogdev/laravel-microsoft-graph/releases/tag/v3.1.7

movcmpret commented 1 year ago

Faced this issue with laravel 8 and dcblogdev/laravel-microsoft-graph v3.2.0

downgrade to 3.1.5 solved it

edit: this pull request might be interesting https://github.com/dcblogdev/laravel-microsoft-graph/pull/59