Merge 3b699fdf3e6cebd6fdb4539438e96b93e59a5bb9 into 89a726ce5da26da893dd3c2d8475e1d66677fd9c
This commit is contained in:
		
						commit
						2a106b7960
					
				
							
								
								
									
										7
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								main.go
									
									
									
									
									
								
							@ -568,6 +568,13 @@ func (s *DB) AutoMigrate(values ...interface{}) *DB {
 | 
			
		||||
	return db
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// AddColumn add column with type
 | 
			
		||||
func (s *DB) AddColumn(column string, typ string) *DB {
 | 
			
		||||
	scope := s.clone().NewScope(s.Value)
 | 
			
		||||
	scope.addColumn(column, typ)
 | 
			
		||||
	return scope.db
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ModifyColumn modify column to type
 | 
			
		||||
func (s *DB) ModifyColumn(column string, typ string) *DB {
 | 
			
		||||
	scope := s.clone().NewScope(s.Value)
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										4
									
								
								scope.go
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								scope.go
									
									
									
									
									
								
							@ -1138,6 +1138,10 @@ func (scope *Scope) dropTable() *Scope {
 | 
			
		||||
	return scope
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (scope *Scope) addColumn(column string, typ string) {
 | 
			
		||||
	scope.Raw(fmt.Sprintf("ALTER TABLE %v ADD %v %v", scope.QuotedTableName(), scope.Quote(column), typ)).Exec()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (scope *Scope) modifyColumn(column string, typ string) {
 | 
			
		||||
	scope.db.AddError(scope.Dialect().ModifyColumn(scope.QuotedTableName(), scope.Quote(column), typ))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user