Saving snapshots
This commit is contained in:
6
Shogi.Database/Session/Stored Procedures/CreateState.sql
Normal file
6
Shogi.Database/Session/Stored Procedures/CreateState.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
CREATE PROCEDURE [session].[CreateState]
|
||||
@SessionId [session].[SessionSurrogateKey],
|
||||
@Document NVARCHAR(MAX)
|
||||
AS
|
||||
|
||||
INSERT INTO [session].[State] (SessionId, Document) VALUES (@SessionId, @Document);
|
||||
@@ -0,0 +1,7 @@
|
||||
CREATE PROCEDURE [session].[ReadStatesBySession]
|
||||
@SessionId [session].[SessionSurrogateKey]
|
||||
AS
|
||||
|
||||
SELECT Id, SessionId, Document
|
||||
FROM [session].[State]
|
||||
WHERE Id = @SessionId;
|
||||
9
Shogi.Database/Session/Tables/State.sql
Normal file
9
Shogi.Database/Session/Tables/State.sql
Normal file
@@ -0,0 +1,9 @@
|
||||
CREATE TABLE [session].[State]
|
||||
(
|
||||
[Id] BIGINT NOT NULL PRIMARY KEY IDENTITY,
|
||||
[SessionId] [session].[SessionSurrogateKey] NOT NULL,
|
||||
[Document] NVARCHAR(MAX) NOT NULL,
|
||||
|
||||
CONSTRAINT [FK_State_ToSession] FOREIGN KEY (SessionId) REFERENCES [session].[Session](Id),
|
||||
CONSTRAINT [StateDocument must be JSON] CHECK(ISJSON(Document)=1)
|
||||
)
|
||||
@@ -1,2 +1,3 @@
|
||||
CREATE TYPE [session].[SessionSurrogateKey]
|
||||
-- C# Guid
|
||||
CREATE TYPE [session].[SessionSurrogateKey]
|
||||
FROM CHAR(36) NOT NULL
|
||||
|
||||
@@ -79,6 +79,9 @@
|
||||
<Build Include="Session\Stored Procedures\ReadSessionsMetadata.sql" />
|
||||
<Build Include="AspNetUsersId.sql" />
|
||||
<Build Include="Session\Functions\MaxNewSessionsPerUser.sql" />
|
||||
<Build Include="Session\Tables\State.sql" />
|
||||
<Build Include="Session\Stored Procedures\CreateState.sql" />
|
||||
<Build Include="Session\Stored Procedures\ReadStatesBySession.sql" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PostDeploy Include="Post Deployment\Script.PostDeployment.sql" />
|
||||
|
||||
Reference in New Issue
Block a user