📜  php artisan 在表格中添加行 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:37.200000             🧑  作者: Mango

代码示例1
First, create the file via Artisan (or do it manually if you like):
    php artisan make:migration name_of_the_generated_file --table=table_to_be_added_to
  
Edit the file and add on the 'function up()' so the column will be created once you do 'migrate':
    $table->define_the_type('name_of_the_column')->nullable();
    ps.: 'define_the_type' needs to be changed by the type of field you want to create.
    ps.: 'name_of_the_column' needs to be changed by the name you want the column to have.
  
Then, add on the 'function down()' so we can remove the column with the 'rollback' if needed:
    $table->dropColumn('name_of_the_column');