小编San*_*hra的帖子

如何使用laravel 5迁移在表中添加列而不丢失其数据?

我有一个现有的数据库表,我想在其上添加列.但是,当我运行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表.

php migration postgresql laravel-5.2

17
推荐指数
1
解决办法
2万
查看次数

未捕获的TypeError:lang不是函数

在我的HTML中,我langscript标签中定义了函数并添加了"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为其他任何内容,则此代码可以正常工作.

javascript typeerror

8
推荐指数
1
解决办法
593
查看次数

标签 统计

javascript ×1

laravel-5.2 ×1

migration ×1

php ×1

postgresql ×1

typeerror ×1