Coder Social home page Coder Social logo

Comments (7)

drbyte avatar drbyte commented on August 16, 2024

So the new settings conflicts with the Laravel's default string length and validations, which is 255. So either we have to update the validations to 125 or ...

I suppose you could bypass calling Schema::defaultStringLength(125) if you simply impose it in your migration, as shown in the migration stub comments:

$table->string('name'); // For MySQL 8.0 use string('name', 125);
$table->string('guard_name'); // For MySQL 8.0 use string('guard_name', 125);

You would still have to manually impose your own validation rules (including length limits) on any forms you create to manage those fields, as usual in any application.

from laravel-permission.

kkraju4u avatar kkraju4u commented on August 16, 2024

But my point is that the migrations works fine with MySQL 8.0 without setting the default string length as 125 or updating the migrations, when using InnoDB with dynamic or compressed row format in MySQL. So what I'm trying to say is as per the prerequisites documentation and the migration stub comments, it's kind of misleading that if I'm using MySQL 8.0, it's mandatory to update the string limit to 125 either globally or just for the permission and roles table.

from laravel-permission.

drbyte avatar drbyte commented on August 16, 2024

Right. I'm digging to collect enough information in order to convey the requirements as accurately as possible, without making the documentation extra-long.

I guess perhaps the simplest approach is to explain what environments/configurations require special care to avoid triggering errors caused by limitations within said environments.

from laravel-permission.

drbyte avatar drbyte commented on August 16, 2024

Another thought: What's the actual max length "needed" for guard_name? Do people really need to accommodate 255 or 125 character guard names? Most applications I've seen use 3 chars ('web', 'api', etc) or maybe 5 ("admin").
I wonder if we hard-code it to 25 maybe that will give a happy combination?

eg, default in the migration to:

$table->string('guard_name', 25);

from laravel-permission.

drbyte avatar drbyte commented on August 16, 2024

Or ... what's the way to query MySQL for the max index length the current db host supports for a given table?
Maybe we can query that in the migration and dynamically set things accordingly?

from laravel-permission.

kkraju4u avatar kkraju4u commented on August 16, 2024

I couldn't find any query to get the configuration. But as you might already know, the engine and row format can be obtained from the information schema. Maybe that details can be used to set a custom configuration.

SELECT TABLE_NAME, ENGINE, ROW_FORMAT FROM information_schema.TABLES where TABLE_SCHEMA = 'schema_name_from_env' AND TABLE_NAME = 'migrations'

In my opinion, it will be easier to mention these in the documentation so that the user can decide which configuration to use. You just need to include the steps to identify the correct configuration.

So if MyISAM - name and guard_name should be 125.
InnoDB REDUNDANT or COMPACT row format - name and guard_name should be 95 // Not sure if my calculation is correct.
Use the default value for InnoDB DYNAMIC or COMPRESSED row format.

Here are some links for reference if that helps.

from laravel-permission.

spatie-bot avatar spatie-bot commented on August 16, 2024

Dear contributor,

because this issue seems to be inactive for quite some time now, I've automatically closed it. If you feel this issue deserves some attention from my human colleagues feel free to reopen it.

from laravel-permission.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.