✨ Poll and its CRUD
This commit is contained in:
2073
DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.Designer.cs
generated
Normal file
2073
DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
121
DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.cs
Normal file
121
DysonNetwork.Sphere/Migrations/20250802095248_AddPoll.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using DysonNetwork.Sphere.Poll;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using NodaTime;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace DysonNetwork.Sphere.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddPoll : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "polls",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
title = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: true),
|
||||
description = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
|
||||
ended_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true),
|
||||
publisher_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
||||
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
||||
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_polls", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "fk_polls_publishers_publisher_id",
|
||||
column: x => x.publisher_id,
|
||||
principalTable: "publishers",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "poll_answers",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
answer = table.Column<Dictionary<string, JsonElement>>(type: "jsonb", nullable: false),
|
||||
account_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
poll_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
||||
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
||||
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_poll_answers", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "fk_poll_answers_polls_poll_id",
|
||||
column: x => x.poll_id,
|
||||
principalTable: "polls",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "poll_questions",
|
||||
columns: table => new
|
||||
{
|
||||
id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
type = table.Column<int>(type: "integer", nullable: false),
|
||||
options = table.Column<List<PollOption>>(type: "jsonb", nullable: true),
|
||||
title = table.Column<string>(type: "character varying(1024)", maxLength: 1024, nullable: false),
|
||||
description = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: true),
|
||||
order = table.Column<int>(type: "integer", nullable: false),
|
||||
is_required = table.Column<bool>(type: "boolean", nullable: false),
|
||||
poll_id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
||||
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
||||
deleted_at = table.Column<Instant>(type: "timestamp with time zone", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("pk_poll_questions", x => x.id);
|
||||
table.ForeignKey(
|
||||
name: "fk_poll_questions_polls_poll_id",
|
||||
column: x => x.poll_id,
|
||||
principalTable: "polls",
|
||||
principalColumn: "id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_poll_answers_poll_id",
|
||||
table: "poll_answers",
|
||||
column: "poll_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_poll_questions_poll_id",
|
||||
table: "poll_questions",
|
||||
column: "poll_id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "ix_polls_publisher_id",
|
||||
table: "polls",
|
||||
column: "publisher_id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "poll_answers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "poll_questions");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "polls");
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,10 +1,12 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using DysonNetwork.Shared.Data;
|
||||
using DysonNetwork.Sphere;
|
||||
using DysonNetwork.Sphere.Chat;
|
||||
using DysonNetwork.Sphere.Developer;
|
||||
using DysonNetwork.Sphere.Poll;
|
||||
using DysonNetwork.Sphere.WebReader;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
@@ -498,6 +500,152 @@ namespace DysonNetwork.Sphere.Migrations
|
||||
b.ToTable("custom_app_secrets", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Sphere.Poll.Poll", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<Instant>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created_at");
|
||||
|
||||
b.Property<Instant?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("deleted_at");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(4096)
|
||||
.HasColumnType("character varying(4096)")
|
||||
.HasColumnName("description");
|
||||
|
||||
b.Property<Instant?>("EndedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("ended_at");
|
||||
|
||||
b.Property<Guid>("PublisherId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("publisher_id");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("character varying(1024)")
|
||||
.HasColumnName("title");
|
||||
|
||||
b.Property<Instant>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("updated_at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_polls");
|
||||
|
||||
b.HasIndex("PublisherId")
|
||||
.HasDatabaseName("ix_polls_publisher_id");
|
||||
|
||||
b.ToTable("polls", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Sphere.Poll.PollAnswer", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<Guid>("AccountId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("account_id");
|
||||
|
||||
b.Property<Dictionary<string, JsonElement>>("Answer")
|
||||
.IsRequired()
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("answer");
|
||||
|
||||
b.Property<Instant>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created_at");
|
||||
|
||||
b.Property<Instant?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("deleted_at");
|
||||
|
||||
b.Property<Guid>("PollId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("poll_id");
|
||||
|
||||
b.Property<Instant>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("updated_at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_poll_answers");
|
||||
|
||||
b.HasIndex("PollId")
|
||||
.HasDatabaseName("ix_poll_answers_poll_id");
|
||||
|
||||
b.ToTable("poll_answers", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Sphere.Poll.PollQuestion", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<Instant>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created_at");
|
||||
|
||||
b.Property<Instant?>("DeletedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("deleted_at");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.HasMaxLength(4096)
|
||||
.HasColumnType("character varying(4096)")
|
||||
.HasColumnName("description");
|
||||
|
||||
b.Property<bool>("IsRequired")
|
||||
.HasColumnType("boolean")
|
||||
.HasColumnName("is_required");
|
||||
|
||||
b.Property<List<PollOption>>("Options")
|
||||
.HasColumnType("jsonb")
|
||||
.HasColumnName("options");
|
||||
|
||||
b.Property<int>("Order")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("order");
|
||||
|
||||
b.Property<Guid>("PollId")
|
||||
.HasColumnType("uuid")
|
||||
.HasColumnName("poll_id");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("character varying(1024)")
|
||||
.HasColumnName("title");
|
||||
|
||||
b.Property<int>("Type")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("type");
|
||||
|
||||
b.Property<Instant>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("updated_at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk_poll_questions");
|
||||
|
||||
b.HasIndex("PollId")
|
||||
.HasDatabaseName("ix_poll_questions_poll_id");
|
||||
|
||||
b.ToTable("poll_questions", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Sphere.Post.Post", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@@ -1592,6 +1740,42 @@ namespace DysonNetwork.Sphere.Migrations
|
||||
b.Navigation("App");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Sphere.Poll.Poll", b =>
|
||||
{
|
||||
b.HasOne("DysonNetwork.Sphere.Publisher.Publisher", "Publisher")
|
||||
.WithMany("Polls")
|
||||
.HasForeignKey("PublisherId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_polls_publishers_publisher_id");
|
||||
|
||||
b.Navigation("Publisher");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Sphere.Poll.PollAnswer", b =>
|
||||
{
|
||||
b.HasOne("DysonNetwork.Sphere.Poll.Poll", "Poll")
|
||||
.WithMany()
|
||||
.HasForeignKey("PollId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_poll_answers_polls_poll_id");
|
||||
|
||||
b.Navigation("Poll");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Sphere.Poll.PollQuestion", b =>
|
||||
{
|
||||
b.HasOne("DysonNetwork.Sphere.Poll.Poll", "Poll")
|
||||
.WithMany("Questions")
|
||||
.HasForeignKey("PollId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired()
|
||||
.HasConstraintName("fk_poll_questions_polls_poll_id");
|
||||
|
||||
b.Navigation("Poll");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Sphere.Post.Post", b =>
|
||||
{
|
||||
b.HasOne("DysonNetwork.Sphere.Post.Post", "ForwardedPost")
|
||||
@@ -1837,6 +2021,11 @@ namespace DysonNetwork.Sphere.Migrations
|
||||
b.Navigation("Secrets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Sphere.Poll.Poll", b =>
|
||||
{
|
||||
b.Navigation("Questions");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("DysonNetwork.Sphere.Post.Post", b =>
|
||||
{
|
||||
b.Navigation("Reactions");
|
||||
@@ -1850,6 +2039,8 @@ namespace DysonNetwork.Sphere.Migrations
|
||||
|
||||
b.Navigation("Members");
|
||||
|
||||
b.Navigation("Polls");
|
||||
|
||||
b.Navigation("Posts");
|
||||
|
||||
b.Navigation("Subscriptions");
|
||||
|
Reference in New Issue
Block a user