Documentation
¶
Index ¶
- type Attribute
- type BelongsTo
- type Column
- type Config
- type Database
- func (d *Database) CreateMySQLSchema(dbName string) *schema.Schema
- func (d *Database) CreatePostgreSQLSchema(dbName string) *schema.Schema
- func (d *Database) CreateSQLiteSchema(dbName string) *schema.Schema
- func (d *Database) LoadConfig(environment string) *Config
- func (d *Database) NewConfig(environment string) *Config
- func (d *Database) NewModel(name string) *Model
- func (d *Database) Tables() []string
- type Enum
- type Generator
- type HasMany
- type HasOne
- type Index
- type Model
- func (m *Model) AddBelongsTo(belongsTo *BelongsTo)
- func (m *Model) AddColumn(column *Column)
- func (m *Model) AddDefaultPrimaryKey()
- func (m *Model) AddHasMany(hasMany *HasMany)
- func (m *Model) AddHasOne(hasOne *HasOne)
- func (m *Model) AddIndex(index *Index)
- func (m *Model) AddTimestamps()
- func (m *Model) SetPrimaryKey(columnNames []string)
- func (m *Model) String() string
- type PrimaryKey
- type Schema
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BelongsTo ¶
type BelongsTo struct {
Name string
ModelName string
ForeignKey string
ForeignType string
PrimaryKey string
Type string
Index bool
Null bool
Dependent string
Optional bool
Required bool
Default bool
}
func NewBelongsTo ¶ added in v0.1.7
type Config ¶
type Config struct {
Adapter string
Environment string
URL types.StringOrEnv
Database string
Host string
Port string
User string
Password string
Encoding string
Pool int
Timeout int
Socket string
Options map[string]string
RawOptions string
}
func (*Config) ConnectionURL ¶
return database connection url from config `sql.Open("adapter", config.ConnectionURL(true))`
func (*Config) GetDatabaseName ¶
type Database ¶
type Database struct {
Name string
Adapter string
TimeZone string
Generators []*Generator
Configs []*Config
Models []*Model
// contains filtered or unexported fields
}
func (*Database) CreateMySQLSchema ¶ added in v0.1.7
convert a mysql queryx database schema to an atlas sql schema
func (*Database) CreatePostgreSQLSchema ¶ added in v0.1.7
convert a postgresql queryx database schema to an atlas sql schema
func (*Database) CreateSQLiteSchema ¶
func (*Database) LoadConfig ¶
type Model ¶
type Model struct {
Database *Database
// model name in camel case
Name string
TableName string
TimeZone string
Timestamps bool
Columns []*Column
Attributes []*Attribute
BelongsTo []*BelongsTo
HasMany []*HasMany
HasOne []*HasOne
Index []*Index
// whether to automatically add a default primary key column named "id", default true
DefaultPrimaryKey bool
PrimaryKey *PrimaryKey
}
func (*Model) AddBelongsTo ¶
func (*Model) AddDefaultPrimaryKey ¶
func (m *Model) AddDefaultPrimaryKey()
set default primary key with id column for a model
func (*Model) AddHasMany ¶
func (*Model) AddTimestamps ¶
func (m *Model) AddTimestamps()
func (*Model) SetPrimaryKey ¶
custom primary key for a model
type PrimaryKey ¶
Click to show internal directories.
Click to hide internal directories.