After migrating the laravel database, I want to modify the data table field information

WBOY
Release: 2023-03-02 11:08:01
Original
2655 people have browsed it

After executing

php artisan migrate in laravel, data is also inserted into the database
But now I want to modify the target structure. For example, I want to add a default value of 0 to the title field. If withdrawn, the data will be gone. How can I ensure that the database data is still there? Now you can modify the data table

ps (I tried to create a migration if I added a field, but it didn’t work when I modified the field information)

Reply content:

After executing

php artisan migrate

in laravel, data is also inserted into the databaseBut now I want to modify the target structure. For example, I want to add a default value of 0 to the
title field. If withdrawn, the data will be gone. How can I ensure that the database data is still there? Now you can modify the data table

ps (I tried to create a migration if I added a field, but it didn’t work when I modified the field information)

<code>Schema::table('users', function ($table) { $table->string('title')->default('1')->change(); });</code>
Copy after login
https://laravel-china.org/doc...

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!