"Laravel 데이터베이스: 마이그레이션"의 두 판 사이의 차이

51번째 줄: 51번째 줄:
*[[artisan make:migration]]
*[[artisan make:migration]]
*[[artisan migrate]]
*[[artisan migrate]]
*[[Flyway]]
*[[스키마 마이그레이션]]


==참고 자료==
==참고 자료==

2016년 11월 24일 (목) 14:17 판

1 개요

라라벨 Database Migration
라라벨 DB 마이그레이션

2 마이그레이션 생성

  • artisan명령을 통한 마이그레이션 생성
php artisan make:migration create_tasks_table --create=tasks
  • 마이그레이션 작성(수정)
<?php

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

class CreateTasksTable extends Migration
{
    public function up()
    {
        Schema::create('tasks', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::drop('tasks');
    }
}
  • 마이그레이션 확인 후 수행
php artisan migrate:status
php artisan migrate

3 DB 마이그레이션 변경

  • artisan 명령을 통한 DB에 생성된 마이그레이션 삭제후 재 마이그레이션
  • 리셋, 마이그레이션 과정을 거치기 때문에 DB의 모든 데이터가 삭제됨을 주의 할 것
php artisan migrate:refresh

4 같이 보기

5 참고 자료

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