我有一个现有的数据库表,我想在其上添加列.但是,当我运行php artisan migrate命令时,它没有说任何迁移.但是我已经添加了一个用于添加表列的Schema.我已经阅读了一些文章和链接,我应该php artisan migrate:refresh在添加新列之前先运行.问题是,它将删除我表中的现有数据.有没有什么办法可以执行迁移并在我的表中成功添加列而不删除我的数据?请帮我解决一下这个.非常感谢.这是我的迁移代码.
public function up()
{
//
Schema::create('purchase_orders', function(Blueprint $table){
$table->increments('id');
$table->string('po_code');
$table->text('purchase_orders');
$table->float('freight_charge');
$table->float('overall_total');
$table->timestamps();
});
Schema::table('purchase_orders', function(Blueprint $table){
$table->string('shipped_via');
$table->string('terms');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
Schema::drop('purchase_orders');
}
Run Code Online (Sandbox Code Playgroud)
我想添加列shipped_via,并terms在我的purchase_orders表.
在我的HTML中,我lang在script标签中定义了函数并添加了"Test Fire!" 点击时必须调用lang的按钮:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Testing Functions</title>
<script type="text/javascript">
function lang() {
alert("Hello, World! It's JavaScript this time");
}
</script>
</head>
<body>
<form action="">
<input type="button" value="Test Fire!" onclick="lang();">
</form>
</body>
</html>Run Code Online (Sandbox Code Playgroud)
但是,如果我单击按钮,我会收到此错误:
未捕获的TypeError:
lang不是函数
但是,如果我将函数名称更改lang为其他任何内容,则此代码可以正常工作.