forked from ariga/atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
revision.go
140 lines (121 loc) · 4.85 KB
/
revision.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
// Copyright 2021-present The Atlas Authors. All rights reserved.
// This source code is licensed under the Apache 2.0 license found
// in the LICENSE file in the root directory of this source tree.
// Code generated by entc, DO NOT EDIT.
package revision
import (
"github.com/iasthc/atlas/sql/migrate"
"entgo.io/ent/dialect/sql"
)
const (
// Label holds the string label denoting the revision type in the database.
Label = "revision"
// FieldID holds the string denoting the id field in the database.
FieldID = "version"
// FieldDescription holds the string denoting the description field in the database.
FieldDescription = "description"
// FieldType holds the string denoting the type field in the database.
FieldType = "type"
// FieldApplied holds the string denoting the applied field in the database.
FieldApplied = "applied"
// FieldTotal holds the string denoting the total field in the database.
FieldTotal = "total"
// FieldExecutedAt holds the string denoting the executed_at field in the database.
FieldExecutedAt = "executed_at"
// FieldExecutionTime holds the string denoting the execution_time field in the database.
FieldExecutionTime = "execution_time"
// FieldError holds the string denoting the error field in the database.
FieldError = "error"
// FieldErrorStmt holds the string denoting the error_stmt field in the database.
FieldErrorStmt = "error_stmt"
// FieldHash holds the string denoting the hash field in the database.
FieldHash = "hash"
// FieldPartialHashes holds the string denoting the partial_hashes field in the database.
FieldPartialHashes = "partial_hashes"
// FieldOperatorVersion holds the string denoting the operator_version field in the database.
FieldOperatorVersion = "operator_version"
// Table holds the table name of the revision in the database.
Table = "atlas_schema_revisions"
)
// Columns holds all SQL columns for revision fields.
var Columns = []string{
FieldID,
FieldDescription,
FieldType,
FieldApplied,
FieldTotal,
FieldExecutedAt,
FieldExecutionTime,
FieldError,
FieldErrorStmt,
FieldHash,
FieldPartialHashes,
FieldOperatorVersion,
}
// ValidColumn reports if the column name is valid (part of the table columns).
func ValidColumn(column string) bool {
for i := range Columns {
if column == Columns[i] {
return true
}
}
return false
}
var (
// DefaultType holds the default value on creation for the "type" field.
DefaultType migrate.RevisionType
// DefaultApplied holds the default value on creation for the "applied" field.
DefaultApplied int
// AppliedValidator is a validator for the "applied" field. It is called by the builders before save.
AppliedValidator func(int) error
// DefaultTotal holds the default value on creation for the "total" field.
DefaultTotal int
// TotalValidator is a validator for the "total" field. It is called by the builders before save.
TotalValidator func(int) error
)
// OrderOption defines the ordering options for the Revision queries.
type OrderOption func(*sql.Selector)
// ByID orders the results by the id field.
func ByID(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldID, opts...).ToFunc()
}
// ByDescription orders the results by the description field.
func ByDescription(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldDescription, opts...).ToFunc()
}
// ByType orders the results by the type field.
func ByType(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldType, opts...).ToFunc()
}
// ByApplied orders the results by the applied field.
func ByApplied(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldApplied, opts...).ToFunc()
}
// ByTotal orders the results by the total field.
func ByTotal(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldTotal, opts...).ToFunc()
}
// ByExecutedAt orders the results by the executed_at field.
func ByExecutedAt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldExecutedAt, opts...).ToFunc()
}
// ByExecutionTime orders the results by the execution_time field.
func ByExecutionTime(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldExecutionTime, opts...).ToFunc()
}
// ByError orders the results by the error field.
func ByError(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldError, opts...).ToFunc()
}
// ByErrorStmt orders the results by the error_stmt field.
func ByErrorStmt(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldErrorStmt, opts...).ToFunc()
}
// ByHash orders the results by the hash field.
func ByHash(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldHash, opts...).ToFunc()
}
// ByOperatorVersion orders the results by the operator_version field.
func ByOperatorVersion(opts ...sql.OrderTermOption) OrderOption {
return sql.OrderByField(FieldOperatorVersion, opts...).ToFunc()
}