mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-10-28 10:51:44 +01:00 
			
		
		
		
	Migrate DB: rename table is plural, order matters
The calls to AutoMigrate to other classes that refer to users will create the table and it will break, it needs to be done before everything else. Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
This commit is contained in:
		
							parent
							
								
									81441afe70
								
							
						
					
					
						commit
						9eaa8dd049
					
				
							
								
								
									
										14
									
								
								db.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								db.go
									
									
									
									
									
								
							| @ -41,6 +41,13 @@ func (h *Headscale) initDB() error { | ||||
| 		db.Exec(`create extension if not exists "uuid-ossp";`) | ||||
| 	} | ||||
| 
 | ||||
| 	_ = db.Migrator().RenameTable("namespaces", "users") | ||||
| 
 | ||||
| 	err = db.AutoMigrate(&User{}) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	_ = db.Migrator().RenameColumn(&Machine{}, "ip_address", "ip_addresses") | ||||
| 	_ = db.Migrator().RenameColumn(&Machine{}, "name", "hostname") | ||||
| 
 | ||||
| @ -187,13 +194,6 @@ func (h *Headscale) initDB() error { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	_ = db.Migrator().RenameTable("Namespace", "User") | ||||
| 
 | ||||
| 	err = db.AutoMigrate(&User{}) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	err = db.AutoMigrate(&PreAuthKey{}) | ||||
| 	if err != nil { | ||||
| 		return err | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user