importschema

package
v1.6.27 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: GPL-3.0, Apache-2.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	VarStringDSN           string
	VarStringOutputDir     string
	VarStringTables        string
	VarStringExcludeTables string
	VarBoolAutoMixin       bool
)

Functions

func FormatFile

func FormatFile(ctx *GenContext) error

FormatFile formats the file to adjust simple admin

func Gen

func Gen(_ *cobra.Command, _ []string) (err error)

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 GenContext

type GenContext struct {
	Dsn           string
	OutputDir     string
	Tables        []string
	ExcludeTables []string
	AutoMixin     bool
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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