//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//

package table

import (
	"github.com/Gleipnir-Technology/jet/postgres"
)

var Job = newJobTable("public", "job", "")

// A temporary holding place for jobs that are pushed to backend workers. Once work is completed the job should be deleted
type jobTable struct {
	postgres.Table

	// Columns
	Created postgres.ColumnTimestamp
	ID      postgres.ColumnInteger
	Type    postgres.ColumnString
	RowID   postgres.ColumnInteger

	AllColumns     postgres.ColumnList
	MutableColumns postgres.ColumnList
	DefaultColumns postgres.ColumnList
}

type JobTable struct {
	jobTable

	EXCLUDED jobTable
}

// AS creates new JobTable with assigned alias
func (a JobTable) AS(alias string) *JobTable {
	return newJobTable(a.SchemaName(), a.TableName(), alias)
}

// Schema creates new JobTable with assigned schema name
func (a JobTable) FromSchema(schemaName string) *JobTable {
	return newJobTable(schemaName, a.TableName(), a.Alias())
}

// WithPrefix creates new JobTable with assigned table prefix
func (a JobTable) WithPrefix(prefix string) *JobTable {
	return newJobTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}

// WithSuffix creates new JobTable with assigned table suffix
func (a JobTable) WithSuffix(suffix string) *JobTable {
	return newJobTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}

func newJobTable(schemaName, tableName, alias string) *JobTable {
	return &JobTable{
		jobTable: newJobTableImpl(schemaName, tableName, alias),
		EXCLUDED: newJobTableImpl("", "excluded", ""),
	}
}

func newJobTableImpl(schemaName, tableName, alias string) jobTable {
	var (
		CreatedColumn  = postgres.TimestampColumn("created")
		IDColumn       = postgres.IntegerColumn("id")
		TypeColumn     = postgres.StringColumn("type_")
		RowIDColumn    = postgres.IntegerColumn("row_id")
		allColumns     = postgres.ColumnList{CreatedColumn, IDColumn, TypeColumn, RowIDColumn}
		mutableColumns = postgres.ColumnList{CreatedColumn, TypeColumn, RowIDColumn}
		defaultColumns = postgres.ColumnList{IDColumn}
	)

	return jobTable{
		Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),

		//Columns
		Created: CreatedColumn,
		ID:      IDColumn,
		Type:    TypeColumn,
		RowID:   RowIDColumn,

		AllColumns:     allColumns,
		MutableColumns: mutableColumns,
		DefaultColumns: defaultColumns,
	}
}
