MyBookmark/Modules.User.Database/Migrations/20241101174734_Init.cs
THE_KONDRAT 7b16d72329 ui and login
mongo => postgres
2024-11-03 16:08:39 +03:00

104 lines
4.7 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Modules.User.Database.Migrations
{
/// <inheritdoc />
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
NickName = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
FirstName = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
Patronymic = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
LastName = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
AvatarId = table.Column<Guid>(type: "uuid", nullable: true),
RegionalSettings_LanguageId = table.Column<Guid>(type: "uuid", nullable: true),
Deleted = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Accounts",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
UserId = table.Column<Guid>(type: "uuid", nullable: false),
Email = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: false),
HashedPassword = table.Column<string>(type: "text", nullable: false),
CreationDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
Deleted = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Accounts", x => x.Id);
table.ForeignKey(
name: "FK_Accounts_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Sessions",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
RefreshToken = table.Column<string>(type: "character varying(172)", maxLength: 172, nullable: false),
ClientInfo_UserAgent = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
ClientInfo_Country = table.Column<string>(type: "character varying(96)", maxLength: 96, nullable: true),
ClientInfo_Region = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
ExpiredDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "'0001-01-01 00:00:00+00'"),
LastUpdate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
AccountId = table.Column<Guid>(type: "uuid", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Sessions", x => x.Id);
table.ForeignKey(
name: "FK_Sessions_Accounts_AccountId",
column: x => x.AccountId,
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Accounts_UserId",
table: "Accounts",
column: "UserId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Sessions_AccountId",
table: "Sessions",
column: "AccountId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Sessions");
migrationBuilder.DropTable(
name: "Accounts");
migrationBuilder.DropTable(
name: "Users");
}
}
}