【发布时间】:2021-08-22 04:07:42
【问题描述】:
我使用 Laravel 迁移向数据库表添加了一个新列,如下所示:
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddFAQToStoreTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('store', function (Blueprint $table) {
$table->longText('FAQ')->after('description');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('store', function (Blueprint $table) {
$table->dropColumn('FAQ');
});
}
}
作为 FAQ 的默认值,我希望在运行迁移时为所有商店预填充以下 HTML:
<div><span style="font-weight:600">Can we get our purchase delivered?</span><br/>
Yes, items purchased can be delivered. However, due to COVID-19 restrictions, we are expecting a 3-5 business days' delay.</div>
是否可以添加一个新列并同时使用上面的 HTML 块预先填充它?如果使用数据库播种器是更好的做法,也请提出建议。谢谢
【问题讨论】:
-
为什么不用php端?
标签: php laravel database-migration