Fix create with ignore migration (#4571)
This commit is contained in:
		
							parent
							
								
									82fe815303
								
							
						
					
					
						commit
						21e85b89d6
					
				| @ -167,11 +167,13 @@ func (m Migrator) CreateTable(values ...interface{}) error { | |||||||
| 
 | 
 | ||||||
| 			for _, dbName := range stmt.Schema.DBNames { | 			for _, dbName := range stmt.Schema.DBNames { | ||||||
| 				field := stmt.Schema.FieldsByDBName[dbName] | 				field := stmt.Schema.FieldsByDBName[dbName] | ||||||
|  | 				if !field.IgnoreMigration { | ||||||
| 					createTableSQL += "? ?" | 					createTableSQL += "? ?" | ||||||
| 					hasPrimaryKeyInDataType = hasPrimaryKeyInDataType || strings.Contains(strings.ToUpper(string(field.DataType)), "PRIMARY KEY") | 					hasPrimaryKeyInDataType = hasPrimaryKeyInDataType || strings.Contains(strings.ToUpper(string(field.DataType)), "PRIMARY KEY") | ||||||
| 					values = append(values, clause.Column{Name: dbName}, m.DB.Migrator().FullDataTypeOf(field)) | 					values = append(values, clause.Column{Name: dbName}, m.DB.Migrator().FullDataTypeOf(field)) | ||||||
| 					createTableSQL += "," | 					createTableSQL += "," | ||||||
| 				} | 				} | ||||||
|  | 			} | ||||||
| 
 | 
 | ||||||
| 			if !hasPrimaryKeyInDataType && len(stmt.Schema.PrimaryFields) > 0 { | 			if !hasPrimaryKeyInDataType && len(stmt.Schema.PrimaryFields) > 0 { | ||||||
| 				createTableSQL += "PRIMARY KEY ?," | 				createTableSQL += "PRIMARY KEY ?," | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user