Skip to content
Snippets Groups Projects
Commit 780e4285 authored by Adiv's avatar Adiv
Browse files

Added migration

parent 00f09908
No related branches found
No related tags found
No related merge requests found
// <auto-generated />
using System;
using AuthenticationMicroservice.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace AuthenticationMicroservice.Migrations
{
[DbContext(typeof(AuthenticationDbContext))]
[Migration("20230325232645_InitialMigration")]
partial class InitialMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0-preview.2.23128.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("AuthenticationMicroservice.Models.Entities.RefreshToken", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier")
.HasDefaultValueSql("newid()");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<bool>("Deleted")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("DeletedAt")
.HasColumnType("datetimeoffset");
b.Property<long>("Expires")
.HasColumnType("bigint");
b.Property<string>("IpAddress")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsValid")
.HasColumnType("bit");
b.Property<string>("Reason")
.HasColumnType("nvarchar(max)");
b.Property<string>("Token")
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset?>("UpdatedAt")
.HasColumnType("datetimeoffset");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("CreatedAt", "Deleted");
b.ToTable("RefreshToken");
});
modelBuilder.Entity("AuthenticationMicroservice.Models.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<DateTimeOffset?>("DeletedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("EmailAddress")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<Guid?>("EmailConfirmationToken")
.HasColumnType("uniqueidentifier");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset?>("LastLogin")
.HasColumnType("datetimeoffset");
b.Property<DateTimeOffset?>("LastRefreshTokenIssued")
.HasColumnType("datetimeoffset");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("PasswordResetToken")
.HasColumnType("uniqueidentifier");
b.Property<string>("ProfilePictureUrl")
.HasColumnType("nvarchar(max)");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UnconfirmedEmail")
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset?>("UpdatedAt")
.HasColumnType("datetimeoffset");
b.HasKey("Id");
b.HasIndex("EmailAddress")
.IsUnique();
b.ToTable("User");
});
modelBuilder.Entity("AuthenticationMicroservice.Models.Entities.RefreshToken", b =>
{
b.HasOne("AuthenticationMicroservice.Models.Entities.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
#pragma warning restore 612, 618
}
}
}
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AuthenticationMicroservice.Migrations
{
/// <inheritdoc />
public partial class InitialMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "User",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Surname = table.Column<string>(type: "nvarchar(max)", nullable: false),
EmailAddress = table.Column<string>(type: "nvarchar(450)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
LastLogin = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
LastRefreshTokenIssued = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
ProfilePictureUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
UnconfirmedEmail = table.Column<string>(type: "nvarchar(max)", nullable: true),
PasswordResetToken = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
EmailConfirmationToken = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
DeletedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
UpdatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_User", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RefreshToken",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false, defaultValueSql: "newid()"),
Token = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsValid = table.Column<bool>(type: "bit", nullable: false),
Expires = table.Column<long>(type: "bigint", nullable: false),
IpAddress = table.Column<string>(type: "nvarchar(max)", nullable: true),
Deleted = table.Column<bool>(type: "bit", nullable: false),
Reason = table.Column<string>(type: "nvarchar(max)", nullable: true),
UserId = table.Column<int>(type: "int", nullable: false),
CreatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: false),
DeletedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true),
UpdatedAt = table.Column<DateTimeOffset>(type: "datetimeoffset", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_RefreshToken", x => x.Id);
table.ForeignKey(
name: "FK_RefreshToken_User_UserId",
column: x => x.UserId,
principalTable: "User",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_RefreshToken_CreatedAt_Deleted",
table: "RefreshToken",
columns: new[] { "CreatedAt", "Deleted" });
migrationBuilder.CreateIndex(
name: "IX_RefreshToken_UserId",
table: "RefreshToken",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_User_EmailAddress",
table: "User",
column: "EmailAddress",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RefreshToken");
migrationBuilder.DropTable(
name: "User");
}
}
}
// <auto-generated />
using System;
using AuthenticationMicroservice.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace AuthenticationMicroservice.Migrations
{
[DbContext(typeof(AuthenticationDbContext))]
partial class AuthenticationDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.0-preview.2.23128.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("AuthenticationMicroservice.Models.Entities.RefreshToken", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier")
.HasDefaultValueSql("newid()");
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<bool>("Deleted")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("DeletedAt")
.HasColumnType("datetimeoffset");
b.Property<long>("Expires")
.HasColumnType("bigint");
b.Property<string>("IpAddress")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsValid")
.HasColumnType("bit");
b.Property<string>("Reason")
.HasColumnType("nvarchar(max)");
b.Property<string>("Token")
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset?>("UpdatedAt")
.HasColumnType("datetimeoffset");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("CreatedAt", "Deleted");
b.ToTable("RefreshToken");
});
modelBuilder.Entity("AuthenticationMicroservice.Models.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTimeOffset>("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property<DateTimeOffset?>("DeletedAt")
.HasColumnType("datetimeoffset");
b.Property<string>("EmailAddress")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<Guid?>("EmailConfirmationToken")
.HasColumnType("uniqueidentifier");
b.Property<string>("FirstName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset?>("LastLogin")
.HasColumnType("datetimeoffset");
b.Property<DateTimeOffset?>("LastRefreshTokenIssued")
.HasColumnType("datetimeoffset");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<Guid?>("PasswordResetToken")
.HasColumnType("uniqueidentifier");
b.Property<string>("ProfilePictureUrl")
.HasColumnType("nvarchar(max)");
b.Property<string>("Surname")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UnconfirmedEmail")
.HasColumnType("nvarchar(max)");
b.Property<DateTimeOffset?>("UpdatedAt")
.HasColumnType("datetimeoffset");
b.HasKey("Id");
b.HasIndex("EmailAddress")
.IsUnique();
b.ToTable("User");
});
modelBuilder.Entity("AuthenticationMicroservice.Models.Entities.RefreshToken", b =>
{
b.HasOne("AuthenticationMicroservice.Models.Entities.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
#pragma warning restore 612, 618
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment