feat: migrator support table comment (#6225)
* feat: migrator support table comment * feat: migrator support tableType.It like ColumnTypes * Avoid updating the go.mod file. * Update tests_all.sh * Update migrator.go * remove Catalog() & Engine() methods. * remove CatalogValue & EngineValue. --------- Co-authored-by: Jinzhu <wosmvp@gmail.com>
This commit is contained in:
		
							parent
							
								
									32045fdd7d
								
							
						
					
					
						commit
						e61b98d696
					
				| @ -56,6 +56,14 @@ type Index interface { | ||||
| 	Option() string | ||||
| } | ||||
| 
 | ||||
| // TableType table type interface
 | ||||
| type TableType interface { | ||||
| 	Schema() string | ||||
| 	Name() string | ||||
| 	Type() string | ||||
| 	Comment() (comment string, ok bool) | ||||
| } | ||||
| 
 | ||||
| // Migrator migrator interface
 | ||||
| type Migrator interface { | ||||
| 	// AutoMigrate
 | ||||
| @ -72,6 +80,7 @@ type Migrator interface { | ||||
| 	HasTable(dst interface{}) bool | ||||
| 	RenameTable(oldName, newName interface{}) error | ||||
| 	GetTables() (tableList []string, err error) | ||||
| 	TableType(dst interface{}) (TableType, error) | ||||
| 
 | ||||
| 	// Columns
 | ||||
| 	AddColumn(dst interface{}, field string) error | ||||
|  | ||||
| @ -949,3 +949,8 @@ func (m Migrator) GetIndexes(dst interface{}) ([]gorm.Index, error) { | ||||
| func (m Migrator) GetTypeAliases(databaseTypeName string) []string { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| // TableType return tableType gorm.TableType and execErr error
 | ||||
| func (m Migrator) TableType(dst interface{}) (gorm.TableType, error) { | ||||
| 	return nil, errors.New("not support") | ||||
| } | ||||
|  | ||||
							
								
								
									
										33
									
								
								migrator/table_type.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								migrator/table_type.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,33 @@ | ||||
| package migrator | ||||
| 
 | ||||
| import ( | ||||
| 	"database/sql" | ||||
| ) | ||||
| 
 | ||||
| // TableType table type implements TableType interface
 | ||||
| type TableType struct { | ||||
| 	SchemaValue  string | ||||
| 	NameValue    string | ||||
| 	TypeValue    string | ||||
| 	CommentValue sql.NullString | ||||
| } | ||||
| 
 | ||||
| // Schema returns the schema of the table.
 | ||||
| func (ct TableType) Schema() string { | ||||
| 	return ct.SchemaValue | ||||
| } | ||||
| 
 | ||||
| // Name returns the name of the table.
 | ||||
| func (ct TableType) Name() string { | ||||
| 	return ct.NameValue | ||||
| } | ||||
| 
 | ||||
| // Type returns the type of the table.
 | ||||
| func (ct TableType) Type() string { | ||||
| 	return ct.TypeValue | ||||
| } | ||||
| 
 | ||||
| // Comment returns the comment of current table.
 | ||||
| func (ct TableType) Comment() (comment string, ok bool) { | ||||
| 	return ct.CommentValue.String, ct.CommentValue.Valid | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 John Mai
						John Mai