using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Iceshrimp.Backend.Core.Database.Migrations
{
///
public partial class AddPushSubscriptionTable : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn(
name: "masto_id",
table: "notification",
type: "bigint",
nullable: false,
defaultValue: 0L)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.CreateTable(
name: "push_subscription",
columns: table => new
{
id = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
createdAt = table.Column(type: "timestamp with time zone", nullable: false),
userId = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
oauthTokenId = table.Column(type: "character varying(32)", maxLength: 32, nullable: false),
endpoint = table.Column(type: "character varying(512)", maxLength: 512, nullable: false),
auth = table.Column(type: "character varying(256)", maxLength: 256, nullable: false),
publickey = table.Column(type: "character varying(128)", maxLength: 128, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_push_subscription", x => x.id);
table.ForeignKey(
name: "FK_push_subscription_oauth_token_oauthTokenId",
column: x => x.oauthTokenId,
principalTable: "oauth_token",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_push_subscription_user_userId",
column: x => x.userId,
principalTable: "user",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_push_subscription_oauthTokenId",
table: "push_subscription",
column: "oauthTokenId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_push_subscription_userId",
table: "push_subscription",
column: "userId");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "push_subscription");
migrationBuilder.DropColumn(
name: "masto_id",
table: "notification");
}
}
}