Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

update migration to anonymous classes & add missing UsersTrait #255

Closed
wants to merge 3 commits into from
Closed

update migration to anonymous classes & add missing UsersTrait #255

wants to merge 3 commits into from

Conversation

akunbeben
Copy link

@akunbeben akunbeben commented Apr 2, 2022

Due to migration class name collisions

Laravel-acl v4.x
Laravel v9.6.0
PHP v8.0.11

                                                     
  Symfony\Component\ErrorHandler\Error\FatalError                                          
                                                                                            
  Cannot declare class CreatePermissionsTable, because the name is already in use           
                                                                                            
  at C:\laragon\www\...\database\migrations\2022_04_02_070448_create_acl_permissions_table.php
      3▕ use Illuminate\Database\Migrations\Migration;                                      
      4▕ use Illuminate\Database\Schema\Blueprint;                                          
      5▕ use Illuminate\Support\Facades\Schema;                                             
      6▕                                                                                    
      7▕ class CreatePermissionsTable extends Migration                                     
      8▕ {                                                                                  
      9▕     public function up()                                                           
     10▕     {                                                                              
     11▕         $permissionsTable = config('acl.tables.permissions', 'permissions');       
                                                                                            
                                                                                            
   Whoops\Exception\ErrorException                                                          
                                                                                            
  Cannot declare class CreatePermissionsTable, because the name is already in use           

As I read from the https://laravel-news.com/laravel-anonymous-migrations

The Laravel team released Laravel 8.37 with anonymous migration support, which solves a GitHub issue with migration class name collisions. The core of the problem is that if multiple migrations have the same class name, it'll cause issues when trying to recreate the database from scratch.

The anonymous class feature is also backward-compatible with named migration classes to benefit from this feature in Laravel 8!

I have solved the error by changing migration classes into anonymous classes. and it works.

@akunbeben akunbeben changed the title update migration classes to anonymous classes update migration to anonymous classes & add missing UsersTrait Apr 2, 2022
@akunbeben
Copy link
Author

also added missing UsersTrait #253

@mateusjunges mateusjunges self-assigned this Apr 11, 2022
@mateusjunges mateusjunges marked this pull request as draft April 11, 2022 22:43
@mateusjunges
Copy link
Owner

Marking as draft until testing pipeline is fixed

@akunbeben
Copy link
Author

akunbeben commented Apr 12, 2022

working on it🚀

@mateusjunges
Copy link
Owner

closing this due to lack of updates

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

Successfully merging this pull request may close these issues.

2 participants