model

package
v0.0.0-...-86b9d59 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataPopulate

func DataPopulate(db *gorm.DB)

func GetGeoTypeMap

func GetGeoTypeMap() map[string]bool

GetGeoTypeValues returns a map of geo types for validation

func GetGeoTypeValues

func GetGeoTypeValues() []string

GetGeoTypeValues returns a slice of geo types

func GetTopLevelGeoNames

func GetTopLevelGeoNames() map[string]string

func Migrate

func Migrate(db *gorm.DB)

setup schema

func SetupDBOnceOnly

func SetupDBOnceOnly(dsn string)

special case for use in comptests - only setup db if it has not already been set up. This is safe to call multiple times against the same db.

func SetupUpdateDB

func SetupUpdateDB(dsn string)

SetupUpdate is used both to create and update the database It's OK to call this more than once on the same DB

Types

type DataVer

type DataVer struct {
	gorm.Model       // updated_at etc
	ID         int32 `gorm:"primaryKey;autoIncrement:false"`
	CensusYear int32
	VerString  string
	Source     string
	Notes      string
	Public     bool
	GoMetrics  []GeoMetric `gorm:"foreignKey:DataVerID;references:ID"`
}

func (DataVer) TableName

func (DataVer) TableName() string

don't pluralise table name

type Geo

type Geo struct {
	ID        int32 `gorm:"primaryKey"`
	TypeID    int32
	Code      string `gorm:"index:unique"`
	Name      string
	WelshName string
	Lat       float64 // probably redundant use LongLatGeom
	Long      float64 // probably redundant use LongLatGeom
	Valid     bool    `gorm:"DEFAULT:true"`

	// wkb_geometry - added via ALTER don't migrate
	Wkbgeometry sql.NullString `gorm:"column:wkb_geometry;-:migration"`

	// wkb_long_lat_geom - added via ALTER don't migrate
	WkbLongLatGeom sql.NullString `gorm:"column:wkb_long_lat_geom;-:migration"`

	GoMetrics []GeoMetric `gorm:"foreignKey:GeoID;references:ID"`
	PostCodes []PostCode  `gorm:"foreignKey:GeoID;references:ID"`
}

func (Geo) TableName

func (Geo) TableName() string

don't pluralise table name

type GeoMetric

type GeoMetric struct {
	ID         int32 `gorm:"primaryKey"`
	GeoID      int32 `gorm:"index"`
	CategoryID int32 `gorm:"index"`
	Metric     float64
	DataVerID  int32
}

func (GeoMetric) TableName

func (GeoMetric) TableName() string

don't pluralise table name

type GeoType

type GeoType struct {
	ID   int32 `gorm:"primaryKey;autoIncrement:false"`
	Name string
	Geos []Geo `gorm:"foreignKey:TypeID;references:ID"`
}

func (GeoType) TableName

func (GeoType) TableName() string

don't pluralise table

type NomisCategory

type NomisCategory struct {
	// why do we need uniqueIndex? composite key!
	ID              int32 `gorm:"uniqueIndex;primaryKey"`
	NomisDescID     int32 `gorm:"primaryKey"`
	CategoryName    string
	MeasurementUnit string
	StatUnit        string
	LongNomisCode   string `gorm:"uniqueIndex"`
	Year            int32
	GoMetrics       []GeoMetric `gorm:"foreignKey:CategoryID;references:ID"`
}

func (NomisCategory) TableName

func (NomisCategory) TableName() string

don't pluralise table name

type NomisDesc

type NomisDesc struct {
	ID              int32 `gorm:"uniqueIndex;primaryKey"`
	NomisTopicID    int32 `gorm:"primaryKey"`
	Name            string
	PopStat         string
	ShortNomisCode  string `gorm:"uniqueIndex"`
	Year            int32
	NomisCategories []NomisCategory `gorm:"foreignKey:NomisDescID;references:ID"`
}

func (NomisDesc) TableName

func (NomisDesc) TableName() string

don't pluralise table name

type NomisTopic

type NomisTopic struct {
	ID           int32 `gorm:"primaryKey"`
	TopNomisCode string
	Name         string
	NomisDescs   []NomisDesc `gorm:"foreignKey:NomisTopicID;references:ID"`
}

func (NomisTopic) TableName

func (NomisTopic) TableName() string

don't pluralise table name

type PostCode

type PostCode struct {
	ID    int32 `gorm:"primaryKey"`
	GeoID int32 `gorm:"index"`
	Pcds  string
	Geo   Geo // XXX
}

func (PostCode) TableName

func (PostCode) TableName() string

don't pluralise table name

type SchemaVer

type SchemaVer struct {
	gorm.Model // updated_at etc
	BuildTime  string
	GitCommit  string
	Version    string
}

func (SchemaVer) TableName

func (SchemaVer) TableName() string

don't pluralise table name

type YearMapping

type YearMapping struct {
	ID           int32 `gorm:"primaryKey"`
	Lsoa2011code string
	Lad2020code  string
}

func (YearMapping) TableName

func (YearMapping) TableName() string

don't pluralise table name

Jump to

Keyboard shortcuts

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