"라라벨 artisan make:migration --create"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 5개는 보이지 않습니다)
2번째 줄: 2번째 줄:
;<nowiki>라라벨 artisan make:migration --create</nowiki>
;<nowiki>라라벨 artisan make:migration --create</nowiki>
*[[artisan make:migration]]에 <code>--create</code> 옵션을 붙인 것
*[[artisan make:migration]]에 <code>--create</code> 옵션을 붙인 것
* migration 파일의 up() 메소드에 <code>Schema::create('테이블명', ...)</code> 구문을 기입해줌
* migration 파일의 down() 메소드에 <code>Schema::drop('테이블명', ...)</code> 구문을 기입해줌


<source lang='console'>
==예시==
<syntaxhighlight lang='console'>
root@zetawiki:/var/www/laravel# php artisan make:migration create_photos_table --create=photos
root@zetawiki:/var/www/laravel# php artisan make:migration create_photos_table --create=photos
Created Migration: 2016_05_15_090058_create_photos_table
Created Migration: 2016_05_15_090058_create_photos_table
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
root@zetawiki:/var/www/laravel# php artisan migrate:status
root@zetawiki:/var/www/laravel# php artisan migrate:status
+------+------------------------------------------------+
+------+------------------------------------------------+
16번째 줄: 19번째 줄:
| N    | 2016_05_15_090058_create_photos_table          |
| N    | 2016_05_15_090058_create_photos_table          |
+------+------------------------------------------------+
+------+------------------------------------------------+
</source>
</syntaxhighlight>
<source lang='console'>
<syntaxhighlight lang='console'>
root@zetawiki:/var/www/laravel# cat database/migrations/2016_05_15_090058_create_photos_table.php
root@zetawiki:/var/www/laravel# cat database/migrations/2016_05_15_090058_create_photos_table.php
<?php
<?php
49번째 줄: 52번째 줄:
     }
     }
}
}
</source>
</syntaxhighlight>


==같이 보기==
==같이 보기==
*[[artisan make:migration --table]]
*[[artisan make:migration]]
*[[artisan migrate]]
*[[artisan migrate]]
*[[artisan migrate:status]]
*[[artisan migrate:status]]
57번째 줄: 62번째 줄:
*[[artisan 명령어]]
*[[artisan 명령어]]


[[분류: Laravel]]
[[분류: 라라벨 artisan]]

2020년 11월 2일 (월) 02:58 기준 최신판

1 개요[ | ]

라라벨 artisan make:migration --create
  • artisan make:migration--create 옵션을 붙인 것
  • migration 파일의 up() 메소드에 Schema::create('테이블명', ...) 구문을 기입해줌
  • migration 파일의 down() 메소드에 Schema::drop('테이블명', ...) 구문을 기입해줌

2 예시[ | ]

root@zetawiki:/var/www/laravel# php artisan make:migration create_photos_table --create=photos
Created Migration: 2016_05_15_090058_create_photos_table
root@zetawiki:/var/www/laravel# php artisan migrate:status
+------+------------------------------------------------+
| Ran? | Migration                                      |
+------+------------------------------------------------+
| Y    | 2014_10_12_100000_create_password_resets_table |
| Y    | 2015_10_27_141258_create_tasks_table           |
| N    | 2016_05_15_090058_create_photos_table          |
+------+------------------------------------------------+
root@zetawiki:/var/www/laravel# cat database/migrations/2016_05_15_090058_create_photos_table.php
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePhotosTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('photos', function (Blueprint $table) {
            $table->increments('id');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('photos');
    }
}

3 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}