diff --git a/Directory.Build.props b/Directory.Build.props
index 7eb4dc6..7ab4e07 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -1,7 +1,7 @@
- 1.1.0
+ 1.1.1
Tudor Stanciu
STA
IdentityServer
diff --git a/IdentityServer.Api/IdentityServer.Api.csproj b/IdentityServer.Api/IdentityServer.Api.csproj
index cba7bb6..e76cdcf 100644
--- a/IdentityServer.Api/IdentityServer.Api.csproj
+++ b/IdentityServer.Api/IdentityServer.Api.csproj
@@ -12,6 +12,7 @@
+
diff --git a/IdentityServer.Api/Program.cs b/IdentityServer.Api/Program.cs
index 68c1918..4460c50 100644
--- a/IdentityServer.Api/Program.cs
+++ b/IdentityServer.Api/Program.cs
@@ -16,7 +16,7 @@ namespace IdentityServer.Api
{
public static void Main(string[] args)
{
- var isConsole = Debugger.IsAttached || args.Contains("--console");
+ var isConsole = args.Contains("--console");
if (!isConsole)
{
var pathToExe = Process.GetCurrentProcess().MainModule.FileName;
diff --git a/IdentityServer.Api/Startup.cs b/IdentityServer.Api/Startup.cs
index 92737ab..8c60cd4 100644
--- a/IdentityServer.Api/Startup.cs
+++ b/IdentityServer.Api/Startup.cs
@@ -1,4 +1,3 @@
-using AutoMapper;
using IdentityServer.Application;
using IdentityServer.Application.Services.Abstractions;
using IdentityServer.Domain.Data;
@@ -11,6 +10,8 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using NDB.Extensions.Swagger;
using NDB.Extensions.Swagger.Constants;
+using NDB.Infrastructure.DatabaseMigration;
+using NDB.Infrastructure.DatabaseMigration.Constants;
using Newtonsoft.Json;
using System.Reflection;
@@ -44,6 +45,7 @@ namespace IdentityServer.Api
services.AddSwagger("Identity Server API", AuthorizationType.None);
// Data access
+ services.AddMigration(DatabaseType.SQLServer);
services.AddDataAccess();
// Application
@@ -78,6 +80,8 @@ namespace IdentityServer.Api
});
app.ConfigureSwagger("IdentityServer API");
+ app.UseMigration();
+
var behaviorService = app.ApplicationServices.GetService();
behaviorService.FillTokenStore();
}
diff --git a/IdentityServer.Domain.Data/IdentityServer.Domain.Data.csproj b/IdentityServer.Domain.Data/IdentityServer.Domain.Data.csproj
index 8ebdccb..9ea6772 100644
--- a/IdentityServer.Domain.Data/IdentityServer.Domain.Data.csproj
+++ b/IdentityServer.Domain.Data/IdentityServer.Domain.Data.csproj
@@ -12,4 +12,28 @@
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+
diff --git a/IdentityServer.Domain.Data/Scripts/1.0.0/01.AppUser table.sql b/IdentityServer.Domain.Data/Scripts/1.0.0/01.AppUser table.sql
deleted file mode 100644
index 46cba40..0000000
--- a/IdentityServer.Domain.Data/Scripts/1.0.0/01.AppUser table.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-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,
- CreationDate datetime constraint DF_AppUser_CreationDate default getdate()
- )
-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.Data/Scripts/1.0.1/01.UserStatus table.sql b/IdentityServer.Domain.Data/Scripts/1.0.0/01.UserStatus table.sql
similarity index 98%
rename from IdentityServer.Domain.Data/Scripts/1.0.1/01.UserStatus table.sql
rename to IdentityServer.Domain.Data/Scripts/1.0.0/01.UserStatus table.sql
index c8d6d7b..ceb5812 100644
--- a/IdentityServer.Domain.Data/Scripts/1.0.1/01.UserStatus table.sql
+++ b/IdentityServer.Domain.Data/Scripts/1.0.0/01.UserStatus table.sql
@@ -7,7 +7,6 @@ begin
StatusName varchar(50) not null
)
end
-go
if not exists (select top 1 1 from UserStatus)
begin
@@ -15,5 +14,4 @@ begin
select 'ACTIVE', 'Active' union
select 'INACTIVE', 'Inactive' union
select 'BLOCKED', 'Blocked'
-end
-go
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/IdentityServer.Domain.Data/Scripts/1.0.0/02.AppUser table.sql b/IdentityServer.Domain.Data/Scripts/1.0.0/02.AppUser table.sql
new file mode 100644
index 0000000..d9e5926
--- /dev/null
+++ b/IdentityServer.Domain.Data/Scripts/1.0.0/02.AppUser table.sql
@@ -0,0 +1,19 @@
+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 constraint UQ_AppUser_UserName unique,
+ [Password] varchar(250) not null,
+ FirstName varchar(100),
+ LastName varchar(100),
+ Email varchar(100),
+ ProfilePictureUrl varchar(200),
+ SecurityStamp varchar(200) not null constraint UQ_AppUser_SecurityStamp unique,
+ StatusId int not null constraint FK_AppUser_UserStatus references UserStatus(StatusId),
+ CreationDate datetime not null constraint DF_AppUser_CreationDate default getdate(),
+ FailedLoginAttempts int,
+ LastLoginDate datetime,
+ PasswordChangeDate datetime
+ )
+end
\ No newline at end of file
diff --git a/IdentityServer.Domain.Data/Scripts/1.0.0/03.IDX_AppUser_Email_NOTNULL.sql b/IdentityServer.Domain.Data/Scripts/1.0.0/03.IDX_AppUser_Email_NOTNULL.sql
new file mode 100644
index 0000000..3c7c586
--- /dev/null
+++ b/IdentityServer.Domain.Data/Scripts/1.0.0/03.IDX_AppUser_Email_NOTNULL.sql
@@ -0,0 +1,6 @@
+if not exists (select top 1 1 from sys.indexes where name = 'IDX_AppUser_Email_NOTNULL' AND object_id = OBJECT_ID('AppUser'))
+begin
+ CREATE UNIQUE NONCLUSTERED INDEX IDX_AppUser_Email_NOTNULL
+ ON AppUser(Email)
+ WHERE Email IS NOT NULL
+end
\ No newline at end of file
diff --git a/IdentityServer.Domain.Data/Scripts/1.0.1/03.UserClaim table.sql b/IdentityServer.Domain.Data/Scripts/1.0.1/01.UserClaim table.sql
similarity index 98%
rename from IdentityServer.Domain.Data/Scripts/1.0.1/03.UserClaim table.sql
rename to IdentityServer.Domain.Data/Scripts/1.0.1/01.UserClaim table.sql
index a6b0f61..71964bb 100644
--- a/IdentityServer.Domain.Data/Scripts/1.0.1/03.UserClaim table.sql
+++ b/IdentityServer.Domain.Data/Scripts/1.0.1/01.UserClaim table.sql
@@ -7,5 +7,4 @@ begin
ClaimKey varchar(50) not null,
ClaimValue varchar(300) not null
)
-end
-go
\ No newline at end of file
+end
\ 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
deleted file mode 100644
index 02b5df5..0000000
--- a/IdentityServer.Domain.Data/Scripts/1.0.1/02.New structure for AppUser table.sql
+++ /dev/null
@@ -1,48 +0,0 @@
-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
-
-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 constraint UQ_AppUser_UserName unique,
- [Password] varchar(100) not null,
- FirstName varchar(100),
- LastName varchar(100),
- Email varchar(100),
- ProfilePictureUrl varchar(200),
- SecurityStamp varchar(200) not null constraint UQ_AppUser_SecurityStamp unique,
- StatusId int not null constraint FK_AppUser_UserStatus references UserStatus(StatusId),
- CreationDate datetime not null constraint DF_AppUser_CreationDate default getdate(),
- FailedLoginAttempts int,
- LastLoginDate datetime,
- PasswordChangeDate datetime
- )
-end
-go
-
-if not exists (select top 1 1 from sys.indexes where name = 'IDX_AppUser_Email_NOTNULL' AND object_id = OBJECT_ID('AppUser'))
-begin
- CREATE UNIQUE NONCLUSTERED INDEX IDX_AppUser_Email_NOTNULL
- ON AppUser(Email)
- WHERE Email IS NOT NULL
-end
-go
-
-if not exists (select top 1 1 from AppUser)
-begin
- 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
-end
-go
\ No newline at end of file
diff --git a/IdentityServer.Domain.Data/Scripts/1.0.1/04.UserToken table.sql b/IdentityServer.Domain.Data/Scripts/1.0.1/02.UserToken table.sql
similarity index 98%
rename from IdentityServer.Domain.Data/Scripts/1.0.1/04.UserToken table.sql
rename to IdentityServer.Domain.Data/Scripts/1.0.1/02.UserToken table.sql
index b417c40..22b953c 100644
--- a/IdentityServer.Domain.Data/Scripts/1.0.1/04.UserToken table.sql
+++ b/IdentityServer.Domain.Data/Scripts/1.0.1/02.UserToken table.sql
@@ -9,5 +9,4 @@ begin
ValidUntil datetime not null,
Burnt bit
)
-end
-go
\ No newline at end of file
+end
\ No newline at end of file
diff --git a/IdentityServer.Domain.Data/Scripts/1.0.1/03.Add admin user.sql b/IdentityServer.Domain.Data/Scripts/1.0.1/03.Add admin user.sql
new file mode 100644
index 0000000..5618abf
--- /dev/null
+++ b/IdentityServer.Domain.Data/Scripts/1.0.1/03.Add admin user.sql
@@ -0,0 +1,13 @@
+if not exists (select top 1 1 from AppUser where UserName = '***REMOVED***')
+begin
+ declare @activeStatusId int
+ select @activeStatusId = StatusId from UserStatus where StatusCode = 'ACTIVE'
+
+ insert into AppUser(UserName, [Password], FirstName, CreationDate, SecurityStamp, StatusId)
+ select '***REMOVED***' as UserName,
+ '***REMOVED***' as [Password],
+ ***REMOVED*** as FirstName,
+ getdate() as CreationDate,
+ cast(newid() as varchar(100)) as SecurityStamp,
+ @activeStatusId as StatusId
+end
\ No newline at end of file
diff --git a/IdentityServer.Domain.Data/Scripts/1.0.1/04.Add my user.sql b/IdentityServer.Domain.Data/Scripts/1.0.1/04.Add my user.sql
new file mode 100644
index 0000000..e46d63c
--- /dev/null
+++ b/IdentityServer.Domain.Data/Scripts/1.0.1/04.Add my user.sql
@@ -0,0 +1,16 @@
+if not exists (select top 1 1 from AppUser where UserName = '***REMOVED***')
+begin
+ declare @activeStatusId int
+ select @activeStatusId = StatusId from UserStatus where StatusCode = 'ACTIVE'
+
+ insert into AppUser(UserName, [Password], FirstName, LastName, Email, ProfilePictureUrl, CreationDate, SecurityStamp, StatusId)
+ select '***REMOVED***' as UserName,
+ '***REMOVED***' as [Password],
+ ***REMOVED*** as FirstName,
+ ***REMOVED*** as LastName,
+ '***REMOVED******REMOVED***' as Email,
+ ***REMOVED*** as ProfilePictureUrl,
+ getdate() as CreationDate,
+ cast(newid() as varchar(100)) as SecurityStamp,
+ @activeStatusId as StatusId
+end
\ No newline at end of file
diff --git a/ReleaseNotes.xml b/ReleaseNotes.xml
index cb50263..9a36a5a 100644
--- a/ReleaseNotes.xml
+++ b/ReleaseNotes.xml
@@ -30,4 +30,10 @@
◾ Upgrade packages MicrosoftExtensions, AutoMapper, EntityFramework, NDB
+
+ 1.1.1
+
+ ◾ Added NDB.Infrastructure.DatabaseMigration
+
+
\ No newline at end of file