tuitio/IdentityServer.Domain.Data/Scripts/1.0.1/02.New structure for AppUse...

40 lines
1.3 KiB
MySQL
Raw Normal View History

2021-11-11 01:20:02 +02:00
if exists (select top 1 1 from sys.objects where name = 'AppUser' and type = 'U')
and not exists(select top 1 1 from sys.columns where name = 'SecurityStamp' and object_id = object_id('AppUser'))
begin
select * into #TmpAppUser from AppUser
drop table AppUser
end
2020-12-20 00:18:53 +02:00
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,
2021-11-10 15:14:58 +02:00
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
2020-12-20 00:18:53 +02:00
)
end
go
if not exists (select top 1 1 from AppUser)
begin
2021-11-11 01:20:02 +02:00
declare @activeStatusId int
select @activeStatusId = StatusId from UserStatus where StatusCode = 'ACTIVE'
insert into AppUser(UserName, [Password], CreationDate, SecurityStamp, StatusId)
select UserName, [Password], CreationDate, cast(newid() as varchar(100)), @activeStatusId as StatusId
from #TmpAppUser
drop table #TmpAppUser
2020-12-20 00:18:53 +02:00
end
go