using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace PARR.DAL.Migrations { /// public partial class TblUsersRoles : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Roles", columns: table => new { Id = table.Column(type: "uuid", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Roles", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "uuid", nullable: false), DateCreated = table.Column(type: "timestamp with time zone", nullable: false), Ip = table.Column(type: "text", nullable: false), Name = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "UsersInRoles", columns: table => new { RoleId = table.Column(type: "uuid", nullable: false), UserId = table.Column(type: "uuid", nullable: false) }, constraints: table => { table.PrimaryKey("PK_UsersInRoles", x => new { x.RoleId, x.UserId }); table.ForeignKey( name: "FK_UsersInRoles_Roles_RoleId", column: x => x.RoleId, principalTable: "Roles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "FK_UsersInRoles_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Users_Ip", table: "Users", column: "Ip", unique: true); migrationBuilder.CreateIndex( name: "IX_UsersInRoles_UserId", table: "UsersInRoles", column: "UserId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "UsersInRoles"); migrationBuilder.DropTable( name: "Roles"); migrationBuilder.DropTable( name: "Users"); } } }