using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Api.Migrations { /// public partial class AddUserAuthentication : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), Email = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), FirstName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), LastName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), ProfilePictureUrl = table.Column(type: "nvarchar(500)", maxLength: 500, nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), LastLoginAt = table.Column(type: "datetime2", nullable: true), IsActive = table.Column(type: "bit", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "UserOAuthProviders", columns: table => new { Id = table.Column(type: "int", nullable: false) .Annotation("SqlServer:Identity", "1, 1"), UserId = table.Column(type: "int", nullable: false), Provider = table.Column(type: "int", nullable: false), ProviderId = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), ProviderEmail = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), ProviderName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true), CreatedAt = table.Column(type: "datetime2", nullable: false), LastUsedAt = table.Column(type: "datetime2", nullable: true) }, constraints: table => { table.PrimaryKey("PK_UserOAuthProviders", x => x.Id); table.ForeignKey( name: "FK_UserOAuthProviders_Users_UserId", column: x => x.UserId, principalTable: "Users", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_UserOAuthProviders_Provider_ProviderId", table: "UserOAuthProviders", columns: new[] { "Provider", "ProviderId" }, unique: true); migrationBuilder.CreateIndex( name: "IX_UserOAuthProviders_UserId", table: "UserOAuthProviders", column: "UserId"); migrationBuilder.CreateIndex( name: "IX_Users_Email", table: "Users", column: "Email", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "UserOAuthProviders"); migrationBuilder.DropTable( name: "Users"); } } }