parser

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Database       *Database    `"DATABASE" @@`
	Roles          *Roles       `| "ROLES" @@`
	Extensions     *Extensions  `| "EXTENSIONS" @@`
	Schemas        *Schemas     `| "SCHEMAS" @@`
	ForeignKeys    *ForeignKeys `| ("FOREIGN" "KEYS") @@`
	Schema         *Name        `| "SCHEMA" @@`
	TablesInSchema *Name        `| "TABLES" "IN" @@`
	ViewsInSchema  *Name        `| "VIEWS" "IN" @@`
	Table          *SchemaItem  `| "TABLE" @@`
	View           *SchemaItem  `| "VIEW" @@`
	Indexes        *SchemaItem  `| "INDEXES" "ON" @@`
	Constraints    *SchemaItem  `| "CONSTRAINTS" "ON" @@`
}

Command contains details of a create or drop command. Only one of the members will be `true` or populated.

type DDSL

type DDSL struct {
	Create  *Command     `"CREATE" @@`
	Drop    *Command     `| "DROP" @@`
	Migrate *Migrate     `| "MIGRATE" @@`
	Sql     *string      `| "SQL" @Sql`
	Seed    *SeedCommand `| "SEED" @@`
}

DDSL is the top level struct of the parser. Only one of the members will be populated.

func Parse

func Parse(commands string) ([]*DDSL, error)

Parse parses an input of one or more commands and returns a slice of parse trees.

type Database

type Database struct {
	Ref *Ref `[@@]`
}

Database contains details for action on a database.

type Extensions

type Extensions struct {
	Ref *Ref `[@@]`
}

Extensions contains details for action on extensions.

type ForeignKeys

type ForeignKeys struct {
	Ref *Ref `[@@]`
}

ForeignKeys contains details for action on a foreign keys.

type Migrate

type Migrate struct {
	Top    bool `@"TOP"`
	Bottom bool `| @"BOTTOM"`
	Up     *int `| "UP" @Int`
	Down   *int `| "DOWN" @Int`
}

Migrate contains the migration command. Only one of the members will be `true` or nonzero.

type Name

type Name struct {
	Name string `@Ident`
	Ref  *Ref   `[@@]`
}

type Ref

type Ref struct {
	Ref string `@Ref`
}

Tag contains the git tag to run the DDSL command against.

type Roles

type Roles struct {
	Ref *Ref `[@@]`
}

Roles contains details for action on roles.

type SchemaItem

type SchemaItem struct {
	Item        string `@SchemaItem`
	Ref         *Ref   `[@@]`
	TableOrView string
	Schema      string
}

SchemaItem contains the schema and table or view when it is the object of the command.

type Schemas

type Schemas struct {
	Ref *Ref `[@@]`
}

Schemas contains details for action on schemas.

type SeedCommand

type SeedCommand struct {
	Table          *SchemaItem `"TABLE" @@`
	TablesInSchema *Name       `| "TABLES" "IN" @@`
}

Jump to

Keyboard shortcuts

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