From 4f0db24b5b7f5d9ca25e8e245d6e7bb4619c16b8 Mon Sep 17 00:00:00 2001 From: Tudor Stanciu Date: Wed, 10 Nov 2021 15:14:58 +0200 Subject: [PATCH] New structure for AppUser table --- .../Scripts/{ => 1.0.0}/01.AppUser table.sql | 0 .../Scripts/1.0.1/01.UserStatus table.sql | 19 +++++++++++++ .../02.New structure for AppUser table.sql | 27 +++++++++++++++++++ IdentityServer.Domain/Entities/AppUser.cs | 2 ++ 4 files changed, 48 insertions(+) rename IdentityServer.Domain.Data/Scripts/{ => 1.0.0}/01.AppUser table.sql (100%) create mode 100644 IdentityServer.Domain.Data/Scripts/1.0.1/01.UserStatus table.sql create mode 100644 IdentityServer.Domain.Data/Scripts/1.0.1/02.New structure for AppUser table.sql diff --git a/IdentityServer.Domain.Data/Scripts/01.AppUser table.sql b/IdentityServer.Domain.Data/Scripts/1.0.0/01.AppUser table.sql similarity index 100% rename from IdentityServer.Domain.Data/Scripts/01.AppUser table.sql rename to IdentityServer.Domain.Data/Scripts/1.0.0/01.AppUser table.sql diff --git a/IdentityServer.Domain.Data/Scripts/1.0.1/01.UserStatus table.sql b/IdentityServer.Domain.Data/Scripts/1.0.1/01.UserStatus table.sql new file mode 100644 index 0000000..6abaab4 --- /dev/null +++ b/IdentityServer.Domain.Data/Scripts/1.0.1/01.UserStatus table.sql @@ -0,0 +1,19 @@ +if not exists (select top 1 1 from sys.objects where name = 'UserStatus' and type = 'U') +begin + create table UserStatus + ( + StatusId int identity(0, 1) constraint PK_UserStatus primary key, + StatusCode varchar(30) not null, + StatusName varchar(50) not null + ) +end +go + +if not exists (select top 1 1 from UserStatus) +begin + insert into UserStatus(StatusCode, StatusName) + select 'ACTIVE', 'Active' union + select 'INACTIVE', 'Inactive' union + select 'BLOCKED', 'Blocked' +end +go \ No newline at end of file diff --git a/IdentityServer.Domain.Data/Scripts/1.0.1/02.New structure for AppUser table.sql b/IdentityServer.Domain.Data/Scripts/1.0.1/02.New structure for AppUser table.sql new file mode 100644 index 0000000..289a436 --- /dev/null +++ b/IdentityServer.Domain.Data/Scripts/1.0.1/02.New structure for AppUser table.sql @@ -0,0 +1,27 @@ +if not exists (select top 1 1 from sys.objects where name = 'AppUser' and type = 'U') +begin + create table AppUser + ( + UserId int identity(0, 1) constraint PK_AppUser primary key, + UserName varchar(100) not null, + [Password] varchar(100) not null, + FirstName varchar(100), + LastName varchar(100), + Email varchar(100), + ProfilePictureUrl varchar(200), + SecurityStamp varchar(200), + StatusId int constraint FK_AppUser_UserStatus references UserStatus(StatusId), + CreationDate datetime constraint DF_AppUser_CreationDate default getdate(), + FailedLoginAttempts int, + LastLoginDate datetime, + PasswordChangeDate datetime + ) +end +go + +if not exists (select top 1 1 from AppUser) +begin + insert into AppUser(UserName, [Password]) + select '***REMOVED***', '***REMOVED***' +end +go \ No newline at end of file diff --git a/IdentityServer.Domain/Entities/AppUser.cs b/IdentityServer.Domain/Entities/AppUser.cs index b9ed4e4..50999f8 100644 --- a/IdentityServer.Domain/Entities/AppUser.cs +++ b/IdentityServer.Domain/Entities/AppUser.cs @@ -7,6 +7,8 @@ namespace IdentityServer.Domain.Entities public int UserId { get; set; } public string UserName { get; set; } public string Password { get; set; } + public string Email { get; set; } + public string ProfilePictureUrl { get; set; } public DateTime CreationDate { get; set; } } }