using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DodoSSH.Infrastructure.Migrations
{
///
public partial class AddTeamInvitation : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "team_invitation",
schema: "dodo",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false),
team_id = table.Column(type: "uuid", nullable: false),
email = table.Column(type: "citext", maxLength: 320, nullable: false),
role = table.Column(type: "integer", nullable: false),
invited_by_user_id = table.Column(type: "uuid", nullable: false),
created_at_utc = table.Column(type: "timestamp with time zone", nullable: false),
expires_at_utc = table.Column(type: "timestamp with time zone", nullable: false),
accepted_at_utc = table.Column(type: "timestamp with time zone", nullable: true),
accepted_by_user_id = table.Column(type: "uuid", nullable: true),
revoked_at_utc = table.Column(type: "timestamp with time zone", nullable: true),
xmin = table.Column(type: "xid", rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_team_invitation", x => x.id);
table.ForeignKey(
name: "fk_team_invitation_team_team_id",
column: x => x.team_id,
principalSchema: "dodo",
principalTable: "team",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_team_invitation_email",
schema: "dodo",
table: "team_invitation",
column: "email");
migrationBuilder.CreateIndex(
name: "ix_team_invitation_team_id_email",
schema: "dodo",
table: "team_invitation",
columns: new[] { "team_id", "email" },
unique: true,
filter: "accepted_at_utc IS NULL AND revoked_at_utc IS NULL");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "team_invitation",
schema: "dodo");
}
}
}