php 改变字段类型,php – Laravel迁移表字段的类型更改

在 Laravel 的数据库迁移文件 `2015_09_14_051851_create_orders_table.php` 中,用户打算将 `category_id` 字段从整数类型改为字符串类型。这通常涉及到数据库结构的更新,可能是因为需要存储更复杂的数据或者为了适应新的业务需求。
摘要由CSDN通过智能技术生成

以下是我的文件2015_09_14_051851_create_orders_table.php。

我想改变$ table->整数(‘category_id’);作为新迁移的字符串。

use Illuminate\Database\Schema\Blueprint;

use Illuminate\Database\Migrations\Migration;

class CreateOrdersTable extends Migration {

/**

* Run the migrations.

*

* @return void

*/

public function up()

{

Schema::create('orders', function(Blueprint $table)

{

$table->increments('id');

$table->string('num');

$table->integer('user_id');

$table->text('store_name');

$table->integer('store_name_publication');

$table->string('postal_code', 255);

$table->string('phone_number', 255);

$table->text('title');

$table->text('description');

$table->string('list_image_filename1', 255);

$table->string('list_image_filename2', 255)->nullable();

$table->string('list_image_filename3', 255)->nullable();

$table->string('list_image_filename4', 255)->nullable();

$table->string('list_image_filename5', 255)->nullable();

$table->integer('term');

$table->datetime('state0_at')->nullable();

$table->datetime('state1_at')->nullable();

$table->datetime('state2_at')->nullable();

$table->datetime('state3_at')->nullable();

$table->datetime('state4_at')->nullable();

$table->datetime('state5_at')->nullable();

$table->datetime('state6_at')->nullable();

$table->datetime('state7_at')->nullable();

$table->datetime('state8_at')->nullable();

$table->datetime('state9_at')->nullable();

$table->datetime('state10_at')->nullable();

$table->integer('category_id');

$table->integer('target_customer_sex');

$table->integer('target_customer_age');

$table->integer('payment_order');

$table->integer('num_comment');

$table->integer('num_view');

$table->string('num_pop');

$table->integer('money');

$table->integer('point');

$table->datetime('closed_at');

$table->timestamps();

$table->softDeletes();

});

}

/**

* Reverse the migrations.

*

* @return void

*/

public function down()

{

Schema::drop('orders');

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值