// Code generated by gopkg.in/reform.v1. DO NOT EDIT.

package models

import (
	"fmt"
	"strings"

	"gopkg.in/reform.v1"
	"gopkg.in/reform.v1/parse"
)

type restoreHistoryItemTableType struct {
	s parse.StructInfo
	z []interface{}
}

// Schema returns a schema name in SQL database ("").
func (v *restoreHistoryItemTableType) Schema() string {
	return v.s.SQLSchema
}

// Name returns a view or table name in SQL database ("restore_history").
func (v *restoreHistoryItemTableType) Name() string {
	return v.s.SQLName
}

// Columns returns a new slice of column names for that view or table in SQL database.
func (v *restoreHistoryItemTableType) Columns() []string {
	return []string{
		"id",
		"artifact_id",
		"service_id",
		"status",
		"started_at",
		"finished_at",
	}
}

// NewStruct makes a new struct for that view or table.
func (v *restoreHistoryItemTableType) NewStruct() reform.Struct {
	return new(RestoreHistoryItem)
}

// NewRecord makes a new record for that table.
func (v *restoreHistoryItemTableType) NewRecord() reform.Record {
	return new(RestoreHistoryItem)
}

// PKColumnIndex returns an index of primary key column for that table in SQL database.
func (v *restoreHistoryItemTableType) PKColumnIndex() uint {
	return uint(v.s.PKFieldIndex)
}

// RestoreHistoryItemTable represents restore_history view or table in SQL database.
var RestoreHistoryItemTable = &restoreHistoryItemTableType{
	s: parse.StructInfo{
		Type:    "RestoreHistoryItem",
		SQLName: "restore_history",
		Fields: []parse.FieldInfo{
			{Name: "ID", Type: "string", Column: "id"},
			{Name: "ArtifactID", Type: "string", Column: "artifact_id"},
			{Name: "ServiceID", Type: "string", Column: "service_id"},
			{Name: "Status", Type: "RestoreStatus", Column: "status"},
			{Name: "StartedAt", Type: "time.Time", Column: "started_at"},
			{Name: "FinishedAt", Type: "*time.Time", Column: "finished_at"},
		},
		PKFieldIndex: 0,
	},
	z: new(RestoreHistoryItem).Values(),
}

// String returns a string representation of this struct or record.
func (s RestoreHistoryItem) String() string {
	res := make([]string, 6)
	res[0] = "ID: " + reform.Inspect(s.ID, true)
	res[1] = "ArtifactID: " + reform.Inspect(s.ArtifactID, true)
	res[2] = "ServiceID: " + reform.Inspect(s.ServiceID, true)
	res[3] = "Status: " + reform.Inspect(s.Status, true)
	res[4] = "StartedAt: " + reform.Inspect(s.StartedAt, true)
	res[5] = "FinishedAt: " + reform.Inspect(s.FinishedAt, true)
	return strings.Join(res, ", ")
}

// Values returns a slice of struct or record field values.
// Returned interface{} values are never untyped nils.
func (s *RestoreHistoryItem) Values() []interface{} {
	return []interface{}{
		s.ID,
		s.ArtifactID,
		s.ServiceID,
		s.Status,
		s.StartedAt,
		s.FinishedAt,
	}
}

// Pointers returns a slice of pointers to struct or record fields.
// Returned interface{} values are never untyped nils.
func (s *RestoreHistoryItem) Pointers() []interface{} {
	return []interface{}{
		&s.ID,
		&s.ArtifactID,
		&s.ServiceID,
		&s.Status,
		&s.StartedAt,
		&s.FinishedAt,
	}
}

// View returns View object for that struct.
func (s *RestoreHistoryItem) View() reform.View {
	return RestoreHistoryItemTable
}

// Table returns Table object for that record.
func (s *RestoreHistoryItem) Table() reform.Table {
	return RestoreHistoryItemTable
}

// PKValue returns a value of primary key for that record.
// Returned interface{} value is never untyped nil.
func (s *RestoreHistoryItem) PKValue() interface{} {
	return s.ID
}

// PKPointer returns a pointer to primary key field for that record.
// Returned interface{} value is never untyped nil.
func (s *RestoreHistoryItem) PKPointer() interface{} {
	return &s.ID
}

// HasPK returns true if record has non-zero primary key set, false otherwise.
func (s *RestoreHistoryItem) HasPK() bool {
	return s.ID != RestoreHistoryItemTable.z[RestoreHistoryItemTable.s.PKFieldIndex]
}

// SetPK sets record primary key, if possible.
//
// Deprecated: prefer direct field assignment where possible: s.ID = pk.
func (s *RestoreHistoryItem) SetPK(pk interface{}) {
	reform.SetPK(s, pk)
}

// check interfaces
var (
	_ reform.View   = RestoreHistoryItemTable
	_ reform.Struct = (*RestoreHistoryItem)(nil)
	_ reform.Table  = RestoreHistoryItemTable
	_ reform.Record = (*RestoreHistoryItem)(nil)
	_ fmt.Stringer  = (*RestoreHistoryItem)(nil)
)

func init() {
	parse.AssertUpToDate(&RestoreHistoryItemTable.s, new(RestoreHistoryItem))
}
