laravel 項目遷移_在Laravel遷移

laravel 項目遷移

Before moving forward we need to know some facts about it,

在繼續前進之前,我們需要了解一些事實,

  • Resources: In these directories, we have already a js, lang, sass and view page. Where, sass and js file holf their uncompressed, unminified js, CSS, sass file.

    資源:在這些目錄中,我們已經有一個js,lang,sass和view頁面。 sass和js文件將其未壓縮,最小化的js,CSS和sass文件分開。

  • view/welcome.blade.php: Which is already defined in storage/framwork/views/.... (at the bottom of the page: path/welcome.blade.php)

    view / welcome.blade.php:已在storage / framwork / views / ....中定義(在頁面底部:path / welcome.blade.php)

在Laravel遷移 (Migration in Laravel)

We are creating migration for creating databases or Database columns in PHPMyAdmin or any other database. After migration it will be automatically creating a database in PHPMyAdmin means we don't have to create again database and it's columns in PHPMyAdmin.

我們正在創建遷移,以在PHPMyAdmin或任何其他數據庫中創建數據庫或Database列。 遷移后,它將自動在PHPMyAdmin中創建數據庫,這意味著我們不必再次創建數據庫,并且它是PHPMyAdmin中的列。

Here, we need to create a post-migration table for creating a table column to store, retrieve, edit and update the data, we can take columns name according to our requirement.

在這里,我們需要創建一個遷移后的表,以創建一個表列來存儲,檢索,編輯和更新數據,我們可以根據需要獲取列名。

First, On CMD run this command for creating a migration table,

首先,在CMD上運行此命令以創建遷移表,

    $ php artisan make:migration create_posts_table

Now, you can see this migration file in this path and open it: database/migration/create_posts_table

現在,您可以在此路徑中看到此遷移文件并打開它: database / migration / create_posts_table

Migration in Laravel | Step 1

Here, I am declaring a column name in public function up{ // code }

在這里,我在public function up中聲明一個列名{//代碼}

Example: Code for create_posts_table

示例:create_posts_table的代碼

class CreatePostsTable extends Migration
{
public function up()
{
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('body');
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('posts');
}
}

public function up{}: In this function, we are creating a database schema. It is the blueprint of the table that's why we are writing a Blueprint $table in the Schema.

public function up {} :在此函數中,我們正在創建一個數據庫模式。 這就是表的藍圖,這就是我們在Schema中編寫Blueprint $ table的原因。

public function down{}: In this function, dropIfExists means to drop the table "posts" if already exists.

public function down {} :在此函數中, dropIfExists表示刪除表“ posts”(如果已存在)。

Now, again on CMD: $ php artisan migrate

現在,再次在CMD上: $ php artisan migration

Here, this command is used to migrate the table columns successfully. Every migration table has two classes "UP" and "down".

在此,此命令用于成功遷移表列。 每個遷移表都有兩個類“ UP”“ down”

  • "UP" class: This method is used to set execution whenever the migration command is running.

    “ UP”類 :每當運行遷移命令時,此方法用于設置執行。

  • "Down" class: This method is used to set when you want to rollback after migration. You can say that it is the reverse of the "UP" method.

    “ Down”類 :此方法用于設置要在遷移后回滾的時間。 您可以說這與“ UP”方法相反。

Now, after migration, we have a new Posts table in PHPMyAdmin's blog' DB table named 'posts'. Again Here, "Posts" is your table name from where you can store, retrieve, delete and update your data.

現在,在遷移之后,我們在PHPMyAdmin的博客“ DB”表中有了一個名為“ posts”的新Posts表。 在這里, “職位”是您的表名,您可以在其中存儲,檢索,刪除和更新數據。

Migration in Laravel | Step 2

Now, here you can see after the migration database id automatically created in the PHPMyAdmin.

現在,在這里您可以看到在PHPMyAdmin中自動創建的遷移數據庫ID。

Conclusion:

結論:

In this article, we have learnt about the migration in Laravel. I hope you understood the concept, we will know more about it in the up coming articles. Have a great day! Happy Learning!

在本文中,我們了解了Laravel中遷移 。 希望您理解這個概念,我們將在以后的文章中進一步了解它。 祝你有美好的一天! 學習愉快!

翻譯自: https://www.includehelp.com/laravel/migration.aspx

laravel 項目遷移

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/540561.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/540561.shtml
英文地址,請注明出處:http://en.pswp.cn/news/540561.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Python之list對應元素求和

本次分享將講述如何在Python中對多個list的對應元素求和,前提是每個list的長度一樣。比如:a[1,2,3], b[2,3,4], c[3,4,5], 對a,b,c的對應元素求和,輸出應為[6,9,12].    方法一:   直接求解,按照對應元素相加的…

[轉載] Python中str跟int的轉換

參考鏈接: Python中的類型轉換 字符串str轉換成int: int_value int(str_value) int轉換成字符串str: str_value str(int_value) a100 b666 #int轉str類型 print(int轉str類型) print(int轉str: str(a)) #str轉int類型 print(str轉int類型…

ot協議是什么_OT的完整形式是什么?

ot協議是什么OT:主題外 (OT: Off Topic) OT is an abbreviation of "Off Topic". OT是“ Off Topic”的縮寫 。 It is an expression, which is commonly used in Gmail or messaging platform. It shows that the email that has been sent is irrelev…

[轉載] python中字符串編碼形式及其所占字節

參考鏈接: Python中的字節對象與字符串 1.常見字符串編碼錯誤 在使用Python讀文件時經常遇到編碼問題引起的錯誤,比如: UnicodeDecodeError: gbk codec cant decode byte 0x80 in position 30: illegal multibyte sequence 遇到這種異…

[AtCoder-ARC073F]Many Moves

題目大意:   有一排n個格子和2枚硬幣。   現在有q次任務,每一次要你把其中一枚硬幣移到x的位置上,移動1格的代價是1。   兩枚硬幣不能同時移動,任務必須按次序完成。   現在告訴你兩枚硬幣初始狀態所在的位置a和b&#xf…

ScalavsKotlin

Is Scala better that Kotlin? No..., Is Kotlin better than Scala? No... Scala比Kotlin更好嗎? 不...,Kotlin勝過Scala嗎? 沒有... Both programming languages have their own profits and are for a specific set of development. It…

工業智能相機與基于PC的機器視覺的區別比較

隨著科技的日漸成熟,機器視覺得到了飛速發展。由于嵌入式技術的發展,近幾年智能相機性能顯著提高,越來越多必須依賴于PC處理的應用開始向智能相機平臺傾斜。低成本、高可靠性及易于安裝維護等優勢,使得機器視覺在制造業上的規模性應用越來越普…

[轉載] python skimage在圖像處理中的用法

參考鏈接: 在Python中打印單變量和多變量 基于python腳本語言開發的數字圖片處理包,比如PIL,Pillow, opencv, scikit-image等。 PIL和Pillow只提供最基礎的數字圖像處理,功能有限;opencv實際上是一個c庫,只是提供了py…

scala元組 數組_Scala中的數組

scala元組 數組Scala中的數組 (Arrays in Scala) An array is a linear data structure with a fixed number of elements. It is a collection that stores a fixed number Arrays in Scalf elements of the same datatype. In Scala, an array is 0 indexed, i.e. the first …

OpenStack —— DevStack一鍵自動化安裝

一、DevStack介紹Devstack目前是支持Ubuntu16.04和CentOS 7,而且Devstack官方建議使用Ubuntu16.04,所以我們使用Ubuntu 16.04進行安裝。默認無論是Devstack和OpenStack,都是采用Master的代碼進行安裝,這樣經常會出現,今…

[轉載] Python學習筆記——運維和Shell

參考鏈接: 在C / C,Python,PHP和Java中交換兩個變量 目錄 什么是運維 運維第一工具-shell編程 shell歷史 執行腳本 基本語法 Shell腳本語法 條件測試:test [ if/then/elif/else/fi case/esac for/do/done …

scala java混合_Scala特性混合

scala java混合Scala | 特性混合 (Scala | Trait Mixins ) In Scala, the number of traits can be extended using a class or an abstract class. This is known as Trait Mixins. For extending, only traits, the blend of traits, class or abstract class are valid. If …

Scala鑄造

Scala中的類型 (Types in Scala) Type also know as data type tells the compiler about the type of data that is used by the programmer. For example, if we initialize a value or variable as an integer the compiler will free up 4 bytes of memory space and it wi…

/ 卡路里_最大卡路里

/ 卡路里Problem statement: 問題陳述: Shivang is very foodie but he has a diet plan. He has an array of elements indicating the calorie of food he can consume on that day. In his diet plan, he can’t eat on for three consecutive days. But since …

[轉載] Python類中的私有變量和公有變量

參考鏈接: Python中的私有變量 我們這里就直奔主題,不做基礎鋪墊,默認你有一些Python類的基礎,大家在看這篇博客的時候,如果基礎知識忘了,可以去菜鳥教程 從一個簡單的類開始 class A(): #定義一…

OpenCV探索之路(二十五):制作簡易的圖像標注小工具

搞圖像深度學習的童鞋一定碰過圖像數據標注的東西,當我們訓練網絡時需要訓練集數據,但在網上又沒有找到自己想要的數據集,這時候就考慮自己制作自己的數據集了,這時就需要對圖像進行標注。圖像標注是件很枯燥又很費人力物力的一件…

固件的完整形式是什么?

FW:前進 (FW: Forward) FW is an abbreviation of "Forward". FW是“ Forward”的縮寫 。 It is an expression, which is commonly used in Gmail or messaging platform. It is also written as FWD or Fwd or Fw. It shows that the email has been s…

[轉載] python __slots__ 詳解(上篇)

參考鏈接: Python的__name __(特殊變量) python中的new-style class要求繼承Python中的一個內建類型, 一般繼承object,也可以繼承list或者dict等其他的內建類型。 在python新式類中,可以定義一個變量__slots__,它的作…

委托BegionInvoke和窗體BegionInvoke

委托BegionInvoke是指通過委托方法執行多線程任務,例如: //定義委托成員變量 delegate void dg_DeleAirport(); //指定委托函數 dg_DeleAirport dga AirportBLL.DeleteHistoryTransAirport; //通過BeginInvoke以異步線程方式執行委托函數,可…

圖論 弦_混亂的弦

圖論 弦Problem statement: 問題陳述: You are provided an input string S and the string "includehelp". You need to figure out all possible subsequences "includehelp" in the string S? Find out the number of ways in which the s…