Alter SQL column names to be distinct
This commit is contained in:
		
							parent
							
								
									a49b46381c
								
							
						
					
					
						commit
						28abdac5b6
					
				
					 14 changed files with 40 additions and 25 deletions
				
			
		
							
								
								
									
										15
									
								
								db/migrations/0003-distinguish-column-names.sql
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								db/migrations/0003-distinguish-column-names.sql
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
BEGIN TRANSACTION;
 | 
			
		||||
 | 
			
		||||
-- Rename mxc to mxc_url for consistency
 | 
			
		||||
 | 
			
		||||
ALTER TABLE lottie RENAME COLUMN mxc TO mxc_url;
 | 
			
		||||
 | 
			
		||||
-- Rename id to sticker_id so joins make sense in the future
 | 
			
		||||
 | 
			
		||||
ALTER TABLE lottie RENAME COLUMN id TO sticker_id;
 | 
			
		||||
 | 
			
		||||
-- Rename discord_id to user_id so joins make sense in the future
 | 
			
		||||
 | 
			
		||||
ALTER TABLE sim RENAME COLUMN discord_id TO user_id;
 | 
			
		||||
 | 
			
		||||
COMMIT;
 | 
			
		||||
							
								
								
									
										6
									
								
								db/orm-utils.d.ts
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								db/orm-utils.d.ts
									
										
									
									
										vendored
									
									
								
							| 
						 | 
				
			
			@ -28,8 +28,8 @@ export type Models = {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	lottie: {
 | 
			
		||||
		id: string
 | 
			
		||||
		mxc: string
 | 
			
		||||
		sticker_id: string
 | 
			
		||||
		mxc_url: string
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	member_cache: {
 | 
			
		||||
| 
						 | 
				
			
			@ -45,7 +45,7 @@ export type Models = {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	sim: {
 | 
			
		||||
		discord_id: string
 | 
			
		||||
		user_id: string
 | 
			
		||||
		sim_name: string
 | 
			
		||||
		localpart: string
 | 
			
		||||
		mxid: string
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -26,6 +26,6 @@ test("orm: from: get pluck works", t => {
 | 
			
		|||
})
 | 
			
		||||
 | 
			
		||||
test("orm: from: join and pluck works", t => {
 | 
			
		||||
	const mxid = from("sim").join("sim_member", "mxid").and("WHERE discord_id = ? AND room_id = ?").pluck("mxid").get("771520384671416320", "!hYnGGlPHlbujVVfktC:cadence.moe")
 | 
			
		||||
	const mxid = from("sim").join("sim_member", "mxid").and("WHERE user_id = ? AND room_id = ?").pluck("mxid").get("771520384671416320", "!hYnGGlPHlbujVVfktC:cadence.moe")
 | 
			
		||||
	t.equal(mxid, "@_ooye_bojack_horseman:cadence.moe")
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue