mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/9 Reviewed By: alexsn Differential Revision: D16252229 fbshipit-source-id: 795b6556d322e5c1ff5fb826c3b06ba5421ac857
30 lines
715 B
Cheetah
30 lines
715 B
Cheetah
{{ define "migrate" }}
|
|
{{ template "header" "migrate" }}
|
|
{{ $pkg := base $.Config.Package }}
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"fbc/ent/dialect"
|
|
"fbc/ent/dialect/sql/schema"
|
|
)
|
|
|
|
// Schema is the API for creating, migrating and dropping a schema.
|
|
type Schema struct {
|
|
drv dialect.Driver
|
|
universalID bool
|
|
}
|
|
|
|
// NewSchema creates a new schema client.
|
|
func NewSchema(drv dialect.Driver) *Schema { return &Schema{drv: drv} }
|
|
|
|
// Create creates all schema resources.
|
|
func (s *Schema) Create(ctx context.Context, opts ...schema.MigrateOption) error {
|
|
migrate, err := schema.NewMigrate(s.drv, opts...)
|
|
if err != nil {
|
|
return fmt.Errorf("ent/migrate: %v", err)
|
|
}
|
|
return migrate.Create(ctx, Tables...)
|
|
}
|
|
{{ end }} |