mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: initial work for multi-schema migration using atlasgo.io (#3821)
This commit is contained in:
@@ -192,3 +192,29 @@ func NewSchemaConfigContext(parent context.Context, config SchemaConfig) context
|
||||
{{- end }}
|
||||
step.Edge.Schema = schemaConfig.{{ $schema }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "config/init/fields/multischema" }}
|
||||
{{- if $.FeatureEnabled "sql/multischema" }}
|
||||
cfg.schemaConfig = DefaultSchemaConfig
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- define "dialect/sql/config/options/multischema" }}
|
||||
{{- if $.FeatureEnabled "sql/multischema" }}
|
||||
{{- $all := $.TableSchemas }}
|
||||
var (
|
||||
// DefaultSchemaConfig represents the default schema names for all tables as defined in ent/schema.
|
||||
DefaultSchemaConfig = SchemaConfig {
|
||||
{{- range $n := $.Nodes }}
|
||||
{{ $n.Name }}: tableSchemas[{{ indexOf $all $n.TableSchema }}],
|
||||
{{- range $e := $n.Edges }}
|
||||
{{- if and $e.M2M (not $e.Inverse) (not $e.Through) }}
|
||||
{{ $n.Name }}{{ $e.StructField }}: tableSchemas[{{ indexOf $all $e.TableSchema }}],
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
}
|
||||
tableSchemas = [...]string{ {{- range $i, $s := $all }}{{ if $i }},{{ end }}"{{ $s }}"{{ end }} }
|
||||
)
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -34,6 +34,11 @@ in the LICENSE file in the root directory of this source tree.
|
||||
{{ $e.ColumnConstant }} = "{{ $e.Rel.Column }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- with $tmpls := matchTemplate "dialect/sql/meta/constants/*" }}
|
||||
{{- range $tmpl := $tmpls }}
|
||||
{{- xtemplate $tmpl $ }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ end }}
|
||||
|
||||
{{/* Variables needed for sql dialects. */}}
|
||||
|
||||
Reference in New Issue
Block a user