using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable #pragma warning disable CA1814 // Prefer jagged arrays over multidimensional namespace Infrastructure.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.EnsureSchema( name: "auth"); migrationBuilder.CreateTable( name: "Roles", schema: "auth", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "character varying(50)", maxLength: 50, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Roles", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", schema: "auth", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Username = table.Column(type: "varchar(50)", maxLength: 50, nullable: false), Email = table.Column(type: "varchar(100)", maxLength: 100, nullable: false), Password = table.Column(type: "varchar(250)", maxLength: 250, nullable: false), LastLogin = table.Column(type: "timestamp with time zone", nullable: false), RefreshToken = table.Column(type: "text", nullable: true), RefreshTokenExpiryTime = table.Column(type: "timestamp with time zone", nullable: true), ResetPasswordToken = table.Column(type: "text", nullable: true), ResetPasswordTokenExpiryTime = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "UserRoles", schema: "auth", columns: table => new { UserId = table.Column(type: "integer", nullable: false), RoleId = table.Column(type: "integer", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UserRoles", x => new { x.UserId, x.RoleId }); table.ForeignKey( name: "FK_UserRoles_Roles_RoleId", column: x => x.RoleId, principalSchema: "auth", principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_UserRoles_Users_UserId", column: x => x.UserId, principalSchema: "auth", principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.InsertData( schema: "auth", table: "Roles", columns: new[] { "Id", "Name" }, values: new object[,] { { 1, "SuperAdmin" }, { 2, "Admin" }, { 3, "User" } }); migrationBuilder.InsertData( schema: "auth", table: "Users", columns: new[] { "Id", "Email", "LastLogin", "Password", "RefreshToken", "RefreshTokenExpiryTime", "ResetPasswordToken", "ResetPasswordTokenExpiryTime", "Username" }, values: new object[,] { { 1, "admin@rss.wenske-services-development.de", new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "AQAAAAIAAYagAAAAELBxAsYVTssn5taCQ7CMo+Mzn0i87Jt8ZXJTe7cgG5hfN3wDJzIkQaotyFhM/mQGaQ==", null, null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Superadmin" }, { 2, "info@rss.wenske-services-development.de", new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "AQAAAAIAAYagAAAAEP0NWiTTz20doMf/KL0WkBR+5roc5KTouMrfiHk2MMXOQn+E+C5Q4dqWD7PnNoxUmQ==", null, null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "Admin" } }); migrationBuilder.InsertData( schema: "auth", table: "UserRoles", columns: new[] { "RoleId", "UserId" }, values: new object[,] { { 1, 1 }, { 2, 2 } }); migrationBuilder.CreateIndex( name: "IX_UserRoles_RoleId", schema: "auth", table: "UserRoles", column: "RoleId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "UserRoles", schema: "auth"); migrationBuilder.DropTable( name: "Roles", schema: "auth"); migrationBuilder.DropTable( name: "Users", schema: "auth"); } } }