mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Summary:
Set the standard header ("Code generated by entc, DO NOT EDIT.") as default, and override it using option in graph.
No changes to graph except the `generate.go` file.
Reviewed By: idoshveki
Differential Revision: D16642348
fbshipit-source-id: d9fd1d2046e2fd96acbb100ef061fda75d99ce52
32 lines
725 B
Cheetah
32 lines
725 B
Cheetah
{{ define "migrate" }}
|
|
|
|
{{- with extend $ "Package" "migrate" -}}
|
|
{{ template "header" . }}
|
|
{{ end }}
|
|
|
|
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 }} |