20210814002109_AddDevices.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #pragma warning disable CS1591, SA1601
  2. using System;
  3. using Microsoft.EntityFrameworkCore.Migrations;
  4. namespace Jellyfin.Server.Implementations.Migrations
  5. {
  6. public partial class AddDevices : Migration
  7. {
  8. protected override void Up(MigrationBuilder migrationBuilder)
  9. {
  10. migrationBuilder.CreateTable(
  11. name: "ApiKeys",
  12. schema: "jellyfin",
  13. columns: table => new
  14. {
  15. Id = table.Column<int>(type: "INTEGER", nullable: false)
  16. .Annotation("Sqlite:Autoincrement", true),
  17. DateCreated = table.Column<DateTime>(type: "TEXT", nullable: false),
  18. DateLastActivity = table.Column<DateTime>(type: "TEXT", nullable: false),
  19. Name = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
  20. AccessToken = table.Column<string>(type: "TEXT", nullable: false)
  21. },
  22. constraints: table =>
  23. {
  24. table.PrimaryKey("PK_ApiKeys", x => x.Id);
  25. });
  26. migrationBuilder.CreateTable(
  27. name: "DeviceOptions",
  28. schema: "jellyfin",
  29. columns: table => new
  30. {
  31. Id = table.Column<int>(type: "INTEGER", nullable: false)
  32. .Annotation("Sqlite:Autoincrement", true),
  33. DeviceId = table.Column<string>(type: "TEXT", nullable: false),
  34. CustomName = table.Column<string>(type: "TEXT", nullable: true)
  35. },
  36. constraints: table =>
  37. {
  38. table.PrimaryKey("PK_DeviceOptions", x => x.Id);
  39. });
  40. migrationBuilder.CreateTable(
  41. name: "Devices",
  42. schema: "jellyfin",
  43. columns: table => new
  44. {
  45. Id = table.Column<int>(type: "INTEGER", nullable: false)
  46. .Annotation("Sqlite:Autoincrement", true),
  47. UserId = table.Column<Guid>(type: "TEXT", nullable: false),
  48. AccessToken = table.Column<string>(type: "TEXT", nullable: false),
  49. AppName = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
  50. AppVersion = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
  51. DeviceName = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
  52. DeviceId = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
  53. IsActive = table.Column<bool>(type: "INTEGER", nullable: false),
  54. DateCreated = table.Column<DateTime>(type: "TEXT", nullable: false),
  55. DateModified = 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. }