models

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

func (Item) TableName

func (Item) TableName() string

TableName returns the stable table name for Atlas-generated migrations.

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 Owner added in v0.4.0

type Owner struct {
	ID   uint   `gorm:"primaryKey"`
	Name string `gorm:"size:64;not null"`
}

Owner is the parent every relation-deletion fixture references (#312).

func (Owner) TableName added in v0.4.0

func (Owner) 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

type SoftOwner struct {
	gorm.Model
	Name string `gorm:"size:64;not null"`
}

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.

func (SoftOwner) TableName added in v0.4.0

func (SoftOwner) TableName() string

TableName returns the stable table name for Atlas-generated migrations.

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.

Jump to

Keyboard shortcuts

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