#58 added owned entity for SocialNetworks that belongs to an ApplicationUser
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Hutopy.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddSocialNetworksToUser : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ApplicationUser_SocialNetworks",
|
||||
columns: table => new
|
||||
{
|
||||
ApplicationUserId = table.Column<string>(type: "nvarchar(450)", nullable: false),
|
||||
FacebookUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
InstagramUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
XUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
LinkedInUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
TikTokUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
YoutubeUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
RedditUrl = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
YourWebsiteUrl = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ApplicationUser_SocialNetworks", x => x.ApplicationUserId);
|
||||
table.ForeignKey(
|
||||
name: "FK_ApplicationUser_SocialNetworks_AspNetUsers_ApplicationUserId",
|
||||
column: x => x.ApplicationUserId,
|
||||
principalTable: "AspNetUsers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.Sql(@"
|
||||
INSERT INTO ApplicationUser_SocialNetworks (ApplicationUserId, FacebookUrl, InstagramUrl, XUrl, LinkedInUrl, TikTokUrl, YoutubeUrl, RedditUrl, YourWebsiteUrl)
|
||||
SELECT Id, '', '', '', '', '', '', '', ''
|
||||
FROM AspNetUsers
|
||||
");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ApplicationUser_SocialNetworks");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user