tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
20201122231443_PGAddOAuthConnections.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.EntityFrameworkCore.Migrations;
4using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
5
7{
11 public partial class PGAddOAuthConnections : Migration
12 {
14 protected override void Up(MigrationBuilder migrationBuilder)
15 {
16 ArgumentNullException.ThrowIfNull(migrationBuilder);
17
18 migrationBuilder.CreateTable(
19 name: "OAuthConnections",
20 columns: table => new
21 {
22 Id = table.Column<long>(nullable: false)
23 .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
24 Provider = table.Column<int>(nullable: false),
25 ExternalUserId = table.Column<string>(nullable: false, maxLength: 100),
26 UserId = table.Column<long>(nullable: true),
27 },
28 constraints: table =>
29 {
30 table.PrimaryKey("PK_OAuthConnections", x => x.Id);
31 table.ForeignKey(
32 name: "FK_OAuthConnections_Users_UserId",
33 column: x => x.UserId,
34 principalTable: "Users",
35 principalColumn: "Id",
36 onDelete: ReferentialAction.Cascade);
37 });
38
39 migrationBuilder.CreateIndex(
40 name: "IX_OAuthConnections_UserId",
41 table: "OAuthConnections",
42 column: "UserId");
43
44 migrationBuilder.CreateIndex(
45 name: "IX_OAuthConnections_Provider_ExternalUserId",
46 table: "OAuthConnections",
47 columns: new[] { "Provider", "ExternalUserId" },
48 unique: true);
49 }
50
52 protected override void Down(MigrationBuilder migrationBuilder)
53 {
54 ArgumentNullException.ThrowIfNull(migrationBuilder);
55
56 migrationBuilder.DropTable(
57 name: "OAuthConnections");
58 }
59 }
60}