Debian Codegraph @

migrator/index.go

raw
1 package migrator
2
3 import "database/sql"
4
5 // Index implements gorm.Index interface
6 type Index struct {
7 TableName string
8 NameValue string
9 ColumnList []string
10 PrimaryKeyValue sql.NullBool
11 UniqueValue sql.NullBool
12 OptionValue string
13 }
14
15 // Table return the table name of the index.
16 func (idx Index) Table() string {
17 return idx.TableName
18 }
19
20 // Name return the name of the index.
21 func (idx Index) Name() string {
22 return idx.NameValue
23 }
24
25 // Columns return the columns of the index
26 func (idx Index) Columns() []string {
27 return idx.ColumnList
28 }
29
30 // PrimaryKey returns the index is primary key or not.
31 func (idx Index) PrimaryKey() (isPrimaryKey bool, ok bool) {
32 return idx.PrimaryKeyValue.Bool, idx.PrimaryKeyValue.Valid
33 }
34
35 // Unique returns whether the index is unique or not.
36 func (idx Index) Unique() (unique bool, ok bool) {
37 return idx.UniqueValue.Bool, idx.UniqueValue.Valid
38 }
39
40 // Option return the optional attribute of the index
41 func (idx Index) Option() string {
42 return idx.OptionValue
43 }