Documentation
¶
Overview ¶
Package models holds GORM fixtures for the multi-DB conformance suite.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CascadedChild ¶ added in v0.4.0
type CascadedChild struct {
ID uint `gorm:"primaryKey"`
OwnerID uint `gorm:"not null;index"`
Owner Owner `gorm:"constraint:OnDelete:CASCADE;"`
}
CascadedChild references Owner with ON DELETE CASCADE.
func (CascadedChild) TableName ¶ added in v0.4.0
func (CascadedChild) TableName() string
TableName returns the stable table name for Atlas-generated migrations.
type Item ¶
type Item struct {
gorm.Model
Code string `gorm:"size:64;uniqueIndex;not null"`
Name string `gorm:"size:120;index;not null"`
Notes *string `gorm:"size:255"`
Price decimal.Decimal `gorm:"type:decimal(19,4);not null"`
Discount types.Decimal `gorm:"type:decimal(19,4);not null"`
// Loose declares no precision, as an untagged types.Decimal does: an
// unbounded numeric on PostgreSQL, DECIMAL(10,0) on MySQL (#440).
Loose *types.Decimal
}
Item exercises portable schema features required by M2-4 conformance: timestamps (via gorm.Model), nullable columns, unique + non-unique indexes, and decimal storage (Loose with no declared precision). Discount uses the framework types.Decimal wrapper (#222) so the shared money type is covered across the SQLite/PostgreSQL/MySQL matrix.
type NulledChild ¶ added in v0.4.0
type NulledChild struct {
ID uint `gorm:"primaryKey"`
OwnerID *uint `gorm:"index"`
Owner *Owner `gorm:"constraint:OnDelete:SET NULL;"`
}
NulledChild references Owner with ON DELETE SET NULL.
func (NulledChild) TableName ¶ added in v0.4.0
func (NulledChild) TableName() string
TableName returns the stable table name for Atlas-generated migrations.
type RestrictedChild ¶ added in v0.4.0
type RestrictedChild struct {
ID uint `gorm:"primaryKey"`
OwnerID uint `gorm:"not null;index"`
Owner Owner `gorm:"constraint:OnDelete:RESTRICT;"`
}
RestrictedChild references Owner with ON DELETE RESTRICT.
func (RestrictedChild) TableName ¶ added in v0.4.0
func (RestrictedChild) TableName() string
TableName returns the stable table name for Atlas-generated migrations.
type SoftOwner ¶ added in v0.4.0
SoftOwner is a legacy gorm.Model parent: GORM's own Delete only sets deleted_at, so no foreign key fires. database.Delete removes it for real.
type SoftOwnerChild ¶ added in v0.4.0
type SoftOwnerChild struct {
ID uint `gorm:"primaryKey"`
SoftOwnerID uint `gorm:"not null;index"`
SoftOwner SoftOwner `gorm:"constraint:OnDelete:RESTRICT;"`
}
SoftOwnerChild references SoftOwner with ON DELETE RESTRICT.
func (SoftOwnerChild) TableName ¶ added in v0.4.0
func (SoftOwnerChild) TableName() string
TableName returns the stable table name for Atlas-generated migrations.