Modifying column type to bigIncrements without DBAL library

Posted 10 months ago by Tetravalence

Hello, according to Laravel's documentation in order to modify existing column types, the Doctrine DBAL library has to be installed. Furthermore only certain column types can be "changed". I'm working on a blog package and I need the 'id' column to be bigIncrements instead of increments provided as default in the Laravel migration file for the 'users' table. My solution is to use the Schema facade to drop the 'id' column via 'up' method from migration class of the package, then restore the 'id' column with the new type:

 if (Schema::hasColumn('users', 'id')) {
    Schema::table('users', function (Blueprint $table) {
        Schema::table('users', function (Blueprint $table) {

Is this the right way to modify an existing migration without DBAL library? I don't understand because I have to create the 'id' column in a separate Schema block whereas if I try to use dropColumn and bigIncrements methods together then Laravel returns an error message.

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.