Di chuyển giống như kiểm soát phiên bản cho cơ sở dữ liệu của bạn, cho phép nhóm của bạn xác định và chia sẻ định nghĩa lược đồ cơ sở dữ liệu của ứng dụng. Nếu bạn đã từng phải yêu cầu đồng đội thêm một cột vào lược đồ cơ sở dữ liệu cục bộ của họ theo cách thủ công sau khi lấy các thay đổi của bạn từ kiểm soát nguồn, thì bạn đã gặp phải vấn đề mà việc di chuyển cơ sở dữ liệu giải quyết được
Mặt tiền
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
07 của Laravel cung cấp hỗ trợ cơ sở dữ liệu bất khả tri để tạo và thao tác các bảng trên tất cả các hệ thống cơ sở dữ liệu được hỗ trợ của Laravel. Thông thường, quá trình di chuyển sẽ sử dụng mặt tiền này để tạo và sửa đổi các bảng và cột cơ sở dữ liệuTạo Migration
Bạn có thể sử dụng lệnh Artisan
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
08 để tạo di chuyển cơ sở dữ liệu. Di chuyển mới sẽ được đặt trong thư mục # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
09 của bạn. Mỗi tên tệp di chuyển chứa dấu thời gian cho phép Laravel xác định thứ tự di chuyểnphp artisan make:migration create_flights_table
Laravel sẽ sử dụng tên của quá trình di chuyển để cố gắng đoán tên của bảng và liệu quá trình di chuyển có tạo ra một bảng mới hay không. Nếu Laravel có thể xác định tên bảng từ tên di chuyển, Laravel sẽ điền trước vào tệp di chuyển đã tạo với bảng đã chỉ định. Nếu không, bạn chỉ cần chỉ định bảng trong tệp di chuyển theo cách thủ công
Nếu bạn muốn chỉ định đường dẫn tùy chỉnh cho quá trình di chuyển đã tạo, bạn có thể sử dụng tùy chọn
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
10 khi thực hiện lệnh # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
08. Đường dẫn đã cho phải liên quan đến đường dẫn cơ sở của ứng dụng của bạnLưu ý
Sơ khai di chuyển có thể được tùy chỉnh bằng cách xuất bản sơ khai.
Di chuyển đè bẹp
Khi bạn xây dựng ứng dụng của mình, bạn có thể tích lũy ngày càng nhiều lần di chuyển theo thời gian. Điều này có thể dẫn đến thư mục
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
09 của bạn trở nên cồng kềnh với hàng trăm lần di chuyển tiềm năng. Nếu muốn, bạn có thể "bóp" các lần di chuyển của mình thành một tệp SQL duy nhất. Để bắt đầu, hãy thực hiện lệnh # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
13# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Khi bạn thực hiện lệnh này, Laravel sẽ ghi một tệp "lược đồ" vào thư mục
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
14 của ứng dụng của bạn. Tên của tệp lược đồ sẽ tương ứng với kết nối cơ sở dữ liệu. Bây giờ, khi bạn cố gắng di chuyển cơ sở dữ liệu của mình và không có quá trình di chuyển nào khác được thực hiện, trước tiên Laravel sẽ thực thi các câu lệnh SQL của tệp lược đồ của kết nối cơ sở dữ liệu mà bạn đang sử dụng. Sau khi thực thi các câu lệnh của tệp lược đồ, Laravel sẽ thực hiện mọi di chuyển còn lại không phải là một phần của kết xuất lược đồNếu các thử nghiệm của ứng dụng của bạn sử dụng kết nối cơ sở dữ liệu khác với kết nối cơ sở dữ liệu bạn thường sử dụng trong quá trình phát triển cục bộ, thì bạn nên đảm bảo rằng bạn đã kết xuất một tệp lược đồ bằng cách sử dụng kết nối cơ sở dữ liệu đó để các thử nghiệm của bạn có thể xây dựng cơ sở dữ liệu của bạn. Bạn có thể muốn làm điều này sau khi kết xuất kết nối cơ sở dữ liệu mà bạn thường sử dụng trong quá trình phát triển cục bộ
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
0Bạn nên cam kết tệp lược đồ cơ sở dữ liệu của mình để kiểm soát nguồn để các nhà phát triển mới khác trong nhóm của bạn có thể nhanh chóng tạo cấu trúc cơ sở dữ liệu ban đầu của ứng dụng của bạn
Cảnh báo
Tính năng nén di chuyển chỉ khả dụng cho cơ sở dữ liệu MySQL, PostgreSQL và SQLite và sử dụng ứng dụng khách dòng lệnh của cơ sở dữ liệu. Kết xuất lược đồ có thể không được khôi phục vào cơ sở dữ liệu SQLite trong bộ nhớ.
Cơ cấu di cư
Một lớp di chuyển chứa hai phương thức.
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
15 và # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
16. Phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
15 được sử dụng để thêm các bảng, cột hoặc chỉ mục mới vào cơ sở dữ liệu của bạn, trong khi phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
16 sẽ đảo ngược các hoạt động được thực hiện bởi phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
15Trong cả hai phương pháp này, bạn có thể sử dụng trình tạo lược đồ Laravel để tạo và sửa đổi các bảng một cách rõ ràng. Để tìm hiểu về tất cả các phương pháp có sẵn trên trình tạo
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
07, hãy xem tài liệu của nó. Ví dụ: quá trình di chuyển sau đây tạo bảng # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
21# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
8Đặt kết nối di chuyển
Nếu quá trình di chuyển của bạn sẽ tương tác với một kết nối cơ sở dữ liệu khác với kết nối cơ sở dữ liệu mặc định của ứng dụng, thì bạn nên đặt thuộc tính
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
22 cho quá trình di chuyển của mình# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
0Di chuyển đang chạy
Để chạy tất cả các lần di chuyển chưa hoàn thành của bạn, hãy thực hiện lệnh
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
23 ArtisanNếu bạn muốn xem những lần di chuyển nào đã chạy cho đến nay, bạn có thể sử dụng lệnh Artisan
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
24Nếu bạn muốn xem các câu lệnh SQL sẽ được thực thi bởi quá trình di chuyển mà không thực sự chạy chúng, bạn có thể cung cấp cờ
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
25 cho lệnh # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
23# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
5Cô lập thực hiện Migration
Nếu bạn đang triển khai ứng dụng của mình trên nhiều máy chủ và chạy di chuyển như một phần của quy trình triển khai, bạn có thể không muốn hai máy chủ cố gắng di chuyển cơ sở dữ liệu cùng một lúc. Để tránh điều này, bạn có thể sử dụng tùy chọn
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
27 khi gọi lệnh # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
23Khi tùy chọn
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
27 được cung cấp, Laravel sẽ nhận được một khóa nguyên tử bằng cách sử dụng trình điều khiển bộ nhớ cache của ứng dụng của bạn trước khi thử chạy quá trình di chuyển của bạn. Tất cả các nỗ lực khác để chạy lệnh # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
23 trong khi khóa đó được giữ sẽ không thực thi; php artisan make:migration create_flights_table
0Cảnh báo Để sử dụng tính năng này, ứng dụng của bạn phải đang sử dụng trình điều khiển bộ đệm ẩn
31,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
32,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
33,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
34,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
35 hoặc
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
36 làm trình điều khiển bộ đệm mặc định cho ứng dụng của bạn. Ngoài ra, tất cả các máy chủ phải giao tiếp với cùng một máy chủ bộ đệm trung tâm
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Buộc di chuyển để chạy trong sản xuất
Một số thao tác di chuyển mang tính phá hoại, có nghĩa là chúng có thể khiến bạn mất dữ liệu. Để bảo vệ bạn khỏi việc chạy các lệnh này đối với cơ sở dữ liệu sản xuất của mình, bạn sẽ được nhắc xác nhận trước khi các lệnh được thực thi. Để buộc các lệnh chạy mà không có dấu nhắc, hãy sử dụng cờ
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
37Quay lại di chuyển
Để khôi phục hoạt động di chuyển mới nhất, bạn có thể sử dụng lệnh Artisan
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
38. Lệnh này khôi phục "đợt" di chuyển cuối cùng, có thể bao gồm nhiều tệp di chuyểnphp artisan make:migration create_flights_table
9Bạn có thể khôi phục một số lần di chuyển hạn chế bằng cách cung cấp tùy chọn
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
39 cho lệnh # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
38. Ví dụ: lệnh sau sẽ khôi phục năm lần di chuyển cuối cùng# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
2Lệnh
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
41 sẽ khôi phục tất cả các lần di chuyển của ứng dụng của bạnQuay lại & Di chuyển bằng một lệnh duy nhất
Lệnh
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
42 sẽ khôi phục tất cả các lần di chuyển của bạn và sau đó thực hiện lệnh # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
23. Lệnh này tạo lại toàn bộ cơ sở dữ liệu của bạn một cách hiệu quả# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
6Bạn có thể khôi phục và di chuyển lại một số lần di chuyển hạn chế bằng cách cung cấp tùy chọn
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
39 cho lệnh # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
45. Ví dụ: lệnh sau sẽ khôi phục và di chuyển lại năm lần di chuyển cuối cùng# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
0Bỏ tất cả các bảng và di chuyển
Lệnh
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
46 sẽ loại bỏ tất cả các bảng khỏi cơ sở dữ liệu và sau đó thực hiện lệnh # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
23# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
1Cảnh báo
Lệnh46 sẽ loại bỏ tất cả các bảng cơ sở dữ liệu bất kể tiền tố của chúng là gì. Cần thận trọng khi sử dụng lệnh này khi phát triển trên cơ sở dữ liệu được chia sẻ với các ứng dụng khác.
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Những cái bàn
Tạo bảng
Để tạo một bảng cơ sở dữ liệu mới, hãy sử dụng phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
49 trên mặt tiền # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
07. Phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
49 chấp nhận hai đối số. cái đầu tiên là tên của bảng, trong khi cái thứ hai là một bao đóng nhận một đối tượng # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
52 có thể được sử dụng để xác định bảng mới# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
2Khi tạo bảng, bạn có thể sử dụng bất kỳ phương thức cột nào của trình tạo lược đồ để xác định các cột của bảng
Kiểm tra sự tồn tại của bảng/cột
Bạn có thể kiểm tra sự tồn tại của một bảng hoặc cột bằng phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
53 và # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
54# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
3Kết nối cơ sở dữ liệu & Tùy chọn bảng
Nếu bạn muốn thực hiện thao tác lược đồ trên kết nối cơ sở dữ liệu không phải là kết nối mặc định của ứng dụng của bạn, hãy sử dụng phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
55# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
4Ngoài ra, một vài thuộc tính và phương thức khác có thể được sử dụng để xác định các khía cạnh khác của việc tạo bảng. Thuộc tính
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
56 có thể được sử dụng để chỉ định công cụ lưu trữ của bảng khi sử dụng MySQL# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
5Các thuộc tính
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
57 và # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
58 có thể được sử dụng để chỉ định bộ ký tự và đối chiếu cho bảng đã tạo khi sử dụng MySQL# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
6Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
59 có thể được sử dụng để chỉ ra rằng bảng phải là "tạm thời". Các bảng tạm thời chỉ hiển thị với phiên cơ sở dữ liệu của kết nối hiện tại và tự động bị hủy khi đóng kết nối# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
7Nếu bạn muốn thêm một "bình luận" vào một bảng cơ sở dữ liệu, bạn có thể gọi phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
60 trên thể hiện của bảng. Nhận xét bảng hiện chỉ được hỗ trợ bởi MySQL và Postgres# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
8Cập nhật bảng
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
61 trên mặt tiền # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
07 có thể được sử dụng để cập nhật các bảng hiện có. Giống như phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
49, phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
61 chấp nhận hai đối số. tên của bảng và một bao đóng nhận một phiên bản # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
52 mà bạn có thể sử dụng để thêm các cột hoặc chỉ mục vào bảng# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
9Đổi tên/xóa bảng
Để đổi tên một bảng cơ sở dữ liệu hiện có, hãy sử dụng phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
66# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
00Để xóa một bảng hiện có, bạn có thể sử dụng các phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
67 hoặc # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
68# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
01Đổi tên bảng bằng khóa ngoại
Trước khi đổi tên bảng, bạn nên xác minh rằng bất kỳ ràng buộc khóa ngoại nào trên bảng đều có tên rõ ràng trong tệp di chuyển của bạn thay vì để Laravel gán tên dựa trên quy ước. Mặt khác, tên ràng buộc khóa ngoại sẽ tham chiếu đến tên bảng cũ
Cột
Tạo cột
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
61 trên mặt tiền # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
07 có thể được sử dụng để cập nhật các bảng hiện có. Giống như phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
49, phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
61 chấp nhận hai đối số. tên của bảng và một bao đóng nhận một phiên bản # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
73 mà bạn có thể sử dụng để thêm các cột vào bảng# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
9Các loại cột có sẵn
Kế hoạch chi tiết của trình tạo lược đồ cung cấp nhiều phương pháp tương ứng với các loại cột khác nhau mà bạn có thể thêm vào bảng cơ sở dữ liệu của mình. Mỗi phương pháp có sẵn được liệt kê trong bảng dưới đây
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
74
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
75 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
76 [khóa chính] tăng tự động# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
03# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
77
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
78 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
79# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
04# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
80
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
81 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
82# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
83
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
84 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
85# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
05# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
86
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
87 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
88 với độ dài cho trước# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
06# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
89
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
90 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
91 [với múi giờ] với độ chính xác tùy chọn [tổng số]# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
07# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
92
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
93 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
91 với độ chính xác tùy chọn [tổng số]# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
08# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
95
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
96 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
97# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
09# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
98
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
99 tạo một cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
000 với độ chính xác [chữ số tổng] và tỷ lệ [chữ số thập phân] đã cho# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
80# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
001
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
002 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
003 với độ chính xác [tổng số] và tỷ lệ [chữ số thập phân] đã cho# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
81# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
004
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
005 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
006 với các giá trị hợp lệ đã cho# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
82# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
007
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
008 tạo một cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
009 với độ chính xác [tổng số] và tỷ lệ [chữ số thập phân] đã cho# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
83# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
010
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
011 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
76# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
84# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
013
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
014 thêm một cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
015 cho một lớp mô hình nhất định# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
85# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
016
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
017 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
018# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
86# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
019
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
020 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
021# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
87# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
022
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
023 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
024# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
88# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
025
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
026 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
027# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
89# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
028
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
029 là bí danh của phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
75. Theo mặc định, phương thức sẽ tạo một cột # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
029; # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
032
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
033 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
034 tăng tự động làm khóa chính# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
00# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
035
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
036 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
037# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
01# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
038
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
039 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
040# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
02# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
041
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
042 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
043# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
044
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
045 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
046# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
03# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
047
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
048 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
049# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
04# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
050
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
051 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
052# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
05# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
053
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
054 tạo một cột nhằm chứa địa chỉ MAC. Một số hệ thống cơ sở dữ liệu, chẳng hạn như PostgreSQL, có một loại cột dành riêng cho loại dữ liệu này. Các hệ thống cơ sở dữ liệu khác sẽ sử dụng một cột tương đương chuỗi# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
06# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
055
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
056 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
057 tăng tự động làm khóa chính# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
07# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
058
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
059 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
060# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
08# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
061
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
062 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
063# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
09# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
064
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
065 là một phương pháp thuận tiện có thêm cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
066 # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
76 và cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
068 # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
040Phương pháp này nhằm mục đích sử dụng khi xác định các cột cần thiết cho mối quan hệ Eloquent đa hình. Trong ví dụ sau, các cột
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
070 và # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
071 sẽ được tạo# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
50# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
072
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
073 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
074# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
51# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
075
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
076 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
077# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
52# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
078
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
079 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
080# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
53# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
081
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
082 là bí danh của phương thức dấu thời gian# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
54# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
083
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp này tương tự như phương pháp biến hình;
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
55# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
084
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp này tương tự như phương pháp uuidMorphs;
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
56# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
085
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
086 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
087# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
57# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
088
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
089 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
090# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
58# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
091
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
092 tạo một cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
093, nullable nhằm mục đích lưu trữ mã thông báo xác thực "nhớ tôi" hiện tại# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
094
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
095 tạo một cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
096 với danh sách các giá trị hợp lệ đã cho# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
59# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
097
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
098 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
099 tăng tự động làm khóa chínhphp artisan make:migration create_flights_table
00# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
800
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
801 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
802php artisan make:migration create_flights_table
01# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
803
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
804 thêm cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
805 # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
806 [với múi giờ] nullable với độ chính xác tùy chọn [tổng số]. Cột này nhằm lưu trữ dấu thời gian # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
805 cần thiết cho chức năng "xóa mềm" của Eloquentphp artisan make:migration create_flights_table
02# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
808
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
809 thêm một cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
805 # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
806 có thể null với độ chính xác tùy chọn [tổng số]. Cột này nhằm lưu trữ dấu thời gian # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
805 cần thiết cho chức năng "xóa mềm" của Eloquentphp artisan make:migration create_flights_table
03# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
813
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
814 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
040 có độ dài nhất địnhphp artisan make:migration create_flights_table
04# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
816
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
817 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
818php artisan make:migration create_flights_table
05# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
819
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
820 tạo một cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
821 [với múi giờ] với độ chính xác tùy chọn [tổng số]php artisan make:migration create_flights_table
06# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
822
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
823 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
821 với độ chính xác tùy chọn [tổng số]php artisan make:migration create_flights_table
07# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
825
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
826 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
806 [với múi giờ] với độ chính xác tùy chọn [tổng số]php artisan make:migration create_flights_table
08# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
828
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
829 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
806 với độ chính xác tùy chọn [tổng số]php artisan make:migration create_flights_table
09# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
831
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
832 tạo các cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
833 và # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
834 # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
806 [với múi giờ] với độ chính xác tùy chọn [tổng số]php artisan make:migration create_flights_table
90# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
836
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
837 tạo các cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
833 và # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
834 # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
806 với độ chính xác tùy chọn [tổng số]php artisan make:migration create_flights_table
91# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
841
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
842 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
843 tăng tự động làm khóa chínhphp artisan make:migration create_flights_table
92# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
844
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
845 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
846php artisan make:migration create_flights_table
93# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
847
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
848 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
849php artisan make:migration create_flights_table
94# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
850
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
851 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
76php artisan make:migration create_flights_table
95# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
853
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
854 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
855 với độ chính xác tùy chọn [tổng số] và tỷ lệ [chữ số thập phân]php artisan make:migration create_flights_table
96# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
856
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
857 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
034php artisan make:migration create_flights_table
97# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
859
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
860 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
057php artisan make:migration create_flights_table
98# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
862
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
863 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
099php artisan make:migration create_flights_table
99# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
865
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
866 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
843# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
20# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
868
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
869 là một phương pháp thuận tiện có thêm cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
066 # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
871 và cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
068 # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
040Phương pháp này được thiết kế để sử dụng khi xác định các cột cần thiết cho mối quan hệ Eloquent đa hình sử dụng mã định danh UUID. Trong ví dụ sau, các cột
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
070 và # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
071 sẽ được tạo# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
21# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
876
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
877 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
018# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
879
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
880 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
021# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
882
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
883 tạo cột tương đương # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
884# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
22Công cụ sửa đổi cột
Ngoài các loại cột được liệt kê ở trên, có một số "công cụ sửa đổi" cột mà bạn có thể sử dụng khi thêm một cột vào bảng cơ sở dữ liệu. Ví dụ: để tạo cột "nullable", bạn có thể sử dụng phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
885# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
23Bảng sau chứa tất cả các công cụ sửa đổi cột có sẵn. Danh sách này không bao gồm công cụ sửa đổi chỉ mục
Công cụ sửa đổi Mô tả# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
886Đặt cột "sau" một cột khác [MySQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
887Đặt cột INTEGER làm tăng tự động [khóa chính]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
888Chỉ định bộ ký tự cho cột [MySQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
889Chỉ định đối chiếu cho cột [MySQL/PostgreSQL/SQL Server]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
890Thêm nhận xét vào cột [MySQL/PostgreSQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
891Chỉ định giá trị "mặc định" cho cột. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
892Đặt cột "đầu tiên" trong bảng [MySQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
893Đặt giá trị bắt đầu của trường tăng tự động [MySQL/PostgreSQL]. ________ 1894 Đặt cột ở chế độ "ẩn" đối với truy vấn ________ 1895 [MySQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
896Cho phép chèn giá trị NULL vào cột. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
897Tạo cột đã tạo được lưu trữ [MySQL/PostgreSQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
898Đặt các cột INTEGER là UNSIGNED [MySQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
899Đặt các cột DẤU THỜI GIAN để sử dụng CURRENT_TIMESTAMP làm giá trị mặc định. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
000Đặt cột DẤU THỜI GIAN để sử dụng CURRENT_TIMESTAMP khi bản ghi được cập nhật. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
001Tạo cột được tạo ảo [MySQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
002Tạo cột nhận dạng với các tùy chọn trình tự được chỉ định [PostgreSQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
003Xác định mức độ ưu tiên của các giá trị chuỗi so với đầu vào cho một cột nhận dạng [PostgreSQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
004Đặt loại cột không gian thành # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
026 - loại mặc định là # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
006 [PostgreSQL]Biểu thức mặc định
Công cụ sửa đổi
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
007 chấp nhận một giá trị hoặc một phiên bản # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
008. Sử dụng phiên bản # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
009 sẽ ngăn Laravel gói giá trị trong dấu ngoặc kép và cho phép bạn sử dụng các chức năng cụ thể của cơ sở dữ liệu. Một tình huống mà điều này đặc biệt hữu ích là khi bạn cần gán các giá trị mặc định cho các cột JSON# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
24Cảnh báo
Hỗ trợ cho các biểu thức mặc định tùy thuộc vào trình điều khiển cơ sở dữ liệu, phiên bản cơ sở dữ liệu và loại trường của bạn. Vui lòng tham khảo tài liệu cơ sở dữ liệu của bạn. Ngoài ra, không thể kết hợp các biểu thức007 thô [sử dụng
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
011] với các thay đổi cột thông qua phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
012.
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Thứ tự cột
Khi sử dụng cơ sở dữ liệu MySQL, phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
013 có thể được sử dụng để thêm các cột sau một cột hiện có trong lược đồ# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
25Sửa đổi cột
điều kiện tiên quyết
Trước khi sửa đổi một cột, bạn phải cài đặt gói
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
014 bằng trình quản lý gói Composer. Thư viện Doctrine DBAL được sử dụng để xác định trạng thái hiện tại của cột và tạo các truy vấn SQL cần thiết để thực hiện các thay đổi được yêu cầu đối với cột của bạn# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
26Nếu bạn dự định sửa đổi các cột được tạo bằng phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
829, bạn cũng phải thêm cấu hình sau vào tệp cấu hình # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
016 của ứng dụng của mình# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
27Cảnh báo
Nếu ứng dụng của bạn đang sử dụng Microsoft SQL Server, vui lòng đảm bảo rằng bạn đã cài đặt017.
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Cập nhật thuộc tính cột
Phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
012 cho phép bạn sửa đổi loại và thuộc tính của các cột hiện có. Ví dụ: bạn có thể muốn tăng kích thước của cột # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
814. Để xem phương pháp # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
012 đang hoạt động, hãy tăng kích thước của cột # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
021 từ 25 lên 50. Để thực hiện điều này, chúng ta chỉ cần xác định trạng thái mới của cột và sau đó gọi phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
012# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
28Chúng tôi cũng có thể sửa đổi một cột thành nullable
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
29Cảnh báo
Có thể sửa đổi các loại cột sau.78,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
81,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
84,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
87,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
96,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
93,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
90,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
99,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
002,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
036,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
042,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
051,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
062,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
801,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
814,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
817,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
823,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
848,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
851,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
857,
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
863, và
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
880. Để sửa đổi loại cột
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
829, loại Doctrine phải được đăng ký.
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
Đổi tên cột
Để đổi tên một cột, bạn có thể sử dụng phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
046 được cung cấp bởi bản thiết kế trình tạo lược đồ. Trước khi đổi tên cột, đảm bảo rằng bạn đã cài đặt thư viện # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
014 thông qua trình quản lý gói Composer# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
60Cảnh báo
Đổi tên cột005 hiện không được hỗ trợ.
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
thả cột
Để thả một cột, bạn có thể sử dụng phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
049 trên bản thiết kế trình tạo lược đồ. Nếu ứng dụng của bạn đang sử dụng cơ sở dữ liệu SQLite, bạn phải cài đặt gói # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
014 thông qua trình quản lý gói Composer trước khi có thể sử dụng phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
049# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
61Bạn có thể loại bỏ nhiều cột khỏi một bảng bằng cách chuyển một mảng tên cột cho phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
049# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
62Cảnh báo
Không hỗ trợ loại bỏ hoặc sửa đổi nhiều cột trong một lần di chuyển khi sử dụng cơ sở dữ liệu SQLite.
Bí danh lệnh có sẵn
Laravel cung cấp một số phương thức thuận tiện liên quan đến việc loại bỏ các loại cột phổ biến. Mỗi phương pháp này được mô tả trong bảng dưới đây
CommandDescription# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
053Thả cột # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
054 và # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
055. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
056Thả cột # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
057. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
058Thả cột # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
805. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
060Bí danh của phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
061. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
062Thả cột # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
833 và # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
834. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
065Bí danh của phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
066chỉ số
Tạo chỉ mục
Trình tạo lược đồ Laravel hỗ trợ một số loại chỉ mục. Ví dụ sau tạo một cột
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
067 mới và chỉ định rằng các giá trị của nó phải là duy nhất. Để tạo chỉ mục, chúng ta có thể xâu chuỗi phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
068 vào định nghĩa cột# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
63Ngoài ra, bạn có thể tạo chỉ mục sau khi xác định cột. Để làm như vậy, bạn nên gọi phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
068 trên bản thiết kế trình tạo lược đồ. Phương thức này chấp nhận tên của cột sẽ nhận được một chỉ mục duy nhấtBạn thậm chí có thể chuyển một mảng các cột tới một phương thức chỉ mục để tạo chỉ mục tổng hợp [hoặc tổng hợp]
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
64Khi tạo chỉ mục, Laravel sẽ tự động tạo tên chỉ mục dựa trên tên bảng, tên cột và loại chỉ mục, nhưng bạn có thể truyền đối số thứ hai cho phương thức để tự chỉ định tên chỉ mục
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
65Các loại chỉ mục có sẵn
Lớp kế hoạch xây dựng lược đồ của Laravel cung cấp các phương thức để tạo từng loại chỉ mục được hỗ trợ bởi Laravel. Mỗi phương thức chỉ mục chấp nhận một đối số thứ hai tùy chọn để chỉ định tên của chỉ mục. Nếu bỏ qua, tên sẽ được lấy từ tên của bảng và [các] cột được sử dụng cho chỉ mục, cũng như loại chỉ mục. Mỗi phương pháp lập chỉ mục có sẵn được mô tả trong bảng bên dưới
LệnhMô tả# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
070Thêm khóa chính. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
071Thêm phím tổng hợp. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
072Thêm một chỉ mục duy nhất. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
073Thêm một chỉ mục. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
074Thêm chỉ mục toàn văn [MySQL/PostgreSQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
075Thêm chỉ mục toàn văn của ngôn ngữ đã chỉ định [PostgreSQL]. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
076Thêm chỉ mục không gian [ngoại trừ SQLite]Độ dài chỉ mục & MySQL/MariaDB
Theo mặc định, Laravel sử dụng bộ ký tự
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
077. Nếu bạn đang chạy phiên bản MySQL cũ hơn 5. 7. 7 hoặc MariaDB cũ hơn 10. 2. 2, bạn có thể cần định cấu hình thủ công độ dài chuỗi mặc định được tạo bởi quá trình di chuyển để MySQL tạo chỉ mục cho chúng. Bạn có thể định cấu hình độ dài chuỗi mặc định bằng cách gọi phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
078 trong phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
079 của lớp # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
080 của bạn# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
66Ngoài ra, bạn có thể bật tùy chọn
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
081 cho cơ sở dữ liệu của mình. Tham khảo tài liệu về cơ sở dữ liệu của bạn để biết hướng dẫn về cách bật tùy chọn này đúng cáchĐổi tên chỉ mục
Để đổi tên một chỉ mục, bạn có thể sử dụng phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
082 được cung cấp bởi bản thiết kế trình tạo lược đồ. Phương thức này chấp nhận tên chỉ mục hiện tại làm đối số đầu tiên và tên mong muốn làm đối số thứ hai# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
67Giảm chỉ số
Để loại bỏ một chỉ mục, bạn phải chỉ định tên của chỉ mục. Theo mặc định, Laravel tự động gán tên chỉ mục dựa trên tên bảng, tên cột được lập chỉ mục và loại chỉ mục. Dưới đây là một số ví dụ
CommandDescription# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
083Xóa khóa chính khỏi bảng "người dùng". # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
084Xóa chỉ mục duy nhất khỏi bảng "người dùng". # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
085Xóa chỉ mục cơ bản khỏi bảng "geo". # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
086Xóa chỉ mục toàn văn từ bảng "bài đăng". # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
087Xóa chỉ mục không gian khỏi bảng "geo" [ngoại trừ SQLite]Nếu bạn chuyển một mảng các cột vào một phương thức bỏ chỉ mục, tên chỉ mục thông thường sẽ được tạo dựa trên tên bảng, cột và loại chỉ mục
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
68Ràng buộc khóa ngoại
Laravel cũng cung cấp hỗ trợ để tạo các ràng buộc khóa ngoại, được sử dụng để buộc tính toàn vẹn tham chiếu ở cấp cơ sở dữ liệu. Ví dụ: hãy xác định cột
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
088 trên bảng # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
089 tham chiếu cột # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
029 trên bảng # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
091# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
69Vì cú pháp này khá dài dòng, Laravel cung cấp các phương thức bổ sung, ngắn gọn hơn sử dụng các quy ước để mang lại trải nghiệm tốt hơn cho nhà phát triển. Khi sử dụng phương pháp
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
011 để tạo cột của bạn, ví dụ trên có thể được viết lại như vậy# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
00Phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
011 tạo một cột tương đương với # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
76, trong khi phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
095 sẽ sử dụng các quy ước để xác định tên bảng và cột được tham chiếu. Nếu tên bảng của bạn không khớp với quy ước của Laravel, bạn có thể chỉ định tên bảng bằng cách chuyển nó làm đối số cho phương thức # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
095# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
01Bạn cũng có thể chỉ định hành động mong muốn cho các thuộc tính "khi xóa" và "khi cập nhật" của ràng buộc
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
02Một cú pháp thay thế, biểu cảm cũng được cung cấp cho những hành động này
Phương thức Mô tả# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
097Các bản cập nhật sẽ xếp tầng. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
098Các bản cập nhật nên bị hạn chế. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
099Việc xóa sẽ xếp tầng. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
500Delete nên được hạn chế. # Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
501Deletes nên đặt giá trị khóa ngoại thành nullMọi công cụ sửa đổi cột bổ sung phải được gọi trước phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
095# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
02Đánh rơi khóa ngoại
Để xóa khóa ngoại, bạn có thể sử dụng phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
503, chuyển tên của ràng buộc khóa ngoại cần xóa làm đối số. Các ràng buộc khóa ngoại sử dụng quy ước đặt tên giống như các chỉ mục. Nói cách khác, tên ràng buộc khóa ngoại dựa trên tên của bảng và các cột trong ràng buộc, theo sau là hậu tố "_foreign"# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
04Ngoài ra, bạn có thể chuyển một mảng chứa tên cột chứa khóa ngoại cho phương thức
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
503. Mảng sẽ được chuyển đổi thành tên ràng buộc khóa ngoại bằng cách sử dụng quy ước đặt tên ràng buộc của Laravel# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
05Chuyển đổi các ràng buộc khóa ngoại
Bạn có thể bật hoặc tắt các ràng buộc khóa ngoại trong quá trình di chuyển của mình bằng cách sử dụng các phương pháp sau
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
06Cảnh báo
SQLite tắt các ràng buộc khóa ngoại theo mặc định. Khi sử dụng SQLite, hãy đảm bảo bật hỗ trợ khóa ngoại trong cấu hình cơ sở dữ liệu của bạn trước khi thử tạo chúng trong quá trình di chuyển của bạn. Ngoài ra, SQLite chỉ hỗ trợ khóa ngoại khi tạo bảng chứ không hỗ trợ khi bảng bị thay đổi.
Sự kiện
Để thuận tiện, mỗi thao tác di chuyển sẽ gửi một sự kiện. Tất cả các sự kiện sau mở rộng lớp cơ sở
# Dump the current database schema and prune all existing migrations...
php artisan schema:dump --prune
505