Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
254 changes: 254 additions & 0 deletions Migrations/20251126210845_AddPosts.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions Migrations/20251126210845_AddPosts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace sparkly_server.Services.Users.Migrations
{
/// <inheritdoc />
public partial class AddPosts : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "posts",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
AuthorId = table.Column<Guid>(type: "uuid", nullable: false),
ProjectId = table.Column<Guid>(type: "uuid", nullable: true),
Title = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
Content = table.Column<string>(type: "character varying(4000)", maxLength: 4000, nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_posts", x => x.Id);
table.ForeignKey(
name: "FK_posts_projects_ProjectId",
column: x => x.ProjectId,
principalTable: "projects",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_posts_users_AuthorId",
column: x => x.AuthorId,
principalTable: "users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "IX_posts_AuthorId",
table: "posts",
column: "AuthorId");

migrationBuilder.CreateIndex(
name: "IX_posts_ProjectId",
table: "posts",
column: "ProjectId");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "posts");
}
}
}
62 changes: 62 additions & 0 deletions Migrations/AppDbContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,43 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("refresh_tokens", (string)null);
});

modelBuilder.Entity("sparkly_server.Domain.Posts.Post", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");

b.Property<Guid>("AuthorId")
.HasColumnType("uuid");

b.Property<string>("Content")
.IsRequired()
.HasMaxLength(4000)
.HasColumnType("character varying(4000)");

b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");

b.Property<Guid?>("ProjectId")
.HasColumnType("uuid");

b.Property<string>("Title")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");

b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");

b.HasKey("Id");

b.HasIndex("AuthorId");

b.HasIndex("ProjectId");

b.ToTable("posts", (string)null);
});

modelBuilder.Entity("sparkly_server.Domain.Projects.Project", b =>
{
b.Property<Guid>("Id")
Expand Down Expand Up @@ -179,8 +216,33 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Navigation("User");
});

modelBuilder.Entity("sparkly_server.Domain.Posts.Post", b =>
{
b.HasOne("sparkly_server.Domain.Users.User", "Author")
.WithMany("Posts")
.HasForeignKey("AuthorId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.HasOne("sparkly_server.Domain.Projects.Project", "Project")
.WithMany("Posts")
.HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Cascade);

b.Navigation("Author");

b.Navigation("Project");
});

modelBuilder.Entity("sparkly_server.Domain.Projects.Project", b =>
{
b.Navigation("Posts");
});

modelBuilder.Entity("sparkly_server.Domain.Users.User", b =>
{
b.Navigation("Posts");

b.Navigation("RefreshTokens");
});
#pragma warning restore 612, 618
Expand Down
Loading