mirror of
https://github.com/bitwarden/server.git
synced 2025-07-13 13:47:30 -05:00
added transactions table
This commit is contained in:
@ -240,5 +240,16 @@
|
||||
<Build Include="dbo\Stored Procedures\Cipher_CreateWithCollections.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Cipher_UpdateCollections.sql" />
|
||||
<Build Include="dbo\Stored Procedures\CipherDetails_CreateWithCollections.sql" />
|
||||
<Build Include="dbo\Tables\Transaction.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Transaction_Create.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Transaction_DeleteById.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Transaction_ReadById.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Transaction_ReadByOrganizationId.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Transaction_Update.sql" />
|
||||
<Build Include="dbo\Views\TransactionView.sql" />
|
||||
<Build Include="dbo\Stored Procedures\Transaction_ReadByUserId.sql" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<RefactorLog Include="Sql.refactorlog" />
|
||||
</ItemGroup>
|
||||
</Project>
|
48
src/Sql/dbo/Stored Procedures/Transaction_Create.sql
Normal file
48
src/Sql/dbo/Stored Procedures/Transaction_Create.sql
Normal file
@ -0,0 +1,48 @@
|
||||
CREATE PROCEDURE [dbo].[Transaction_Create]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Type TINYINT,
|
||||
@Amount MONEY,
|
||||
@Refunded BIT,
|
||||
@RefundedAmount MONEY,
|
||||
@Details NVARCHAR(100),
|
||||
@PaymentMethodType TINYINT,
|
||||
@Gateway TINYINT,
|
||||
@GatewayId VARCHAR(50),
|
||||
@CreationDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
INSERT INTO [dbo].[Transaction]
|
||||
(
|
||||
[Id],
|
||||
[UserId],
|
||||
[OrganizationId],
|
||||
[Type],
|
||||
[Amount],
|
||||
[Refunded],
|
||||
[RefundedAmount],
|
||||
[Details],
|
||||
[PaymentMethodType],
|
||||
[Gateway],
|
||||
[GatewayId],
|
||||
[CreationDate]
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@Id,
|
||||
@UserId,
|
||||
@OrganizationId,
|
||||
@Type,
|
||||
@Amount,
|
||||
@Refunded,
|
||||
@RefundedAmount,
|
||||
@Details,
|
||||
@PaymentMethodType,
|
||||
@Gateway,
|
||||
@GatewayId,
|
||||
@CreationDate
|
||||
)
|
||||
END
|
12
src/Sql/dbo/Stored Procedures/Transaction_DeleteById.sql
Normal file
12
src/Sql/dbo/Stored Procedures/Transaction_DeleteById.sql
Normal file
@ -0,0 +1,12 @@
|
||||
CREATE PROCEDURE [dbo].[Transaction_DeleteById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
DELETE
|
||||
FROM
|
||||
[dbo].[Transaction]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
13
src/Sql/dbo/Stored Procedures/Transaction_ReadById.sql
Normal file
13
src/Sql/dbo/Stored Procedures/Transaction_ReadById.sql
Normal file
@ -0,0 +1,13 @@
|
||||
CREATE PROCEDURE [dbo].[Transaction_ReadById]
|
||||
@Id UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[TransactionView]
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
@ -0,0 +1,14 @@
|
||||
CREATE PROCEDURE [dbo].[Transaction_ReadByOrganizationId]
|
||||
@OrganizationId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[TransactionView]
|
||||
WHERE
|
||||
[UserId] = NULL
|
||||
AND [OrganizationId] = @OrganizationId
|
||||
END
|
13
src/Sql/dbo/Stored Procedures/Transaction_ReadByUserId.sql
Normal file
13
src/Sql/dbo/Stored Procedures/Transaction_ReadByUserId.sql
Normal file
@ -0,0 +1,13 @@
|
||||
CREATE PROCEDURE [dbo].[Transaction_ReadByUserId]
|
||||
@UserId UNIQUEIDENTIFIER
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[TransactionView]
|
||||
WHERE
|
||||
[UserId] = @UserId
|
||||
END
|
34
src/Sql/dbo/Stored Procedures/Transaction_Update.sql
Normal file
34
src/Sql/dbo/Stored Procedures/Transaction_Update.sql
Normal file
@ -0,0 +1,34 @@
|
||||
CREATE PROCEDURE [dbo].[Transaction_Update]
|
||||
@Id UNIQUEIDENTIFIER,
|
||||
@UserId UNIQUEIDENTIFIER,
|
||||
@OrganizationId UNIQUEIDENTIFIER,
|
||||
@Type TINYINT,
|
||||
@Amount MONEY,
|
||||
@Refunded BIT,
|
||||
@RefundedAmount MONEY,
|
||||
@Details NVARCHAR(100),
|
||||
@PaymentMethodType TINYINT,
|
||||
@Gateway TINYINT,
|
||||
@GatewayId VARCHAR(50),
|
||||
@CreationDate DATETIME2(7)
|
||||
AS
|
||||
BEGIN
|
||||
SET NOCOUNT ON
|
||||
|
||||
UPDATE
|
||||
[dbo].[Transaction]
|
||||
SET
|
||||
[UserId] = @UserId,
|
||||
[OrganizationId] = @OrganizationId,
|
||||
[Type] = @Type,
|
||||
[Amount] = @Amount,
|
||||
[Refunded] = @Refunded,
|
||||
[RefundedAmount] = @RefundedAmount,
|
||||
[Details] = @Details,
|
||||
[PaymentMethodType] = @PaymentMethodType,
|
||||
[Gateway] = @Gateway,
|
||||
[GatewayId] = @GatewayId,
|
||||
[CreationDate] = @CreationDate
|
||||
WHERE
|
||||
[Id] = @Id
|
||||
END
|
28
src/Sql/dbo/Tables/Transaction.sql
Normal file
28
src/Sql/dbo/Tables/Transaction.sql
Normal file
@ -0,0 +1,28 @@
|
||||
CREATE TABLE [dbo].[Transaction] (
|
||||
[Id] UNIQUEIDENTIFIER NOT NULL,
|
||||
[UserId] UNIQUEIDENTIFIER NULL,
|
||||
[OrganizationId] UNIQUEIDENTIFIER NULL,
|
||||
[Type] TINYINT NOT NULL,
|
||||
[Amount] MONEY NOT NULL,
|
||||
[Refunded] BIT NULL,
|
||||
[RefundedAmount] MONEY NULL,
|
||||
[Details] NVARCHAR(100) NULL,
|
||||
[PaymentMethodType] TINYINT NULL,
|
||||
[Gateway] TINYINT NULL,
|
||||
[GatewayId] VARCHAR(50) NULL,
|
||||
[CreationDate] DATETIME2 (7) NOT NULL,
|
||||
CONSTRAINT [PK_Transaction] PRIMARY KEY CLUSTERED ([Id] ASC),
|
||||
CONSTRAINT [FK_Transaction_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]) ON DELETE CASCADE,
|
||||
CONSTRAINT [FK_Transaction_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Transaction_Gateway_GatewayId]
|
||||
ON [dbo].[Transaction]([Gateway] ASC, [GatewayId] ASC);
|
||||
|
||||
|
||||
GO
|
||||
CREATE NONCLUSTERED INDEX [IX_Transaction_UserId_OrganizationId_CreationDate]
|
||||
ON [dbo].[Transaction]([UserId] ASC, [OrganizationId] ASC, [CreationDate] ASC);
|
||||
|
6
src/Sql/dbo/Views/TransactionView.sql
Normal file
6
src/Sql/dbo/Views/TransactionView.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE VIEW [dbo].[TransactionView]
|
||||
AS
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
[dbo].[Transaction]
|
Reference in New Issue
Block a user