20210602224232_AddDevices.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #pragma warning disable CS1591
  2. #pragma warning disable SA1601
  3. using System;
  4. using Microsoft.EntityFrameworkCore.Migrations;
  5. namespace Jellyfin.Server.Implementations.Migrations
  6. {
  7. public partial class AddDevices : Migration
  8. {
  9. protected override void Up(MigrationBuilder migrationBuilder)
  10. {
  11. migrationBuilder.CreateTable(
  12. name: "ApiKeys",
  13. schema: "jellyfin",
  14. columns: table => new
  15. {
  16. Id = table.Column<int>(type: "INTEGER", nullable: false)
  17. .Annotation("Sqlite:Autoincrement", true),
  18. DateCreated = table.Column<DateTime>(type: "TEXT", nullable: false),
  19. DateLastActivity = table.Column<DateTime>(type: "TEXT", nullable: false),
  20. Name = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
  21. AccessToken = table.Column<Guid>(type: "TEXT", nullable: false)
  22. },
  23. constraints: table =>
  24. {
  25. table.PrimaryKey("PK_ApiKeys", x => x.Id);
  26. });
  27. migrationBuilder.CreateTable(
  28. name: "DeviceOptions",
  29. schema: "jellyfin",
  30. columns: table => new
  31. {
  32. Id = table.Column<int>(type: "INTEGER", nullable: false)
  33. .Annotation("Sqlite:Autoincrement", true),
  34. DeviceId = table.Column<string>(type: "TEXT", nullable: false),
  35. CustomName = table.Column<string>(type: "TEXT", nullable: true)
  36. },
  37. constraints: table =>
  38. {
  39. table.PrimaryKey("PK_DeviceOptions", x => x.Id);
  40. });
  41. migrationBuilder.CreateTable(
  42. name: "Devices",
  43. schema: "jellyfin",
  44. columns: table => new
  45. {
  46. Id = table.Column<int>(type: "INTEGER", nullable: false)
  47. .Annotation("Sqlite:Autoincrement", true),
  48. UserId = table.Column<Guid>(type: "TEXT", nullable: false),
  49. AccessToken = table.Column<string>(type: "TEXT", nullable: false),
  50. AppName = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
  51. AppVersion = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
  52. DeviceName = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
  53. DeviceId = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
  54. IsActive = table.Column<bool>(type: "INTEGER", nullable: false),
  55. DateCreated = table.Column<DateTime>(type: "TEXT", nullable: false),
  56. DateLastActivity = table.Column<DateTime>(type: "TEXT", nullable: false)
  57. },
  58. constraints: table =>
  59. {
  60. table.PrimaryKey("PK_Devices", x => x.Id);
  61. table.ForeignKey(
  62. name: "FK_Devices_Users_UserId",
  63. column: x => x.UserId,
  64. principalSchema: "jellyfin",
  65. principalTable: "Users",
  66. principalColumn: "Id",
  67. onDelete: ReferentialAction.Cascade);
  68. });
  69. migrationBuilder.CreateIndex(
  70. name: "IX_ApiKeys_AccessToken",
  71. schema: "jellyfin",
  72. table: "ApiKeys",
  73. column: "AccessToken",
  74. unique: true);
  75. migrationBuilder.CreateIndex(
  76. name: "IX_DeviceOptions_DeviceId",
  77. schema: "jellyfin",
  78. table: "DeviceOptions",
  79. column: "DeviceId",
  80. unique: true);
  81. migrationBuilder.CreateIndex(
  82. name: "IX_Devices_AccessToken_DateLastActivity",
  83. schema: "jellyfin",
  84. table: "Devices",
  85. columns: new[] { "AccessToken", "DateLastActivity" });
  86. migrationBuilder.CreateIndex(
  87. name: "IX_Devices_DeviceId",
  88. schema: "jellyfin",
  89. table: "Devices",
  90. column: "DeviceId");
  91. migrationBuilder.CreateIndex(
  92. name: "IX_Devices_DeviceId_DateLastActivity",
  93. schema: "jellyfin",
  94. table: "Devices",
  95. columns: new[] { "DeviceId", "DateLastActivity" });
  96. migrationBuilder.CreateIndex(
  97. name: "IX_Devices_UserId_DeviceId",
  98. schema: "jellyfin",
  99. table: "Devices",
  100. columns: new[] { "UserId", "DeviceId" });
  101. }
  102. protected override void Down(MigrationBuilder migrationBuilder)
  103. {
  104. migrationBuilder.DropTable(
  105. name: "ApiKeys",
  106. schema: "jellyfin");
  107. migrationBuilder.DropTable(
  108. name: "DeviceOptions",
  109. schema: "jellyfin");
  110. migrationBuilder.DropTable(
  111. name: "Devices",
  112. schema: "jellyfin");
  113. }
  114. }
  115. }