# Database: Migrations

- [Introduction](#introduction)
- [Generating migrations](#generating-migrations)
- [Migration structure](#migration-structure)
    - [Framework tables](#framework-tables)
    - [Changing a migration that has run](#changing-a-migration-that-has-run)
    - [Running a migration without a transaction](#running-a-migration-without-a-transaction)
    - [Supporting several databases](#supporting-several-databases)
- [Running migrations](#running-migrations)
    - [Creating a missing database](#creating-a-missing-database)
    - [Checking which migrations have run](#checking-which-migrations-have-run)
    - [Rebuilding the database](#rebuilding-the-database)
    - [Choosing a connection](#choosing-a-connection)
    - [Running migrations in production](#running-migrations-in-production)
- [Registering migrations](#registering-migrations)
    - [Package migrations](#package-migrations)
- [Squashing migrations](#squashing-migrations)
- [Testing](#testing)

<a name="introduction"></a>

## Introduction


마이그레이션은 데이터베이스의 버전 관리와 같습니다. 팀이 스키마를 코드로 정의하고 공유하게 해줍니다. 변경 사항을 받은 팀원에게 로컬 데이터베이스에 컬럼을 추가하라고 알려줘야 했다면, 마이그레이션이 해결하는 문제를 겪은 것입니다.


각 마이그레이션은 `database/migrations`에 있는 Go 함수이며, [schema builder](/go/docs/schema) 또는 SQL로 스키마를 변경합니다. Laravel은 실행한 각 마이그레이션을 `migrations` 테이블에 기록하므로, `migrate` 명령어는 데이터베이스에서 아직 실행하지 않은 마이그레이션만 실행합니다. 마이그레이션은 애플리케이션 바이너리에 함께 컴파일되므로, 배포된 서버에서는 소스 파일 없이 실행할 수 있습니다.

<a name="generating-migrations"></a>

## Generating migrations


`make:migration` 명령어로 마이그레이션을 생성할 수 있습니다. 생성 순서대로 실행되도록 현재 UTC 시각으로 시작하는 이름의 파일을 `database/migrations`에 만듭니다.

```shell
laravel make:migration create_posts_table
```


이 명령어는 새 마이그레이션을 `database/migrations/migrations.go`의 `All` 목록에도 추가하며, 애플리케이션은 이 목록에서 마이그레이션을 찾습니다. 목록에 대한 자세한 내용은 [registering migrations](#registering-migrations) 절을 참고하세요.


`make:migration`은 마이그레이션 이름으로 대상 테이블과 테이블 생성 여부를 추론합니다. `create_posts_table` 또는 `create_posts` 같은 이름은 `id`와 타임스탬프가 있는 새 `posts` 테이블을 생성하는 코드로 시작합니다. `add_slug_to_posts_table` 같은 이름은 마지막 `_to_`, `_from_`, `_in_` 뒤에서 테이블 이름을 가져와 `posts`에 대한 빈 `schema.Alter`로 시작합니다.


이름에서 테이블을 알 수 없으면 빈 마이그레이션이 생성됩니다. 새 테이블에는 `--create=posts`, 기존 테이블에는 `--table=posts`를 사용하여 테이블을 직접 지정할 수도 있습니다:

```shell
laravel make:migration add_featured_flag --table=posts
```

<a name="migration-structure"></a>

## Migration structure


각 마이그레이션은 컨텍스트를 받고 오류를 반환하는 함수이며, Laravel은 데이터베이스마다 이 함수를 한 번 호출합니다. `make:migration`은 마이그레이션에 따라 함수 이름을 지정하므로 `create_posts_table`은 `createPostsTable`이 됩니다. 예를 들어 다음 마이그레이션은 PostgreSQL, MySQL, MariaDB, SQLite에 맞는 SQL을 작성하는 [schema builder](/go/docs/schema)로 `posts` 테이블을 생성합니다:

```go
// database/migrations/2026_11_10_120000_create_posts_table.go
package migrations

import (
	"context"

	"go.laravel.com/schema"
)

func createPostsTable(ctx context.Context) error {
	return schema.Create(ctx, "posts", func(table *schema.Blueprint) {
		table.ID()
		table.ForeignID("user_id").Constrained().CascadeOnDelete()
		table.String("title")
		table.Timestamp("published_at").Nullable()
		table.Timestamps()

		table.Index("user_id", "published_at")
	})
}
```


테이블에 추가할 수 있는 모든 컬럼 타입, 인덱스, 제약 조건은 [schema builder guide](/go/docs/schema)를 참고하세요. 마이그레이션에서도 애플리케이션의 다른 부분처럼 [`db.Exec`](/go/docs/database#running-queries), [query builder](/go/docs/queries), [models](/go/docs/models)로 데이터베이스를 쿼리할 수 있습니다. 예를 들어 기존 행의 새 컬럼을 채울 수 있습니다.


Laravel은 각 마이그레이션의 실행과 `migrations` 테이블에 대한 기록을 하나의 트랜잭션에서 수행하며, 마이그레이션의 `ctx`가 이 트랜잭션을 전달합니다. `ctx`로 실행하는 모든 스키마 빌더 호출, 쿼리, 모델 쓰기는 이 트랜잭션에 참여합니다. PostgreSQL과 SQLite에서는 실패한 마이그레이션이 일부 스키마 변경을 남기지 않고 완전히 롤백되므로, 마이그레이션을 수정하고 `migrate`를 다시 실행할 수 있습니다.


MySQL과 MariaDB는 `CREATE TABLE`처럼 테이블을 변경하는 구문을 실행할 때마다 트랜잭션을 커밋합니다. 따라서 이 데이터베이스에서는 마이그레이션이 실패해도 앞선 구문의 적용 결과가 남을 수 있습니다. MySQL과 MariaDB에서 마이그레이션이 일부만 적용되는 일을 피하려면 각 테이블 변경을 별도의 마이그레이션에 두세요.

<a name="framework-tables"></a>

### Framework tables


Laravel의 일부 데이터베이스 드라이버는 `database` 캐시 저장소의 `cache` 테이블이나 `database` 큐 드라이버의 `jobs` 테이블처럼 거의 변경하지 않는 테이블에 데이터를 저장합니다. 애플리케이션에 각 드라이버의 컬럼을 직접 작성하는 대신, `database/migrations/migrations.go`의 `Run`에 드라이버의 마이그레이션 헬퍼를 바로 전달할 수 있습니다:

```go
// database/migrations/migrations.go
package migrations

import (
	"go.laravel.com/cache"
	"go.laravel.com/db"
	"go.laravel.com/queue"
)

var All = []db.Migration{
	{Name: "0001_01_01_000001_create_cache_table", Run: cache.CreateTables},
	{Name: "0001_01_01_000002_create_jobs_table", Run: queue.CreateTables},
}
```

| 헬퍼 | 생성 대상 |
| --- | --- |
| `cache.CreateTables` | [cache store's](/go/docs/cache#the-database-store)의 `cache` 및 `cache_locks` 테이블 |
| `feature.CreateTable` | [feature flag store's](/go/docs/feature-flags#the-features-table)의 `features` 테이블 |
| `queue.CreateTables` | [queue's](/go/docs/queues#the-jobs-table)의 `jobs`, `failed_jobs`, `job_batches`, `job_batch_jobs` 테이블 |
| `session.CreateTable` | [session driver's](/go/docs/session#the-database-session-table)의 `sessions` 테이블 |
| `workflow.CreateTables` | [workflow store's](/go/docs/workflows#the-workflow-tables)의 `workflow_*` 테이블 5개 |


나중에 인덱스나 컬럼을 추가하는 등 이러한 테이블을 변경하려면, 해당 마이그레이션 실행 후 새 전진 마이그레이션을 작성하세요.

<a name="changing-a-migration-that-has-run"></a>

### Changing a migration that has run


마이그레이션은 앞으로만 실행하며 `down` 함수나 롤백 명령어는 없습니다. 운영 환경에서 스키마 변경을 되돌리면 테이블이나 컬럼 삭제로 실제 데이터가 손실될 수 있으므로 안전하지 않은 경우가 많습니다. 운영 중인 애플리케이션에서 이전 마이그레이션의 변경을 수정하거나 되돌리려면 새 마이그레이션을 작성하세요. 예를 들어 이전 마이그레이션이 추가한 컬럼을 삭제하는 마이그레이션을 작성할 수 있습니다:

```go
// database/migrations/2026_11_12_090000_drop_posts_published_at.go
func dropPostsPublishedAt(ctx context.Context) error {
	return schema.Alter(ctx, "posts", func(table *schema.Blueprint) {
		table.DropColumn("published_at")
	})
}
```


Laravel은 `All`의 각 항목에 지정된 `Name`으로 마이그레이션을 추적합니다. `make:migration`은 이 값을 파일 이름에서 `.go`를 뺀 이름으로 설정합니다. 공유 환경이나 운영 환경에서 실행한 마이그레이션은 절대 수정하거나 이름을 바꾸지 마세요. 수정한 마이그레이션은 다시 실행되지 않으며, 이름을 바꾼 마이그레이션은 두 번째로 실행됩니다.

> [!NOTE]
> 로컬 개발 중 애플리케이션을 출시하기 전이나 새 마이그레이션을 배포하기 전에는 테이블의 기존 마이그레이션을 직접 수정하고 [`migrate:fresh`](#rebuilding-the-database)를 실행하여 로컬 데이터베이스를 처음부터 다시 만들 수 있습니다.

<a name="running-a-migration-without-a-transaction"></a>

### Running a migration without a transaction


PostgreSQL의 [`Online`](/go/docs/schema#changing-large-tables) 인덱스 생성처럼 일부 구문은 트랜잭션 안에서 실행할 수 없습니다. 대규모 백필도 긴 트랜잭션 하나를 유지하기보다 배치 단위로 커밋해야 하는 경우가 많습니다. 자동 트랜잭션 없이 마이그레이션을 실행하려면 `All`의 해당 항목에 `NoTransaction`을 설정하세요:

```go
// database/migrations/migrations.go
var All = []db.Migration{
	// ...
	{Name: "2026_11_10_160000_index_posts_slug", Run: indexPostsSlug, NoTransaction: true},
}
```


그러면 마이그레이션의 `ctx`는 트랜잭션 대신 커넥션 풀을 전달합니다. 예를 들어 다음 마이그레이션은 `posts`에 대한 쓰기를 차단하지 않고 PostgreSQL에 인덱스를 생성합니다:

```go
// database/migrations/2026_11_10_160000_index_posts_slug.go
func indexPostsSlug(ctx context.Context) error {
	// A failed concurrent build leaves an invalid index behind, so drop it before trying again.
	if _, err := db.Exec(ctx, "drop index concurrently if exists posts_slug_index"); err != nil {
		return err
	}

	return schema.Alter(ctx, "posts", func(table *schema.Blueprint) {
		table.Index("slug").Online()
	})
}
```


각 구문은 즉시 커밋되며, 함수가 `nil`을 반환하면 Laravel이 마이그레이션을 기록합니다. 트랜잭션 없는 마이그레이션이 중간에 실패하면 이미 실행된 구문은 적용된 상태로 남고, 다음 `migrate`는 전체 마이그레이션을 처음부터 다시 실행합니다. 위의 `if exists`처럼 두 번 실행해도 안전하도록 이러한 마이그레이션을 작성하세요.

<a name="supporting-several-databases"></a>

### Supporting several databases


대부분의 애플리케이션은 하나의 데이터베이스를 대상으로 하지만, [packages](#package-migrations)는 애플리케이션이 사용하는 어떤 데이터베이스에서도 실행되어야 하는 마이그레이션을 제공하는 경우가 많습니다. 스키마 빌더는 이식 가능한 스키마 정의를 변환해 주지만, Laravel은 `db.Exec`에 전달한 SQL을 작성한 그대로 보냅니다. 마이그레이션에서 특정 데이터베이스용 SQL이 필요하다면 `db.From(ctx).Dialect()`로 커넥션의 방언을 확인하세요:

```go
// database/migrations/2026_11_11_090000_index_published_posts.go
func indexPublishedPosts(ctx context.Context) error {
	var query string

	switch db.From(ctx).Dialect() {
	case db.Postgres, db.SQLite:
		query = "create index posts_published_at_index on posts (published_at) " +
			"where published_at is not null"
	case db.MySQL, db.MariaDB:
		// MySQL and MariaDB have no partial indexes, so they index every row.
		query = "create index posts_published_at_index on posts (published_at)"
	}

	_, err := db.Exec(ctx, query)

	return err
}
```

<a name="running-migrations"></a>

## Running migrations


아직 실행하지 않은 모든 마이그레이션을 실행하려면 `migrate` 명령어를 사용하세요.

```shell
laravel migrate
```


`migrate`는 처음에 `migrations` 테이블을 만든 뒤 대기 중인 마이그레이션을 이름순으로 실행합니다. 마이그레이션이 실패하면 `migrate`는 중단하고 원인이 된 SQL과 함께 데이터베이스 오류를 출력합니다. 앞선 마이그레이션은 적용된 상태로 남으므로 실패한 항목을 수정한 뒤 `migrate`를 다시 실행하면 나머지가 실행됩니다.

<a name="creating-a-missing-database"></a>

### Creating a missing database


새 머신에서는 `DATABASE_URL`이 아직 없는 데이터베이스를 가리킬 수 있습니다. PostgreSQL, MySQL, MariaDB에서는 `migrate`와 `migrate:fresh`가 데이터베이스 생성을 제안합니다. `--force`를 전달하면 확인 없이 생성할 수 있습니다. Laravel은 URL의 자격 증명으로 연결하므로 URL의 사용자에게 데이터베이스 생성 권한이 있어야 합니다.


SQLite는 파일을 담을 디렉터리가 존재하면 애플리케이션이 처음 열 때 데이터베이스 파일을 직접 생성합니다. 자세한 내용은 [database guide](/go/docs/database#sqlite)를 참고하세요.

<a name="checking-which-migrations-have-run"></a>

### Checking which migrations have run


`migrate:status`는 모든 마이그레이션과 실행 여부를 나열합니다. 한 번의 `migrate` 실행에서 처리한 마이그레이션은 같은 배치 번호를 갖습니다.

```text
Migration                                Batch  Status
2026_09_01_120000_create_audits_table    1      ran, not registered
2026_10_20_090000_create_teams_table     1      ran
2026_10_21_110000_add_team_to_users             pending, out of order
2026_10_27_143000_create_posts_table     2      ran
2026_10_28_101500_create_comments_table         pending
```


`pending, out of order`는 다른 브랜치에서 병합한 마이그레이션처럼, 이미 실행된 마이그레이션보다 오래된 대기 중 마이그레이션을 나타내며 `migrate`는 이 마이그레이션도 실행합니다. `ran, not registered`는 데이터베이스에서 실행했지만 `All`에 더 이상 없는 마이그레이션을 나타냅니다. 보통 이름을 바꾸거나 삭제했을 때 발생합니다.


수동으로 추가한 파일처럼 `database/migrations`에 있지만 `All`에는 없는 마이그레이션 파일이 있으면 `migrate:status`가 경고합니다. `All`에 추가하기 전에는 `migrate`가 해당 파일을 실행하지 않기 때문입니다.

<a name="rebuilding-the-database"></a>

### Rebuilding the database


로컬 개발 중에는 데이터베이스를 처음부터 다시 만들고 싶을 수 있습니다. `migrate:fresh` 명령어는 데이터베이스의 모든 테이블과 뷰를 삭제한 뒤 모든 마이그레이션을 처음부터 실행합니다. PostgreSQL에서는 검색 경로에 있는 스키마의 함수, 프로시저, 사용자 정의 타입(enum 포함), 도메인, 시퀀스도 삭제합니다. 설치된 확장(`citext` 등)과 해당 확장의 객체는 그대로 유지합니다:

```shell
laravel migrate:fresh
```


`migrate:fresh`는 마이그레이션으로 생성하지 않은 테이블까지 포함해 데이터베이스의 모든 테이블을 삭제합니다. 따라서 다른 애플리케이션과 공유하는 데이터베이스에는 실행하지 마세요.


데이터베이스를 다시 만든 직후 행을 채우려면 `--seed`를 전달하여 [seeders](/go/docs/seeding)를 실행하세요. 이름으로 시더 하나를 실행하려면 `--seeder=posts`를 전달하세요:

```shell
laravel migrate:fresh --seed
```

<a name="choosing-a-connection"></a>

### Choosing a connection


마이그레이션은 기본적으로 `DATABASE_URL`이 지정한 데이터베이스에서 실행됩니다. 보고용 데이터베이스 등 [another connection](/go/docs/database#using-more-than-one-database)의 이름을 `--database`와 함께 `migrate`, `migrate:fresh`, `migrate:status`에 전달하면 다른 데이터베이스에서 실행할 수 있습니다:

```shell
laravel migrate --database reporting
```


마이그레이션의 `ctx`는 해당 커넥션을 전달하므로, 마이그레이션 안의 스키마 빌더와 `db.Exec` 호출도 같은 커넥션을 대상으로 합니다. 각 커넥션은 자체 `migrations` 테이블을 유지하므로 데이터베이스마다 실행한 마이그레이션을 기록합니다.

<a name="running-migrations-in-production"></a>

### Running migrations in production


마이그레이션은 운영 데이터를 변경하거나 삭제할 수 있으므로, `APP_ENV`가 `production`이거나 설정되지 않았을 때 `migrate`와 `migrate:fresh`는 실행 확인을 요청합니다. 배포 스크립트 등에서 확인 없이 실행하려면 `--force`를 전달하세요. `--force`가 없으면 확인에 응답할 터미널이 없는 배포 스크립트는 마이그레이션을 수행하지 않고 실패합니다. 서버에서는 `laravel` 대신 컴파일된 바이너리를 직접 실행하세요:

```shell
./app migrate --force
```


여러 서버에 배포할 때는 한 서버나 하나의 배포 단계에서 `migrate`를 실행하세요. 두 서버가 동시에 실행하더라도 `migrate`는 실행 중 데이터베이스 잠금을 유지하므로 각 마이그레이션은 여전히 한 번만 실행됩니다.

> [!NOTE]
> [Laravel Cloud](https://laravel.com/cloud)에 배포할 때는 배포 명령어에 `./app migrate --force`를 넣으세요. Cloud는 인스턴스 수에 관계없이 배포마다 이 명령어를 한 번만 실행하므로 직접 조정할 필요가 없습니다.

<a name="registering-migrations"></a>

## Registering migrations


Go는 런타임에 디렉터리의 함수를 찾아낼 수 없으므로, `database/migrations/migrations.go`가 `All`에 마이그레이션을 나열하며 `make:migration`은 각 새 마이그레이션을 목록 끝에 추가합니다:

```go
// database/migrations/migrations.go
package migrations

import "go.laravel.com/db"

// All are the application's migrations, which migrate runs in name order.
var All = []db.Migration{
	{Name: "2026_11_10_120000_create_posts_table", Run: createPostsTable},
	{Name: "2026_11_10_160000_index_posts_slug", Run: indexPostsSlug, NoTransaction: true},
}
```


새 애플리케이션은 `bootstrap/app.go`에서 이 목록을 Laravel에 전달하므로 `All`의 모든 마이그레이션이 자동으로 실행됩니다:

```go
return laravel.Options{
	// ...
	Migrations: migrations.All,
}
```


`migrate`는 `All` 안의 순서에 관계없이 이름순으로 마이그레이션을 실행하므로, 다른 브랜치에서 병합한 마이그레이션은 목록의 어느 위치에나 놓을 수 있습니다. 이름이 같은 마이그레이션이 두 개 있으면 `migrate`는 실행을 거부합니다.

<a name="package-migrations"></a>

### Package migrations


패키지는 청구 패키지가 송장을 저장하는 테이블 등 자체 마이그레이션을 제공하고, [`Register` method](/go/docs/packages#the-register-method)에서 이를 추가할 수 있습니다. Laravel은 패키지 마이그레이션을 애플리케이션 마이그레이션과 함께 이름순으로 실행합니다:

```go
func (b *Billing) Register(app *laravel.Registrar) error {
	app.Migrations(migrations.All...)

	return nil
}
```


패키지는 애플리케이션처럼 `All` 목록을 가진 자체 `migrations` 패키지에 마이그레이션을 보관합니다. 자세한 내용은 [package development guide's section on migrations](/go/docs/packages#migrations)를 참고하세요.

<a name="squashing-migrations"></a>

## Squashing migrations


애플리케이션을 개발하다 보면 `database/migrations` 디렉터리에 수백 개의 마이그레이션이 쌓일 수 있습니다. 테스트 데이터베이스를 포함한 모든 새 데이터베이스는 이를 모두 실행해야 합니다. 원한다면 `schema:dump` 명령어로 마이그레이션을 하나의 SQL 파일로 통합할 수 있습니다:

```shell
laravel schema:dump

# Dump the database schema and delete the migrations it holds...
laravel schema:dump --prune
```


이 명령어를 실행하면 Laravel은 데이터베이스의 스키마와 `migrations` 테이블의 행을 `database/schema/<connection>-schema.sql`에 기록합니다. 기본 커넥션에서는 `database/schema/default-schema.sql`을 사용합니다. `DB_CONNECTION`이 이름이 있는 [connection](/go/docs/database#using-more-than-one-database)을 선택한 경우에는 `<name>-schema.sql`을 사용합니다. 다른 커넥션을 덤프하려면 `--database`를, 다른 위치에 파일을 쓰려면 `--path`를, `migrations` 테이블의 행을 제외하려면 `--without-migration-data`를 전달하세요.


`--prune`을 전달하면 `database/migrations`의 마이그레이션 파일을 삭제하고 `All`을 비워 패키지가 계속 컴파일되도록 합니다. `migrations.go`와 `_test.go` 파일은 그대로 둡니다.


새 데이터베이스나 `migrate:fresh` 이후처럼 `migrations` 테이블이 빈 데이터베이스에서 `migrate`를 실행하면, Laravel은 먼저 커넥션의 스키마 파일을 불러온 뒤 덤프 이후 추가된 마이그레이션을 실행합니다. `migrate:status`는 통합된 마이그레이션을 표에서 제외하고 한 줄로 요약합니다:

```text
Migration                              Batch  Status
2026_11_20_090000_add_avatar_to_users         pending

42 migrations are squashed into the schema dump.
```


새 애플리케이션은 `database/schema/schema.go`에서 `database/schema`를 임베딩하고 `bootstrap/app.go`에서 Laravel에 전달합니다. 따라서 컴파일된 바이너리만 실행하는 서버도 덤프로 새 데이터베이스를 만들 수 있습니다:

```go
return laravel.Options{
	// ...
	Migrations: migrations.All,
	Schema:     schema.Dumps,
}
```


마이그레이션을 추가했을 때와 마찬가지로, 스키마를 덤프한 뒤에는 바이너리를 다시 빌드하세요. 커넥션에 임베딩된 덤프가 없으면 Laravel은 디스크에서 `database/schema/<connection>-schema.sql`을 읽습니다. `migrate` 또는 `migrate:fresh`에 `--schema-path`를 전달하면 특정 파일을 불러올 수 있으며, `--schema-only`를 전달하면 대기 중인 마이그레이션을 실행하지 않고 스키마만 불러옵니다.


팀의 다른 개발자가 애플리케이션의 초기 데이터베이스 구조를 빠르게 만들 수 있도록 스키마 파일을 소스 관리에 커밋해야 합니다.


테스트도 기본 커넥션의 스키마 파일을 불러옵니다. PostgreSQL로 개발하면서 테스트에는 SQLite를 사용하는 경우처럼, 테스트와 로컬 개발에서 다른 데이터베이스 드라이버를 사용한다면 `bootstrap/app.go`에 전용 [connection](/go/docs/database#defining-more-connections)을 정의하여 별도의 스키마 파일을 갖도록 하세요:

```go
// bootstrap/app.go
func configure(cfg *config.Config, env *config.Env) {
	cfg.Database.Connections = map[string]config.Connection{
		"testing": {
			URL: env.String("TESTING_DATABASE_URL", "sqlite:database/testing.sqlite"),
		},
	}
}
```


[`.env.testing`](/go/docs/testing#configuring-your-tests)에서 이 커넥션을 선택하세요:

```ini
DB_CONNECTION=testing
```


그런 다음 두 커넥션을 모두 덤프하면 `laraveltest.RefreshDatabase`가 각 테스트 데이터베이스에 `database/schema/testing-schema.sql`을 불러옵니다:

```shell
laravel schema:dump
laravel migrate --database=testing
laravel schema:dump --database=testing --prune
```

> [!WARNING]
> 마이그레이션 압축은 PostgreSQL, MySQL, MariaDB, SQLite를 지원하며 데이터베이스 명령행 클라이언트인 `pg_dump`와 `psql`, `mysqldump`와 `mysql`, 또는 `sqlite3`를 사용합니다. CI와 프로덕션 서버를 포함해 스키마를 덤프하거나 불러오는 모든 머신에 클라이언트를 설치하세요. 인메모리 SQLite 테스트 데이터베이스는 클라이언트 없이 스키마 파일을 직접 불러옵니다.

<a name="testing"></a>

## Testing


테스트 전에 마이그레이션을 실행하려면 새 애플리케이션처럼 테스트 클라이언트를 만들 때 [`laraveltest.RefreshDatabase`](/go/docs/testing#refreshing-the-database)를 전달하세요. Laravel은 테스트 실행 사이에 마이그레이션된 테스트 데이터베이스를 유지합니다. 코드나 스키마 파일이 바뀌면 [schema file](#squashing-migrations)과 모든 마이그레이션으로 데이터베이스를 다시 만들므로, 직접 테스트 데이터베이스를 마이그레이션할 필요가 없습니다.