Add unique index
This commit is contained in:
		
							parent
							
								
									c610e5ed9b
								
							
						
					
					
						commit
						b9a6e551cd
					
				
					 2 changed files with 14 additions and 0 deletions
				
			
		
							
								
								
									
										13
									
								
								migration/1558266512381-UserListJoining.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								migration/1558266512381-UserListJoining.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | ||||||
|  | import {MigrationInterface, QueryRunner} from "typeorm"; | ||||||
|  | 
 | ||||||
|  | export class UserListJoining1558266512381 implements MigrationInterface { | ||||||
|  | 
 | ||||||
|  |     public async up(queryRunner: QueryRunner): Promise<any> { | ||||||
|  |         await queryRunner.query(`CREATE UNIQUE INDEX "IDX_90f7da835e4c10aca6853621e1" ON "user_list_joining" ("userId", "userListId") `); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public async down(queryRunner: QueryRunner): Promise<any> { | ||||||
|  |         await queryRunner.query(`DROP INDEX "IDX_90f7da835e4c10aca6853621e1"`); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
|  | @ -4,6 +4,7 @@ import { UserList } from './user-list'; | ||||||
| import { id } from '../id'; | import { id } from '../id'; | ||||||
| 
 | 
 | ||||||
| @Entity() | @Entity() | ||||||
|  | @Index(['userId', 'userListId'], { unique: true }) | ||||||
| export class UserListJoining { | export class UserListJoining { | ||||||
| 	@PrimaryColumn(id()) | 	@PrimaryColumn(id()) | ||||||
| 	public id: string; | 	public id: string; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue