Skip to content

Commit

Permalink
Merge pull request #33 from goodtocode/31-subjects-business-crud-func…
Browse files Browse the repository at this point in the history
…tions

31 subjects business crud functions
  • Loading branch information
goodtocode authored Jun 26, 2023
2 parents 728154f + e32d8c5 commit 07553fa
Show file tree
Hide file tree
Showing 561 changed files with 9,221 additions and 435 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/gtc-rg-subjects-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,15 @@ jobs:
RUNTIME_ENV: 'Development'
SRC_PATH: './src/Subjects'
SRC_SLN: 'Goodtocode.Subjects.sln'
API_PATH: 'Presentation/Api.WebApi'
API_PROJECT: 'Api.WebApi.csproj'
API_PATH: 'Presentation.Api.WebApi'
API_PROJECT: 'Presentation.Api.WebApi.csproj'
APPI_NAME: 'appi-subjects-dev-001'
INFRA_PATH: 'Infrastructure/Persistence'
INFRA_PROJECT: 'Persistence.csproj'
UNIT_PATH: 'Specs/Application.Unit'
UNIT_PROJECT: 'Application.Unit.csproj'
INFRA_PATH: 'Infrastructure.Persistence'
INFRA_PROJECT: 'Infrastructure.Persistence.csproj'
INTEGRATION_PATH: 'Specs.Integration'
INTEGRATION_PROJECT: 'Specs.Integration.csproj'
UNIT_PATH: 'Specs.Unit'
UNIT_PROJECT: 'Specs.Unit.csproj'
SCRIPTS_PATH: './.github/scripts'
SQL_NAME: 'sql-entities-dev-001'
SQLDB_NAME: 'sqldb-entities-dev-001'
Expand All @@ -76,6 +78,7 @@ jobs:
run: |
dotnet build ${{ env.SRC_PATH }}/${{ env.SRC_SLN }} --configuration Release
dotnet test ${{ env.SRC_PATH }}/${{ env.UNIT_PATH }}/${{ env.UNIT_PROJECT }} --verbosity normal
dotnet test ${{ env.SRC_PATH }}/${{ env.INTEGRATION_PATH }}/${{ env.INTEGRATION_PROJECT }} --verbosity normal
dotnet publish ${{ env.SRC_PATH }}/${{ env.API_PATH }}/${{ env.API_PROJECT }} --configuration Release -o ${{ env.AZURE_WEBAPP_NAME }}
shell: pwsh

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE PROCEDURE [Activity].[ExceptionLogInsertByException]
AS
-- Build data into message
Declare @CustomMessage nvarchar(max)
Select @CustomMessage = 'Number: ' + Cast(ERROR_NUMBER() As nvarchar(100))
+ ' Severity: ' + Cast(ERROR_SEVERITY() As nvarchar(100))
+ ' State: ' + Cast(ERROR_STATE() As nvarchar(100))
+ ' Procedure: ' + Cast(ERROR_PROCEDURE() As nvarchar(500))
+ ' Line: ' + Cast(ERROR_LINE() As nvarchar(100))
INSERT INTO [Activity].[ExceptionLog] ([Message], [CustomMessage])
SELECT ERROR_MESSAGE() AS [Message], IsNull(@CustomMessage, '') As [CustomMessage]
21 changes: 21 additions & 0 deletions data/Entity.Database/Activity/Tables/ExceptionLog.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE [Activity].[ExceptionLog] (
[ExceptionLogId] INT IDENTITY (1, 1) NOT NULL,
[ExceptionLogKey] UniqueIdentifier CONSTRAINT [DF_ExceptionLog_ExceptionLogKey] DEFAULT (NewID()) NOT NULL,
[AssemblyName] NVARCHAR (MAX) CONSTRAINT [DF_ExceptionLog_AssemblyName] DEFAULT ('') NOT NULL,
[Message] NVARCHAR (MAX) CONSTRAINT [DF_ExceptionLog_Message] DEFAULT ('') NOT NULL,
[InnerException] NVARCHAR (MAX) CONSTRAINT [DF_ExceptionLog_InnerException] DEFAULT ('') NOT NULL,
[StackTrace] NVARCHAR (MAX) CONSTRAINT [DF_ExceptionLog_StackTrace] DEFAULT ('') NOT NULL,
[ADDomainName] NVARCHAR (MAX) CONSTRAINT [DF_ExceptionLog_ExceptionADDomainName] DEFAULT ('') NOT NULL,
[ADUserName] NVARCHAR (MAX) CONSTRAINT [DF_ExceptionLog_ExceptionADUserName] DEFAULT ('') NOT NULL,
[DirectoryWorking] NVARCHAR (MAX) CONSTRAINT [DF_ExceptionLog_ExceptionDirectoryWorking] DEFAULT ('') NOT NULL,
[DirectoryAssembly] NVARCHAR (MAX) CONSTRAINT [DF_ExceptionLog_ExceptionDirectoryAssembly] DEFAULT ('') NOT NULL,
[URL] NVARCHAR (MAX) CONSTRAINT [DF_ExceptionLog_URL] DEFAULT ('') NOT NULL,
[CustomMessage] NVARCHAR (MAX) CONSTRAINT [DF_ExceptionLog_CustomMessage] DEFAULT ('') NOT NULL,
[Discriminator] NVARCHAR (128) CONSTRAINT [DF_ExceptionLog_Discriminator] DEFAULT ('') NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_ExceptionLog_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_Exception] PRIMARY KEY CLUSTERED ([ExceptionLogId] ASC)
);
GO
CREATE NonCLUSTERED INDEX [IX_ExceptionLog_ExceptionLogKey] ON [Activity].[ExceptionLog] ([ExceptionLogKey] Asc)
GO

15 changes: 15 additions & 0 deletions data/Entity.Database/App_Data/PostBuild.Debug.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ECHO OFF
ECHO Starting PostBuild.bat %1 %2 %3
REM Usage: Call "$(MSBuildProjectDirectory)\App_Data\PostBuild.$(ConfigurationName).bat" "$(MSBuildProjectDirectory)\$(OutDir)" "$(ConfigurationName)" "$(ProjectName)"
REM Vars: $(ProjectName) = MyCo.Framework. Models, $(TargetPath) = output file, $(TargetDir) = full bin path , $(OutDir) = bin\debug, $(ConfigurationName) = "Debug"

REM Locals
SET FullPath=%1
SET FullPath=%FullPath:"=%
ECHO FullPath: %FullPath%
SET Configuration=%2
ECHO Configuration: %Configuration%
SET ProjectName=%3
ECHO ProjectName: %ProjectName%

Exit 0
15 changes: 15 additions & 0 deletions data/Entity.Database/App_Data/PostBuild.Release.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ECHO OFF
ECHO Starting PostBuild.bat %1 %2 %3
REM Usage: Call "$(MSBuildProjectDirectory)\App_Data\PostBuild.$(ConfigurationName).bat" "$(MSBuildProjectDirectory)\$(OutDir)" "$(ConfigurationName)" "$(ProjectName)"
REM Vars: $(ProjectName) = MyCo.Framework. Models, $(TargetPath) = output file, $(TargetDir) = full bin path , $(OutDir) = bin\debug, $(ConfigurationName) = "Debug"

REM Locals
SET FullPath=%1
SET FullPath=%FullPath:"=%
ECHO FullPath: %FullPath%
SET Configuration=%2
ECHO Configuration: %Configuration%
SET ProjectName=%3
ECHO ProjectName: %ProjectName%

Exit 0
15 changes: 15 additions & 0 deletions data/Entity.Database/App_Data/PreBuild.Debug.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ECHO OFF
ECHO Starting PreBuild.bat %1 %2 %3
REM Usage: Call "$(MSBuildProjectDirectory)\App_Data\PreBuild.$(ConfigurationName).bat" "$(MSBuildProjectDirectory)" "$(ConfigurationName)" "$(ProjectName)"
REM Vars: $(ProjectName) = MyCo.Framework. Models, $(TargetPath) = output file, $(TargetDir) = full bin path , $(OutDir) = bin\debug, $(ConfigurationName) = "Debug"

REM Locals
SET FullPath=%1
SET FullPath=%FullPath:"=%
ECHO FullPath: %FullPath%
SET Configuration=%2
ECHO Configuration: %Configuration%
SET ProjectName=%3
ECHO ProjectName: %ProjectName%

exit 0
15 changes: 15 additions & 0 deletions data/Entity.Database/App_Data/PreBuild.Release.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ECHO OFF
ECHO Starting PreBuild.bat %1 %2 %3
REM Usage: Call "$(MSBuildProjectDirectory)\App_Data\PreBuild.$(ConfigurationName).bat" "$(MSBuildProjectDirectory)" "$(ConfigurationName)" "$(ProjectName)"
REM Vars: $(ProjectName) = MyCo.Framework. Models, $(TargetPath) = output file, $(TargetDir) = full bin path , $(OutDir) = bin\debug, $(ConfigurationName) = "Debug"

REM Locals
SET FullPath=%1
SET FullPath=%FullPath:"=%
ECHO FullPath: %FullPath%
SET Configuration=%2
ECHO Configuration: %Configuration%
SET ProjectName=%3
ECHO ProjectName: %ProjectName%

exit 0
19 changes: 19 additions & 0 deletions data/Entity.Database/Entity/Tables/Application.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CREATE TABLE [Entity].[Application] (
[ApplicationId] INT IDENTITY (1, 1) CONSTRAINT [DF_Application_ApplicationId] NOT NULL,
[ApplicationKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Application_ApplicationKey] DEFAULT (NewID()) NOT NULL,
[ApplicationName] NVARCHAR (50) CONSTRAINT [DF_Application_ApplicationName] DEFAULT ('') NOT NULL,
[ApplicationSlogan] NVARCHAR (50) CONSTRAINT [DF_Application_ApplicationSlogan] DEFAULT ('') NOT NULL,
[SharedApplicationKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Application_SharedApplicationKey] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[SharedSecret] INT CONSTRAINT [DF_Application_SharedSecret] DEFAULT(-1) NOT NULL,
[BusinessEntityKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Application_BusinessEntity] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[PrivacyUrl] NVARCHAR (250) CONSTRAINT [DF_Application_PrivacyUrl] DEFAULT ('') NOT NULL,
[TermsUrl] NVARCHAR (250) CONSTRAINT [DF_Application_TermsUrl] DEFAULT ('') NOT NULL,
[TermsRevisedDate] DATETIME CONSTRAINT [DF_Application_TermsRevisedDate] DEFAULT (getutcdate()) NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_Application_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
[ModifiedDate] DATETIME CONSTRAINT [DF_Application_ModifiedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_Application] PRIMARY KEY CLUSTERED ([ApplicationId] ASC),
CONSTRAINT [FK_Application_BusinessEntity] FOREIGN KEY ([BusinessEntityKey]) REFERENCES [Entity].[Entity] ([EntityKey])
);
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_Application_Key] ON [Entity].[Application] ([ApplicationKey] Asc)
Go
22 changes: 22 additions & 0 deletions data/Entity.Database/Entity/Tables/Appointment.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TABLE [Entity].[Appointment] (
[AppointmentId] INT IDENTITY (1, 1) CONSTRAINT [DF_Appointment_AppointmentId] NOT NULL,
[AppointmentKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Appointment_AppointmentKey] DEFAULT (NewID()) NOT NULL,
[AppointmentName] NVARCHAR (50) CONSTRAINT [DF_Appointment_AppointmentName] DEFAULT ('') NOT NULL,
[AppointmentDescription] NVARCHAR (2000) CONSTRAINT [DF_Appointment_AppointmentDescription] DEFAULT ('') NOT NULL,
[SlotLocationKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Appointment_SlotLocation] DEFAULT('00000000-0000-0000-0000-000000000000') NULL,
[SlotResourceKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Appointment_SlotResource] DEFAULT('00000000-0000-0000-0000-000000000000') NULL,
[TimeRangeKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Appointment_TimeRangeId] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[RecordStateKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Appointment_RecordState] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_Appointment_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
[ModifiedDate] DATETIME CONSTRAINT [DF_Appointment_ModifiedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_Appointment] PRIMARY KEY CLUSTERED ([AppointmentId] ASC),
CONSTRAINT [FK_Appointment_Location] FOREIGN KEY ([SlotLocationKey]) REFERENCES [Entity].[SlotLocation] ([SlotLocationKey]),
CONSTRAINT [FK_Appointment_Resource] FOREIGN KEY ([SlotResourceKey]) REFERENCES [Entity].[SlotResource] ([SlotResourceKey]),
CONSTRAINT [FK_Appointment_TimeRange] FOREIGN KEY ([TimeRangeKey]) REFERENCES [Entity].[TimeRange] ([TimeRangeKey]),
CONSTRAINT [FK_Appointment_RecordState] FOREIGN KEY ([RecordStateKey]) REFERENCES [Entity].[RecordState] ([RecordStateKey])
);
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_Appointment_Key] ON [Entity].[Appointment] ([AppointmentKey] Asc)
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_LocationTime_All] ON [Entity].[Appointment] ([SlotLocationKey] Asc, [SlotResourceKey] Asc, [TimeRangeKey] Asc)
GO
10 changes: 10 additions & 0 deletions data/Entity.Database/Entity/Tables/Area.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE [Entity].[Area] (
[AreaId] INT IDENTITY (1, 1) CONSTRAINT [DF_Area_Id] NOT NULL,
[AreaKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Area_Key] NOT NULL DEFAULT(NewId()),
[Area] Geometry NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_Area_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_Area] PRIMARY KEY CLUSTERED ([AreaId] ASC)
);
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_Area_Key] ON [Entity].[Area] ([AreaKey] Asc)
GO
15 changes: 15 additions & 0 deletions data/Entity.Database/Entity/Tables/Business.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CREATE TABLE [Entity].[Business] (
[BusinessId] INT IDENTITY (1, 1) CONSTRAINT [DF_Business_Business] NOT NULL,
[BusinessKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Business_Entity] DEFAULT(NewId()) NOT NULL,
[BusinessName] NVARCHAR (50) CONSTRAINT [DF_Business_BusinessName] DEFAULT ('') NOT NULL,
[TaxNumber] NVARCHAR (20) CONSTRAINT [DF_Business_TaxNumber] DEFAULT ('') NOT NULL,
[RecordStateKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Business_RecordState] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_Business_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
[ModifiedDate] DATETIME CONSTRAINT [DF_Business_ModifiedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_Business] PRIMARY KEY CLUSTERED ([BusinessId] ASC),
CONSTRAINT [FK_Business_Entity] FOREIGN KEY ([BusinessKey]) REFERENCES [Entity].[Entity] ([EntityKey]),
CONSTRAINT [FK_Business_RecordState] FOREIGN KEY ([RecordStateKey]) REFERENCES [Entity].[RecordState] ([RecordStateKey])
);
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_BusinessEntity_Entity] ON [Entity].[Business] ([BusinessKey] Asc)
GO
13 changes: 13 additions & 0 deletions data/Entity.Database/Entity/Tables/Detail.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
CREATE TABLE [Entity].[Detail] (
[DetailId] INT IDENTITY (1, 1) CONSTRAINT [DF_Detail_Id] NOT NULL,
[DetailKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Detail_Key] DEFAULT (NewID()) NOT NULL,
[DetailTypeKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Detail_DetailType] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[DetailData] NVARCHAR (2000) CONSTRAINT [DF_Detail_DetailData] DEFAULT ('') NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_Detail_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
[ModifiedDate] DATETIME CONSTRAINT [DF_Detail_ModifiedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_Detail] PRIMARY KEY CLUSTERED ([DetailId] ASC),
CONSTRAINT [FK_Detail_DetailType] FOREIGN KEY ([DetailTypeKey]) REFERENCES [Entity].[DetailType] ([DetailTypeKey])
);
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_Detail_Key] ON [Entity].[Detail] ([DetailKey] Asc)
GO
12 changes: 12 additions & 0 deletions data/Entity.Database/Entity/Tables/DetailType.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CREATE TABLE [Entity].[DetailType] (
[DetailTypeId] INT IDENTITY (1, 1) CONSTRAINT [DF_DetailType_DetailTypeId] NOT NULL,
[DetailTypeKey] UNIQUEIDENTIFIER CONSTRAINT [DF_DetailType_DetailTypeKey] DEFAULT (NewId()) NOT NULL,
[DetailTypeName] NVARCHAR (50) CONSTRAINT [DF_DetailType_DetailTypeName] DEFAULT ('') NOT NULL,
[DetailTypeDescription] NVARCHAR (250) CONSTRAINT [DF_DetailType_DetailTypeDescription] DEFAULT ('') NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_DetailType_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
[ModifiedDate] DATETIME CONSTRAINT [DF_DetailType_ModifiedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_DetailType] PRIMARY KEY CLUSTERED ([DetailTypeId] ASC)
);
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_DetailType_Key] ON [Entity].[DetailType] ([DetailTypeKey] Asc)
GO
10 changes: 10 additions & 0 deletions data/Entity.Database/Entity/Tables/Entity.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE TABLE [Entity].[Entity] (
[EntityId] INT IDENTITY (1, 1) CONSTRAINT [DF_Entity_EntityId] NOT NULL,
[EntityKey] UNIQUEIDENTIFIER CONSTRAINT [DF_Entity_EntityKey] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_Entity_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
[ModifiedDate] DATETIME CONSTRAINT [DF_Entity_ModifiedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_Entity] PRIMARY KEY CLUSTERED ([EntityId] ASC)
);
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_Entity_EntityKey] ON [Entity].[Entity] ([EntityKey] Asc)
GO
18 changes: 18 additions & 0 deletions data/Entity.Database/Entity/Tables/EntityAppointment.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CREATE TABLE [Entity].[EntityAppointment] (
[EntityAppointmentId] INT IDENTITY (1, 1) CONSTRAINT [DF_EntityAppointment_Id] NOT NULL,
[EntityAppointmentKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityAppointment_Key] DEFAULT(NewId()) NOT NULL,
[EntityKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityAppointment_EntityId] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[AppointmentKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityAppointment_AppointmentId] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[RecordStateKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityAppointment_RecordState] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_EntityAppointment_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
[ModifiedDate] DATETIME CONSTRAINT [DF_EntityAppointment_ModifiedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_EntityAppointment] PRIMARY KEY CLUSTERED ([EntityAppointmentId] ASC),
CONSTRAINT [FK_EntityAppointment_Entity] FOREIGN KEY ([EntityKey]) REFERENCES [Entity].[Entity] ([EntityKey]),
CONSTRAINT [FK_EntityAppointment_Appointment] FOREIGN KEY ([AppointmentKey]) REFERENCES [Entity].[Appointment] ([AppointmentKey]),
CONSTRAINT [FK_EntityAppointment_RecordState] FOREIGN KEY ([RecordStateKey]) REFERENCES [Entity].[RecordState] ([RecordStateKey])
);
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_EntityAppointment_Key] ON [Entity].[EntityAppointment] ([EntityAppointmentKey] Asc)
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_EntityAppointment_All] ON [Entity].[EntityAppointment] ([EntityKey] Asc, [AppointmentKey] Asc)
GO
16 changes: 16 additions & 0 deletions data/Entity.Database/Entity/Tables/EntityDetail.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
CREATE TABLE [Entity].[EntityDetail] (
[EntityDetailId] INT IDENTITY (1, 1) CONSTRAINT [DF_EntityDetail_Id] NOT NULL,
[EntityDetailKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityDetail_Key] DEFAULT (NewID()) NOT NULL,
[EntityKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityDetail_Entity] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[DetailKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityDetail_Detail] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_EntityDetail_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
[ModifiedDate] DATETIME CONSTRAINT [DF_EntityDetail_ModifiedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_EntityDetail] PRIMARY KEY CLUSTERED ([EntityDetailId] ASC),
CONSTRAINT [FK_EntityDetail_Entity] FOREIGN KEY ([EntityKey]) REFERENCES [Entity].[Entity] ([EntityKey]),
CONSTRAINT [FK_EntityDetail_Detail] FOREIGN KEY ([DetailKey]) REFERENCES [Entity].[Detail] ([DetailKey]),
CONSTRAINT [UQ_EntityDetail_EntityDetailId] UNIQUE NONCLUSTERED ([EntityKey] ASC, [EntityDetailKey] ASC)
);
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_EntityDetail_Key] ON [Entity].[EntityDetail] ([EntityDetailKey] Asc)
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_EntityDetail_All] ON [Entity].[EntityDetail] ([EntityKey] Asc, [EntityDetailKey] Asc)
20 changes: 20 additions & 0 deletions data/Entity.Database/Entity/Tables/EntityLocation.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
CREATE TABLE [Entity].[EntityLocation] (
[EntityLocationId] INT IDENTITY (1, 1) CONSTRAINT [DF_EntityLocation_Entity] NOT NULL,
[EntityLocationKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityLocation_Entity] DEFAULT(NewId()) NOT NULL,
[EntityKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityLocation_EntityKey] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[LocationKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityLocation_LocationKey] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[LocationTypeKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityLocation_LocationType] DEFAULT('00000000-0000-0000-0000-000000000000') NULL,
[RecordStateKey] UNIQUEIDENTIFIER CONSTRAINT [DF_EntityLocation_RecordState] DEFAULT('00000000-0000-0000-0000-000000000000') NOT NULL,
[CreatedDate] DATETIME CONSTRAINT [DF_EntityLocation_CreatedDate] DEFAULT (getutcdate()) NOT NULL,
[ModifiedDate] DATETIME CONSTRAINT [DF_EntityLocation_ModifiedDate] DEFAULT (getutcdate()) NOT NULL,
CONSTRAINT [PK_EntityLocation] PRIMARY KEY CLUSTERED ([EntityLocationId] ASC),
CONSTRAINT [FK_EntityLocation_Entity] FOREIGN KEY ([EntityKey]) REFERENCES [Entity].[Entity] ([EntityKey]),
CONSTRAINT [FK_EntityLocation_Location] FOREIGN KEY ([LocationKey]) REFERENCES [Entity].[Location] ([LocationKey]),
CONSTRAINT [FK_EntityLocation_LocationType] FOREIGN KEY ([LocationTypeKey]) REFERENCES [Entity].[LocationType] ([LocationTypeKey]),
CONSTRAINT [FK_EntityLocation_RecordState] FOREIGN KEY ([RecordStateKey]) REFERENCES [Entity].[RecordState] ([RecordStateKey])
);
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_EntityLocation_Entity] ON [Entity].[Entity] ([EntityKey] Asc)
GO
CREATE UNIQUE NonCLUSTERED INDEX [IX_EntityLocation_All] ON [Entity].[EntityLocation] ([EntityKey] Asc, [LocationKey] Asc)
GO
Loading

0 comments on commit 07553fa

Please sign in to comment.