亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Laravel 創(chuàng)建指定表 migrate的例子

 更新時間:2019年10月09日 09:01:37   作者:SHUIPING_YANG  
今天小編就為大家分享一篇Laravel 創(chuàng)建指定表 migrate的例子,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

網(wǎng)上找了很多資料,都很坑爹,說是要把之前的表都給刪掉,然后重新運行,有的說要指定database的文件路徑,都不管用。

php artisan migrate:reset
php artisan migrate

這樣的話我之前的數(shù)據(jù)不都是白搞的了??

這樣肯定不行的啊,我就自己摸索,然后發(fā)現(xiàn)其實可以直接創(chuàng)建指定的表,運行thinker,然后運行up方法即可!示例代碼如下:

這個需要設置composer.json里面的自動加載,需要加載database/migrations這個文件夾下面的文件:

....
  "autoload": {
    "classmap": [
      "database/seeds",
      "database/migrations",
      "database/factories"
    ],
    ....
PS D:\phpStudy\WWW\BCCAdminV1.0> php artisan tinker
Psy Shell v0.7.2 (PHP 7.1.9 — cli) by Justin Hileman
>>> (new CreateAccessLogsTable)->up();
=> null
>>>  

運行出來個null,我還想著估計完蛋了,但是i還是去數(shù)據(jù)庫看了一眼,你猜怎么著,還真的成功了!

  public function up() {
    // Schema::dropIfExists('users');
    Schema::create('access_logs', function (Blueprint $table) {
      $table->increments('id');
      $table->string('ip')->default('0')->comment('ip地址');
      $table->integer('customer_id')->default('0')->comment('用戶ID');
      $table->string('refer_website')->default('')->comment('來源網(wǎng)站');
      $table->string('broswer')->default('')->comment('客戶端瀏覽器');
      $table->string('operating_system')->default('')->comment('客戶端操作系統(tǒng)');
      $table->string('resolution')->default('')->comment('客戶端分辨率');
      $table->string('visited_page')->default('')->comment('被訪問的頁面');
      $table->timestamp('created_at');
      $table->timestamp('left_at');
    });
  }

批量生成假數(shù)據(jù):

http://chabaoo.cn/article/171449.htm

以上這篇Laravel 創(chuàng)建指定表 migrate的例子就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關文章

最新評論