Làm cách nào để xác định độ dài chuỗi trong quá trình di chuyển Laravel?

Trong hướng dẫn này, tôi sẽ học cho bạn cách thay đổi độ dài bằng cách sử dụng di chuyển laravel. bạn có thể dễ dàng và đơn giản thay đổi độ dài bằng cách sử dụng di chuyển laravel

Bài viết đơn giản này minh họa về việc thay đổi chiều dài cột di chuyển laravel. Chúng tôi sẽ sử dụng độ dài cột thay đổi di chuyển của laravel. Ở đây bạn sẽ học cách di chuyển độ dài cột thay đổi của laravel. Tôi sẽ chỉ cho bạn về việc di chuyển thay đổi độ dài cột trong laravel

chúng tôi đang quản lý độ dài phù hợp của loại dữ liệu nên nó rất hữu ích cho việc lưu trữ db. chúng ta có thể tiết kiệm không gian. nhưng nếu bạn đã thêm độ dài như 50 với kiểu dữ liệu chuỗi và sau này bạn cần nâng cấp nó thì bạn sẽ làm như thế nào

Tôi đã tìm kiếm nguồn của lớp BluePrint. Không có phương thức nào như "alterColumn" hoặc "changeColumn". [

Cập nhật lần cuối 7 tháng trước

ai đó nói với tôi rằng tôi phải sử dụng các truy vấn thô

    public function up[] {
        DB::statement['ALTER TABLE `users` MODIFY COLUMN `password` VARCHAR[100]'];
    }

Cập nhật lần cuối 7 tháng trước

Đăng nhập để tham gia vào chủ đề này

Giả sử bạn sẽ tạo một blog và có một trường. Vì vậy, bạn cần đặt độ dài chuỗi tối đa trong bảng

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

26 của mình cho cột

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

27. Vì vậy, trong ví dụ này, tôi sẽ chỉ cho bạn cách đặt độ dài chuỗi tối đa trong quá trình di chuyển laravel. Tôi sẽ chỉ cho bạn độ dài tối đa của chuỗi di chuyển Laravel. Laravel cung cấp nhiều phương thức để thực hiện điều đó như loại 

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

28 

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

29 và

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

30

Bây giờ, giả sử bạn cần một cột văn bản trung bình thì bạn có thể đặt

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};

Bây giờ, giả sử bạn cần một cột văn bản đơn giản thì bạn có thể đặt

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};

Bây giờ, giả sử bạn không biết mình sẽ đăng bao nhiêu văn bản cho một bài đăng trên blog. Sau đó, bạn có thể sử dụng

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

29

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};

Đọc thêm. Laravel Migration Tăng kích thước cột Ví dụ

Phần kết luận

Tôi đã cố gắng thảo luận về khái niệm rõ ràng về độ dài tối đa của chuỗi di chuyển laravel. Bây giờ chúng ta đã biết độ dài tối đa của chuỗi di chuyển laravel. Hy vọng bài hướng dẫn cách đặt độ dài chuỗi tối đa trong laravel migration này sẽ giúp ích cho bạn

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

09 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ệu

Tạ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

10 để 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

11 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ển

php 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

12 khi thực hiện lệnh

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

10. Đường dẫn đã cho phải liên quan đến đường dẫn cơ sở của ứng dụng của bạn

Lưu ý
Sơ khai di chuyển có thể được tùy chỉnh bằng cách sử dụng.

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

11 của bạn trở nên cồng kềnh với hàng trăm lần di chuyển. 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

15

# 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

16 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 thi, 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 tệp lược đồ bằ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ộ

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
4

Bạ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

17 và

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

18. Phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

17 đượ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

18 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

17

Trong 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

09,. 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

23

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
2

Đặ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

24 cho quá trình di chuyển của mình

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
4

Di 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 Artisan

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

25

Nế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

26

Nế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

27 cho lệnh

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

25

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
9

Cô 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

29 khi gọi lệnh

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

25

Khi tùy chọn

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

29 đượ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

25 trong khi khóa đó được giữ sẽ không thực thi;

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
4

Cả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ộ nhớ đệm

# 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,

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

36,

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

37 hoặc

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

38 làm trình điều khiển bộ nhớ đệ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

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

39

Quay 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

40. 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ển

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

3

Bạ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

41 cho lệnh

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

40. 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

6

Lệnh

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

43 sẽ khôi phục tất cả các lần di chuyển của ứng dụng của bạn

Quay 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

44 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

25. 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

0

Bạn có thể quay lại 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

41 cho lệnh

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

47. 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

0

Bỏ 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

48 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

25

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

1

Cảnh báo
Lệnh

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

48 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.

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 pháp

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

51 trên mặt tiền

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

09. Phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

51 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

54 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

2

Khi tạo bảng, bạn có thể sử dụng bất kỳ trình tạo lược đồ nào để 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

55 và

# 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

3

Kế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

57

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

4

Ngoà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

58 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

5

Các thuộc tính

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

59 và

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

60 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

6

Phương pháp

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

61 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

7

Nế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

62 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

8

Cập nhật bảng

Phương pháp

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

63 trên mặt tiền

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

09 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

51, phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

63 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

54 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

68

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
40

Để 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

69 hoặc

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

70

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
41

Đổ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

63 trên mặt tiền

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

09 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

51, phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

63 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

75 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

9

Cá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

76

Phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

77 tạo cột tương đương

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

78 [khóa chính] tăng tự động

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
43

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

79

Phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

80 tạo cột tương đương

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

81

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
44

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

82

Phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

83 tạo cột tương đương

# 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

85

Phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

86 tạo cột tương đương

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

87

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
45

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

88

Phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

89 tạo cột tương đương

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

90 với độ dài cho trước

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
46

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

91

Phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

92 tạo cột tương đương

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

93 [với múi giờ] với độ chính xác tùy chọn [tổng số]

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
47

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

94

Phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

95 tạo cột tương đương

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

93 với độ chính xác tùy chọn [tổng số]

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
48

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

97

Phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

98 tạo cột tương đương

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

99

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
49

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
400

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
401 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
402 với độ chính xác [tổng số] và tỷ lệ [chữ số thập phân] đã cho

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
20

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
403

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
404 tạo một cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
405 với độ chính xác [tổng số] và tỷ lệ [chữ số thập phân] đã cho

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
21

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
406

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
407 tạo một cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
408 với các giá trị hợp lệ đã cho

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
22

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
409

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
410 tạo một cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
411 với độ chính xác [tổng số] và tỷ lệ [chữ số thập phân] đã cho

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
23

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
412

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
413 tạo cột tương đương

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

78

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
24

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
415

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
416 thêm một cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
417 cho một lớp mô hình nhất định

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
25

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
418

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
419 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
420

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
26

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
421

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
422 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
423

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
27

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
424

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
425 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
426

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
28

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
427

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
428 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
429

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
29

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
430

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
431 là bí danh của phương thức

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

77. Theo mặc định, phương thức sẽ tạo một cột
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
431;

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
434

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
435 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
436 tăng tự động làm khóa chính

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
40

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
437

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
438 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
439

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
41

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
440

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
441 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
442

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
42

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
443

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
444 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
445

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
446

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
447 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
448

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
43

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
449

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
450 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
451

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
44

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
452

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
453 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
454

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
45

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
455

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
456 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

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
46

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
457

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
458 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
459 tăng tự động làm khóa chính

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
47

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
460

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
461 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
462

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
48

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
463

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
464 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
465

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
49

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
466

Phương pháp

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
467 là một phương pháp thuận tiện có thêm cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
468

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

78 và cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
470
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
442

Phươ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

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
472 và
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
473 sẽ được tạo

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
90

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
474

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
475 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
476

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
91

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
477

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
478 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
479

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
92

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
480

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
481 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
482

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
93

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
483

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
484 là bí danh của phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
94

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
485

Phương pháp tương tự như phương pháp;

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
95

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
486

Phương pháp tương tự như phương pháp;

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
96

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
487

Phương pháp tương tự như phương pháp;

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
97

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
488

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
489 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
490

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
98

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
491

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
492 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
493

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
99

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
494

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
495 tạo một cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
496, nullable nhằm mục đích lưu trữ "nhớ tôi" hiện tại

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
497

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
498 tạo một cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
499 với danh sách các giá trị hợp lệ đã cho

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
40

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
200

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
201 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
202 tăng tự động làm khóa chính

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
41

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
203

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
204 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
205

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
42

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
206

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
207 thêm một cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
208
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
209 [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
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
208 cần thiết cho chức năng "xóa mềm" của Eloquent

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
43

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
211

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
212 thêm một cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
208
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
209 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
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
208 cần thiết cho chức năng "xóa mềm" của Eloquent

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
44

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
216

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
217 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
442 có độ dài đã cho

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
45

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
219

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
220 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
221

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
46

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
222

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
223 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
224 [với múi giờ] với độ chính xác tùy chọn [tổng số]

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
47

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
225

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
226 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
224 với độ chính xác tùy chọn [tổng số]

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
48

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
228

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
229 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
209 [với múi giờ] với độ chính xác tùy chọn [tổng số]

id[];
            $table->longText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
49

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
231

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
232 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
209 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

30

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
234

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
235 tạo các cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
236 và
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
237
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
209 [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

31

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
239

Phương pháp

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
240 tạo các cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
236 và
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
237
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
209 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

32

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
244

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
245 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
246 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

33

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
247

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
248 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
249

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

34

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
250

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
251 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
252

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

35

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
253

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
254 tạo cột tương đương

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

78

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

36

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
256

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
257 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
258 với độ chính xác tùy chọn [tổng số] và tỷ lệ [chữ số thập phân]

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

37

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
259

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
260 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
436

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

38

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
262

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
263 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
459

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

39

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
265

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
266 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
202

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

60

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
268

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
269 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
246

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

61

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
271

Phương pháp

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
272 là một phương pháp thuận tiện có thêm cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
468
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
274 và cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
470
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
442

Phươ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 sử dụng mã định danh ULID. Trong ví dụ sau, các cột

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
472 và
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
473 sẽ được tạo

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

62

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
279

Phương pháp

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
280 là một phương pháp thuận tiện có thêm cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
468
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
282 và cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
470
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
442

Phươ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

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
472 và
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
473 sẽ được tạo

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

63

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
287

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
288 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
420

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
290

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
291 tạo cột tương đương
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
423

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
293

Phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
294 tạo cột tương đương
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
295

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

64

Cô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

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
296

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

65

Bả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 Mô tả
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
297Đặt cột "sau" một cột khác [MySQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
298Đặt cột INTEGER làm tăng tự động [khóa chính].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
299Chỉ định bộ ký tự cho cột [MySQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
400Chỉ định đối chiếu cho cột [MySQL/PostgreSQL/SQL Server].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
401Thêm nhận xét vào cột [MySQL/PostgreSQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
402Chỉ định giá trị "mặc định" cho cột.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
403Đặt cột "đầu tiên" trong bảng [MySQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
404Đặt giá trị bắt đầu của trường tăng tự động [MySQL/PostgreSQL]. ________ 2405 Biến cột thành "ẩn" với ________ 2406 truy vấn [MySQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
407Cho phép chèn giá trị NULL vào cột.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
408Tạo cột đã tạo được lưu trữ [MySQL/PostgreSQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
409Đặt các cột INTEGER là UNSIGNED [MySQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
410Đặt cột DẤU THỜI GIAN để sử dụng CURRENT_TIMESTAMP làm giá trị mặc định.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
411Đặt cột DẤU THỜI GIAN để sử dụng CURRENT_TIMESTAMP khi bản ghi được cập nhật.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
412Tạo cột được tạo ảo [MySQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
413Tạo cột nhận dạng với các tùy chọn trình tự được chỉ định [PostgreSQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
414Xá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].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
415Đặt loại cột không gian thành
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
428 - loại mặc định là
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
417 [PostgreSQL]

Biểu thức mặc định

Công cụ sửa đổi

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
418 chấp nhận một giá trị hoặc một thể hiện
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
419. Sử dụng phiên bản
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
420 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

66

Cả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ức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
418 thô [sử dụng
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
422] với các thay đổi cột thông qua phương thức
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
423.

Thứ tự cột

Khi sử dụng cơ sở dữ liệu MySQL, phương pháp

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
424 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

67

Sử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

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
425 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

68

Nếu bạn định sửa đổi các cột được tạo bằng phương pháp

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
232, bạn cũng phải thêm cấu hình sau vào tệp cấu hình
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
427 của ứng dụng của mình

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

69

Cả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 đặt

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
428.

Cập nhật thuộc tính cột

Phương pháp

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
423 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
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
217. Để xem phương pháp
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
423 đang hoạt động, hãy tăng kích thước của cột
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
432 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
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
423

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

00

Chú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

01

Cảnh báo
Có thể sửa đổi các loại cột sau.

# 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

83,

# 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

89,

# 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

95,

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

92,
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
401,
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
404,
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
438,
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
444,
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
453,
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
464,
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
204,
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
217,
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
220,
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
226,
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
251,
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
254,
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
260,
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
266, và
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
291. Để sửa đổi cột
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
232, hãy nhập a.

Đổi tên cột

Để đổi tên cột, bạn có thể sử dụng phương pháp

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
457 do trình tạo lược đồ cung cấp

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

02

Đổi tên cột trên cơ sở dữ liệu kế thừa

Nếu bạn đang chạy cài đặt cơ sở dữ liệu cũ hơn một trong các bản phát hành sau, bạn nên đảm bảo rằng bạn đã cài đặt thư viện

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
425 thông qua trình quản lý gói Composer trước khi đổi tên cột

  • MySQL <
    id[];
                $table->text['column'];
                $table->timestamps[];
            }];
        }
    
        public function down[]
        {
            Schema::dropIfExists['posts'];
        }
    };
    
    459
  • MariaDB <
    id[];
                $table->text['column'];
                $table->timestamps[];
            }];
        }
    
        public function down[]
        {
            Schema::dropIfExists['posts'];
        }
    };
    
    460
  • SQLite <
    id[];
                $table->text['column'];
                $table->timestamps[];
            }];
        }
    
        public function down[]
        {
            Schema::dropIfExists['posts'];
        }
    };
    
    461

thả cột

Để thả một cột, bạn có thể sử dụng phương pháp

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
462 trên trình tạo lược đồ

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

03

Bạ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

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
462

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

04

Bỏ cột trên cơ sở dữ liệu kế thừa

Nếu bạn đang chạy phiên bản SQLite trước

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
464, bạn phải cài đặt gói
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
425 thông qua trình quản lý gói Composer trước khi có thể sử dụng phương thức
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
462. Việc loại bỏ hoặc sửa đổi nhiều cột trong một lần di chuyển trong khi sử dụng gói này không được hỗ trợ

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
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
467Thả cột
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
468 và
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
469.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
470Thả cột
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
471.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
472Thả cột
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
208.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
474Bí danh của phương thức
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
475.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
476Thả cột
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
236 và
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
237.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
479Bí danh của phương thức
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
480

chỉ mục

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

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
481 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
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
482 vào định nghĩa cột

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

05

Ngoà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

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
482 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ất

Bạ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

06

Khi 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

07

Cá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ả
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
484Thêm khóa chính.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
485Thêm phím tổng hợp.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
486Thêm một chỉ mục duy nhất.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
487Thêm một chỉ mục.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
488Thêm chỉ mục toàn văn [MySQL/PostgreSQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
489Thêm chỉ mục toàn văn của ngôn ngữ đã chỉ định [PostgreSQL].
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
490Thê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ự

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
491. 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
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
492 trong phương thức
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
493 của lớp
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
494 của bạn

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

08

Ngoài ra, bạn có thể bật tùy chọn

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
495 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

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
496 đượ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

09

Cảnh báo
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

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
425 thông qua trình quản lý gói Composer trước khi có thể sử dụng phương pháp
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
496.

Giả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
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
499Xóa khóa chính khỏi bảng "người dùng".
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
900Xóa một chỉ mục duy nhất khỏi bảng "người dùng".
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
901Xóa chỉ mục cơ bản khỏi bảng "geo".
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
902Xóa chỉ mục toàn văn từ bảng "bài đăng".
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
903Xó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

00

Rà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

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
904 trên bảng
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
905 tham chiếu cột
id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
431 trên bảng
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
907

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

01

Vì 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

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
413 để 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

02

Phương thức

id[];
            $table->mediumText['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
413 tạo cột tương đương

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

78, trong khi phương thức
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
911 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
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
911

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

03

Bạ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

04

Mộ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 pháp Mô tả
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
913Các bản cập nhật nên xếp tầng.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
914Các bản cập nhật nên bị hạn chế.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
915Xóa nên xếp tầng.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
916Việc xóa nên bị hạn chế.
id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
917Deletes nên đặt giá trị khóa ngoại thành null

Mọi bổ sung phải được gọi trước phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
911

# Dump the current database schema and prune all existing migrations...

php artisan schema:dump --prune

04

Đánh rơi khóa ngoại

Để xóa khóa ngoại, bạn có thể sử dụng phương thức

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
919, 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

06

Ngoà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

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
919. 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

07

Chuyể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

08

Cả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 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ở

id[];
            $table->text['column'];
            $table->timestamps[];
        }];
    }

    public function down[]
    {
        Schema::dropIfExists['posts'];
    }
};
921

Làm cách nào để đặt độ dài chuỗi khi di chuyển Laravel?

Làm cách nào để thay đổi độ dài cột bằng Laravel Migration? .
di cư. sử dụng Chiếu sáng\Hỗ trợ\Mặt tiền\Lược đồ;.
Thay đổi độ dài cột bằng Migration. bây giờ, chúng ta cần cập nhật chuỗi tiêu đề có độ dài 50 thành 100. .
Cài đặt gói Composer. nhà soạn nhạc yêu cầu học thuyết/dbal
di cư. đọc thêm. Làm cách nào để cập nhật giá trị Enum trong Laravel Migration?

Làm cách nào để lấy độ dài chuỗi trong Laravel?

Bạn có thể sử dụng phương thức Str của trình trợ giúp laravel. length[] để tìm độ dài chuỗi hoặc bạn có thể sử dụng phương thức php strlen[].

Độ dài chuỗi mặc định trong Laravel là bao nhiêu?

Laravel giả sử utf8 , do đó, nó đặt các cột thành 255 theo mặc định, nhưng quy ước này cần được ghi đè bằng utf8mb4.

Làm cách nào để di chuyển trong Laravel mà không mất dữ liệu?

Đặt chi tiết cột của bạn ở đó, chạy di chuyển bằng cách sử dụng di chuyển thủ công php và đó là tất cả. Bạn sẽ có cột mới này trong bảng người dùng của mình mà không làm mất dữ liệu đã lưu trữ trước đó

Chủ Đề