seeder

package
v0.0.0-...-6804534 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Flags

type Flags struct {
	AddAll             bool
	RemoveAll          bool
	SeedToAdd          string
	SeedToRemove       string
	FileToCreate       string
	Directory          string
	ConnectionURI      string
	SeedKeyNames       string
	SeedKeyIntegerType bool
	Verbose            bool
}

Flags is commandline flags

type PgseederSeed

type PgseederSeed struct {
	ID         uuid.UUID `pg:",pk, unique, notnull, type:uuid, default:uuid_generate_v4()"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
	DeletedAt  *time.Time
	SeedKeys   []SeedKey `pg:"seed_keys"`
	TableName  string
	TableOrder int
}

PgseederSeed is the pgseeder_seeds table model.

type SeedKey

type SeedKey struct {
	Name  string `pg:"name"`
	Value string `pg:"value"`
	Type  string `pg:"type"`
}

SeedKey represnts primary/composite key info of a seed.

type SeedKeyType

type SeedKeyType = string

SeedKeyType is the type of a key.

const (
	SeedKeyTypeString  SeedKeyType = "SeedKeyTypeString"
	SeedKeyTypeInteger SeedKeyType = "SeedKeyTypeInteger"
)

...

type Seeder

type Seeder struct {
	*pg.DB

	SeedKeyType SeedKeyType
	// contains filtered or unexported fields
}

Seeder represents a seeder instance.

func NewSeeder

func NewSeeder(seedKeyNames []string, flags *Flags) (Seeder, error)

NewSeeder creates a new seeder.

func (*Seeder) Add

func (seeder *Seeder) Add(filename string, tableName string) error

Add adds seed data for a table to the DB.

func (*Seeder) AddAll

func (seeder *Seeder) AddAll() error

AddAll adds all seed data to the DB.

func (*Seeder) Remove

func (seeder *Seeder) Remove(tableName string) error

Remove removes seed data for a table in the DB.

func (*Seeder) RemoveAll

func (seeder *Seeder) RemoveAll() error

RemoveAll removes all seed data in the DB.

Jump to

Keyboard shortcuts

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