entimport

package
v0.0.0-...-3381ae9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 23, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteSchema

func WriteSchema(mutations []schemast.Mutator, opts ...ImportOption) error

WriteSchema receives a list of mutators, and writes an ent schema to a given location in the file system.

Types

type ImportOption

type ImportOption func(*ImportOptions)

ImportOption allows for managing import configuration using functional options.

func WithDriver

func WithDriver(drv *mux.ImportDriver) ImportOption

WithDriver provides an import driver to be used by SchemaImporter.

func WithExcludedTables

func WithExcludedTables(tables []string) ImportOption

WithExcludedTables supplies the set of tables to exclude.

func WithSchemaPath

func WithSchemaPath(path string) ImportOption

WithSchemaPath provides a DSN (data source name) for reading the schema & tables from.

func WithTables

func WithTables(tables []string) ImportOption

WithTables limits the schema import to a set of given tables (by all tables are imported)

type ImportOptions

type ImportOptions struct {
	// contains filtered or unexported fields
}

ImportOptions are the options passed on to every SchemaImporter.

type MySQL

type MySQL struct {
	*ImportOptions
}

MySQL holds the schema import options and an Atlas inspector instance

func NewMySQL

func NewMySQL(i *ImportOptions) (*MySQL, error)

NewMySQL - create aמ import structure for MySQL.

func (*MySQL) SchemaMutations

func (m *MySQL) SchemaMutations(ctx context.Context) ([]schemast.Mutator, error)

SchemaMutations implements SchemaImporter.

type Postgres

type Postgres struct {
	*ImportOptions
}

Postgres implements SchemaImporter for PostgreSQL databases.

func (*Postgres) SchemaMutations

func (p *Postgres) SchemaMutations(ctx context.Context) ([]schemast.Mutator, error)

SchemaMutations implements SchemaImporter.

type SchemaImporter

type SchemaImporter interface {
	// SchemaMutations imports a given schema from a data source and returns a list of schemast mutators.
	SchemaMutations(context.Context) ([]schemast.Mutator, error)
}

SchemaImporter is the interface that wraps the SchemaMutations method.

func NewImport

func NewImport(opts ...ImportOption) (SchemaImporter, error)

NewImport calls the relevant data source importer based on a given dialect.

func NewPostgreSQL

func NewPostgreSQL(i *ImportOptions) (SchemaImporter, error)

NewPostgreSQL - returns a new *Postgres.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL