mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-10-31 02:27:04 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			72 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			72 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Microsoft.EntityFrameworkCore.Migrations;
 | |
| 
 | |
| namespace API.Data.Migrations
 | |
| {
 | |
|     public partial class AddedLibrary : Migration
 | |
|     {
 | |
|         protected override void Up(MigrationBuilder migrationBuilder)
 | |
|         {
 | |
|             migrationBuilder.CreateTable(
 | |
|                 name: "Library",
 | |
|                 columns: table => new
 | |
|                 {
 | |
|                     Id = table.Column<int>(type: "INTEGER", nullable: false)
 | |
|                         .Annotation("Sqlite:Autoincrement", true),
 | |
|                     Name = table.Column<string>(type: "TEXT", nullable: true),
 | |
|                     CoverImage = table.Column<string>(type: "TEXT", nullable: true),
 | |
|                     Type = table.Column<int>(type: "INTEGER", nullable: false),
 | |
|                     AppUserId = table.Column<int>(type: "INTEGER", nullable: false)
 | |
|                 },
 | |
|                 constraints: table =>
 | |
|                 {
 | |
|                     table.PrimaryKey("PK_Library", x => x.Id);
 | |
|                     table.ForeignKey(
 | |
|                         name: "FK_Library_Users_AppUserId",
 | |
|                         column: x => x.AppUserId,
 | |
|                         principalTable: "Users",
 | |
|                         principalColumn: "Id",
 | |
|                         onDelete: ReferentialAction.Cascade);
 | |
|                 });
 | |
| 
 | |
|             migrationBuilder.CreateTable(
 | |
|                 name: "FolderPath",
 | |
|                 columns: table => new
 | |
|                 {
 | |
|                     Id = table.Column<int>(type: "INTEGER", nullable: false)
 | |
|                         .Annotation("Sqlite:Autoincrement", true),
 | |
|                     Path = table.Column<string>(type: "TEXT", nullable: true),
 | |
|                     LibraryId = table.Column<int>(type: "INTEGER", nullable: true)
 | |
|                 },
 | |
|                 constraints: table =>
 | |
|                 {
 | |
|                     table.PrimaryKey("PK_FolderPath", x => x.Id);
 | |
|                     table.ForeignKey(
 | |
|                         name: "FK_FolderPath_Library_LibraryId",
 | |
|                         column: x => x.LibraryId,
 | |
|                         principalTable: "Library",
 | |
|                         principalColumn: "Id",
 | |
|                         onDelete: ReferentialAction.Restrict);
 | |
|                 });
 | |
| 
 | |
|             migrationBuilder.CreateIndex(
 | |
|                 name: "IX_FolderPath_LibraryId",
 | |
|                 table: "FolderPath",
 | |
|                 column: "LibraryId");
 | |
| 
 | |
|             migrationBuilder.CreateIndex(
 | |
|                 name: "IX_Library_AppUserId",
 | |
|                 table: "Library",
 | |
|                 column: "AppUserId");
 | |
|         }
 | |
| 
 | |
|         protected override void Down(MigrationBuilder migrationBuilder)
 | |
|         {
 | |
|             migrationBuilder.DropTable(
 | |
|                 name: "FolderPath");
 | |
| 
 | |
|             migrationBuilder.DropTable(
 | |
|                 name: "Library");
 | |
|         }
 | |
|     }
 | |
| }
 |