-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add method GetIndexes * feat: add default impl for Index interface * feat: fmt
- Loading branch information
Showing
3 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package migrator | ||
|
||
import "database/sql" | ||
|
||
// Index implements gorm.Index interface | ||
type Index struct { | ||
TableName string | ||
NameValue string | ||
ColumnList []string | ||
PrimaryKeyValue sql.NullBool | ||
UniqueValue sql.NullBool | ||
OptionValue string | ||
} | ||
|
||
// Table return the table name of the index. | ||
func (idx Index) Table() string { | ||
return idx.TableName | ||
} | ||
|
||
// Name return the name of the index. | ||
func (idx Index) Name() string { | ||
return idx.NameValue | ||
} | ||
|
||
// Columns return the columns fo the index | ||
func (idx Index) Columns() []string { | ||
return idx.ColumnList | ||
} | ||
|
||
// PrimaryKey returns the index is primary key or not. | ||
func (idx Index) PrimaryKey() (isPrimaryKey bool, ok bool) { | ||
return idx.PrimaryKeyValue.Bool, idx.PrimaryKeyValue.Valid | ||
} | ||
|
||
// Unique returns whether the index is unique or not. | ||
func (idx Index) Unique() (unique bool, ok bool) { | ||
return idx.UniqueValue.Bool, idx.UniqueValue.Valid | ||
} | ||
|
||
// Option return the optional attribute fo the index | ||
func (idx Index) Option() string { | ||
return idx.OptionValue | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters