115 lines
4.2 KiB
C#
115 lines
4.2 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace NostrStreamer.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class V2 : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropColumn(
|
|
name: "Event",
|
|
table: "Users");
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "Nostr",
|
|
table: "Payments",
|
|
type: "text",
|
|
nullable: true);
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "Type",
|
|
table: "Payments",
|
|
type: "integer",
|
|
nullable: false,
|
|
defaultValue: 0);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Streams",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PubKey = table.Column<string>(type: "text", nullable: false),
|
|
ClientId = table.Column<string>(type: "text", nullable: false),
|
|
Starts = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
Ends = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
State = table.Column<int>(type: "integer", nullable: false),
|
|
Event = table.Column<string>(type: "text", nullable: false),
|
|
Recording = table.Column<string>(type: "text", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Streams", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Streams_Users_PubKey",
|
|
column: x => x.PubKey,
|
|
principalTable: "Users",
|
|
principalColumn: "PubKey",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Guests",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
StreamId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
PubKey = table.Column<string>(type: "text", nullable: false),
|
|
Relay = table.Column<string>(type: "text", nullable: true),
|
|
Role = table.Column<string>(type: "text", nullable: true),
|
|
Sig = table.Column<string>(type: "text", nullable: true),
|
|
ZapSplit = table.Column<decimal>(type: "numeric", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Guests", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_Guests_Streams_StreamId",
|
|
column: x => x.StreamId,
|
|
principalTable: "Streams",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Guests_StreamId_PubKey",
|
|
table: "Guests",
|
|
columns: new[] { "StreamId", "PubKey" },
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Streams_PubKey",
|
|
table: "Streams",
|
|
column: "PubKey");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Guests");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "Streams");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Nostr",
|
|
table: "Payments");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "Type",
|
|
table: "Payments");
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "Event",
|
|
table: "Users",
|
|
type: "text",
|
|
nullable: true);
|
|
}
|
|
}
|
|
}
|