Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to use data type as "blob" during migration in Laravel 6

I want to store HTML in the database as blob data type when I try to migrate getting errors

Schema::create('projects', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('project_name');
            $table->blob('project_description');
            $table->timestamps();
        });
    }
php artisan module:migrate projects
Migrating: 2019_10_17_125423_create_projects_table

BadMethodCallException : Method Illuminate\Database\Schema\Blueprint::blob does not exist.

at xampp\htdocs\minidmsapi\vendor\laravel\framework\src\Illuminate\Support\Traits\Macroable.php:104

like image 604
Naveen Nayak Avatar asked Oct 17 '19 07:10

Naveen Nayak


People also ask

How do I add a column in Laravel migration without losing data?

database\migration\add_new_column_to_products_table.php Now you can run migrate command to add this new field. Simply you can run below command to auto add a new field. Hope it can help you. Laravel Migration example tutorial, in this tutorial you have learned how to add new column to a table without losing data.

How do I rename a table column in Laravel migration?

To rename a column, you may use the renameColumn method on the Schema builder. Before renaming a column, be sure to add the doctrine/dbal dependency to your composer. json file: Schema::table('users', function (Blueprint $table) { $table->renameColumn('from', 'to'); });


1 Answers

In Laravel they have binary instead of blob. binary is equivalent to blob.

You can use it like:

$table->binary('name'); 

For more information see docs.

Thanks

like image 89
Salman Zafar Avatar answered Sep 27 '22 17:09

Salman Zafar