Documentation ¶
Index ¶
- Variables
- func AsDDL(cmd Command) string
- func AsDML(cmd Command) string
- func CommandToString(cmd Command) string
- func FlipCoin() bool
- func FullyQualifiedName(el dag.INode) string
- func NewOracle(db *sqlx.DB, log *log.Logger) (*oracle, error)
- func NewSUT(conn *sqlx.DB, log *log.Logger) *sut
- func NotPublic(s *Schema) bool
- func RandomString(prefixes ...string) string
- func Tpl(body string, vars any) string
- func WithFullQualifiedName[T dag.INode](name string) dag.Filter[T]
- type AddColumn
- type Column
- type Command
- type CreateDatabase
- type CreateForeignKeyConstraint
- type CreateIndex
- type CreateSchema
- type CreateTable
- type Database
- type DropColumn
- type DropDatabase
- type DropForeignKeyConstraint
- type DropIndex
- type DropSchema
- type DropTable
- type ForeignKeyConstraint
- type Index
- type Queries
- type RenameDatabase
- type RenameSchema
- type RenameTable
- type Schema
- type Step
- type System
- type Table
- type Transcript
- type Translation
Constants ¶
This section is empty.
Variables ¶
View Source
var AllCommands = []Command{ AddColumn{}, CreateDatabase{}, CreateForeignKeyConstraint{}, CreateIndex{}, CreateSchema{}, CreateTable{}, DropColumn{}, DropDatabase{}, DropForeignKeyConstraint{}, DropIndex{}, DropSchema{}, DropTable{}, RenameDatabase{}, RenameSchema{}, RenameTable{}, }
View Source
var Generators = map[reflect.Type]func(*dag.Graph) Command{ reflect.TypeOf(DropDatabase{}): func(g *dag.Graph) Command { return DropDatabase{dag.Nodes[*Database](g).Any()} }, reflect.TypeOf(DropIndex{}): func(g *dag.Graph) Command { return DropIndex{dag.Nodes[*Index](g).Any()} }, reflect.TypeOf(DropSchema{}): func(g *dag.Graph) Command { return DropSchema{dag.Nodes[*Schema](g).Any()} }, reflect.TypeOf(DropTable{}): func(g *dag.Graph) Command { return DropTable{dag.Nodes[*Table](g).Any()} }, reflect.TypeOf(CreateDatabase{}): func(g *dag.Graph) Command { if len(dag.Nodes[*Database](g)) > 5 { return nil } return CreateDatabase{Name: RandomString()} }, reflect.TypeOf(CreateSchema{}): func(g *dag.Graph) Command { if len(dag.Nodes[*Schema](g)) > 2 { return nil } return CreateSchema{Database: dag.Nodes[*Database](g).Any(), Name: RandomString()} }, reflect.TypeOf(CreateTable{}): func(g *dag.Graph) Command { return CreateTable{ Schema: dag.Nodes[*Schema](g).Any(), Name: RandomString(), } }, reflect.TypeOf(CreateIndex{}): func(g *dag.Graph) Command { table := dag.Nodes[*Table](g, func(t *Table) bool { return len(t.Columns()) > 1 }).Any() return CreateIndex{ Table: table, Name: RandomString(), Columns: table.Columns().PickUpTo(3), Unique: FlipCoin(), } }, reflect.TypeOf(RenameTable{}): func(g *dag.Graph) Command { return RenameTable{ Table: dag.Any[*Table](g), Name: RandomString(), } }, reflect.TypeOf(RenameSchema{}): func(g *dag.Graph) Command { return RenameSchema{ Schema: dag.Any[*Schema](g, NotPublic), Name: RandomString(), } }, reflect.TypeOf(RenameDatabase{}): func(g *dag.Graph) Command { return RenameDatabase{ Database: dag.Any[*Database](g), Name: RandomString(), } }, reflect.TypeOf(DropColumn{}): func(g *dag.Graph) Command { return DropColumn{dag.Nodes[*Column](g).Any()} }, reflect.TypeOf(DropForeignKeyConstraint{}): func(g *dag.Graph) Command { panic("not implemented") }, reflect.TypeOf(AddColumn{}): func(g *dag.Graph) Command { return AddColumn{ Table: dag.Nodes[*Table](g).Any(), Name: RandomString(), Nullable: false, } }, reflect.TypeOf(CreateForeignKeyConstraint{}): func(g *dag.Graph) Command { to := dag.Nodes[*Index](g, func(i *Index) bool { return i.Unique && len(i.Columns()) == 1 }).Any().Columns()[0] from := dag.Nodes[*Column](g, func(c *Column) bool { return c.Table().Schema().Database() == to.Table().Schema().Database() && c.Table() != to.Table() }).Any() return CreateForeignKeyConstraint{ Name: RandomString(), From: from, To: to, } }, }
TODO: There's probably no reason to use reflect.TypeOf here. Command is fine.
View Source
var Weights = map[reflect.Type]int{ reflect.TypeOf(CreateIndex{}): 3, reflect.TypeOf(AddColumn{}): 3, reflect.TypeOf(CreateTable{}): 2, reflect.TypeOf(DropDatabase{}): 0, reflect.TypeOf(DropColumn{}): 0, reflect.TypeOf(DropTable{}): 0, reflect.TypeOf(DropSchema{}): 0, }
Functions ¶
func CommandToString ¶
func FullyQualifiedName ¶
func RandomString ¶
Types ¶
type CreateDatabase ¶
type CreateDatabase struct {
Name string
}
type CreateIndex ¶
type CreateSchema ¶
type CreateTable ¶
type DropColumn ¶
type DropColumn struct {
Column *Column
}
type DropDatabase ¶
type DropDatabase struct {
Database *Database
}
type DropForeignKeyConstraint ¶
type DropForeignKeyConstraint struct {
ForeignKeyConstraint *ForeignKeyConstraint
}
type DropSchema ¶
type DropSchema struct {
Schema *Schema
}
type ForeignKeyConstraint ¶
func (*ForeignKeyConstraint) From ¶
func (c *ForeignKeyConstraint) From() *Column
func (*ForeignKeyConstraint) To ¶
func (c *ForeignKeyConstraint) To() *Column
TODO relying on order here feels SUPER sketchy. We may need a way to annotate edges...
type RenameDatabase ¶
type RenameSchema ¶
type RenameTable ¶
type Transcript ¶
type Transcript struct {
Steps []Step
}
type Translation ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.