//
// 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 Email = newEmailTable("comms", "email", "")

type emailTable struct {
	postgres.Table

	// Columns
	Address      postgres.ColumnString
	IsSubscribed postgres.ColumnBool

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

type EmailTable struct {
	emailTable

	EXCLUDED emailTable
}

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

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

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

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

func newEmailTable(schemaName, tableName, alias string) *EmailTable {
	return &EmailTable{
		emailTable: newEmailTableImpl(schemaName, tableName, alias),
		EXCLUDED:   newEmailTableImpl("", "excluded", ""),
	}
}

func newEmailTableImpl(schemaName, tableName, alias string) emailTable {
	var (
		AddressColumn      = postgres.StringColumn("address")
		IsSubscribedColumn = postgres.BoolColumn("is_subscribed")
		allColumns         = postgres.ColumnList{AddressColumn, IsSubscribedColumn}
		mutableColumns     = postgres.ColumnList{IsSubscribedColumn}
		defaultColumns     = postgres.ColumnList{}
	)

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

		//Columns
		Address:      AddressColumn,
		IsSubscribed: IsSubscribedColumn,

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