1
0
mirror of https://github.com/bitwarden/server.git synced 2025-01-22 21:51:22 +01:00

fresh sql schema import

This commit is contained in:
Kyle Spearrin 2017-05-31 08:55:07 -04:00
parent a3a42f4fd5
commit bdce4064b2
7 changed files with 81 additions and 80 deletions

View File

@ -65,71 +65,77 @@
<Folder Include="dbo\Functions\" />
<Folder Include="dbo\Stored Procedures\" />
<Folder Include="dbo\User Defined Types\" />
<Folder Include="pg" />
</ItemGroup>
<ItemGroup>
<Build Include="dbo\Tables\Grant.sql" />
<Build Include="dbo\Tables\Collection.sql" />
<Build Include="dbo\Tables\CollectionCipher.sql" />
<Build Include="dbo\Tables\CollectionGroup.sql" />
<Build Include="dbo\Tables\CollectionUser.sql" />
<Build Include="dbo\Tables\Organization.sql" />
<Build Include="dbo\Tables\Device.sql" />
<Build Include="dbo\Tables\Folder.sql" />
<Build Include="dbo\Tables\Cipher.sql" />
<Build Include="dbo\Tables\User.sql" />
<Build Include="dbo\Tables\Collection.sql" />
<Build Include="dbo\Tables\CollectionCipher.sql" />
<Build Include="dbo\Tables\CollectionGroup.sql" />
<Build Include="dbo\Tables\CollectionUser.sql" />
<Build Include="dbo\Tables\Group.sql" />
<Build Include="dbo\Tables\GroupUser.sql" />
<Build Include="dbo\Tables\Organization.sql" />
<Build Include="dbo\Tables\OrganizationUser.sql" />
<Build Include="dbo\Views\GrantView.sql" />
<Build Include="dbo\Views\UserView.sql" />
<Build Include="dbo\Views\CollectionView.sql" />
<Build Include="dbo\Views\CipherView.sql" />
<Build Include="dbo\Views\DeviceView.sql" />
<Build Include="dbo\Views\CollectionView.sql" />
<Build Include="dbo\Views\GroupView.sql" />
<Build Include="dbo\Views\FolderView.sql" />
<Build Include="dbo\Views\OrganizationUserOrganizationDetailsView.sql" />
<Build Include="dbo\Views\OrganizationUserUserDetailsView.sql" />
<Build Include="dbo\Views\OrganizationUserView.sql" />
<Build Include="dbo\Views\OrganizationView.sql" />
<Build Include="dbo\Functions\CipherDetails.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUserUserDetails_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\Organization_ReadById.sql" />
<Build Include="dbo\Stored Procedures\Organization_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\Organization_Update.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_Create.sql" />
<Build Include="dbo\Stored Procedures\Grant_DeleteByKey.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_DeleteById.sql" />
<Build Include="dbo\Stored Procedures\Grant_DeleteBySubjectIdClientId.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadById.sql" />
<Build Include="dbo\Stored Procedures\Grant_DeleteBySubjectIdClientIdType.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\Grant_ReadByKey.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadByOrganizationIdEmail.sql" />
<Build Include="dbo\Stored Procedures\Grant_ReadBySubjectId.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadByOrganizationIdUserId.sql" />
<Build Include="dbo\Stored Procedures\Grant_Save.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadCountByFreeOrganizationAdminUser.sql" />
<Build Include="dbo\Stored Procedures\User_ReadAccountRevisionDateById.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadCountByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadCountByOrganizationOwnerUser.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_Update.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUserOrganizationDetails_ReadByUserIdStatus.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUserUserDetails_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\User_BumpAccountRevisionDate.sql" />
<Build Include="dbo\Stored Procedures\User_BumpAccountRevisionDateByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\User_BumpAccountRevisionDateByOrganizationUserId.sql" />
<Build Include="dbo\Stored Procedures\User_ReadPublicKeyById.sql" />
<Build Include="dbo\Stored Procedures\Cipher_UpdatePartial.sql" />
<Build Include="dbo\Stored Procedures\Cipher_UpdateWithCollections.sql" />
<Build Include="dbo\Stored Procedures\CipherDetails_Create.sql" />
<Build Include="dbo\Stored Procedures\CipherDetails_Update.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_Create.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_Delete.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_UpdateCollections.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_UpdateCollectionsAdmin.sql" />
<Build Include="dbo\Stored Procedures\Folder_Create.sql" />
<Build Include="dbo\Stored Procedures\Folder_DeleteById.sql" />
<Build Include="dbo\Stored Procedures\Folder_Update.sql" />
<Build Include="dbo\Stored Procedures\Organization_DeleteById.sql" />
<Build Include="dbo\Stored Procedures\Cipher_UpdateWithCollections.sql" />
<Build Include="dbo\Stored Procedures\CipherDetails_ReadByUserIdHasCollection.sql" />
<Build Include="dbo\Stored Procedures\Collection_Create.sql" />
<Build Include="dbo\Stored Procedures\Collection_DeleteById.sql" />
<Build Include="dbo\Stored Procedures\Collection_ReadById.sql" />
<Build Include="dbo\Stored Procedures\Collection_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\Collection_ReadCountByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\Collection_Update.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_Create.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_Delete.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_ReadByUserIdCipherId.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_UpdateCollections.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_UpdateCollectionsAdmin.sql" />
<Build Include="dbo\Stored Procedures\Cipher_ReadCanEditByIdUserId.sql" />
<Build Include="dbo\Stored Procedures\Cipher_Create.sql" />
<Build Include="dbo\Stored Procedures\Cipher_DeleteById.sql" />
<Build Include="dbo\Stored Procedures\Cipher_ReadById.sql" />
<Build Include="dbo\Stored Procedures\Collection_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\CollectionUserDetails_ReadByCollectionId.sql" />
<Build Include="dbo\Stored Procedures\Cipher_Update.sql" />
<Build Include="dbo\Stored Procedures\Device_Create.sql" />
<Build Include="dbo\Stored Procedures\Device_DeleteById.sql" />
@ -144,52 +150,47 @@
<Build Include="dbo\Stored Procedures\User_Update.sql" />
<Build Include="dbo\Stored Procedures\User_UpdateEmailPassword.sql" />
<Build Include="dbo\Stored Procedures\Device_ClearPushTokenByIdentifier.sql" />
<Build Include="dbo\Stored Procedures\Collection_CreateWithGroups.sql" />
<Build Include="dbo\Stored Procedures\Collection_ReadWithGroupsById.sql" />
<Build Include="dbo\Stored Procedures\Collection_UpdateWithGroups.sql" />
<Build Include="dbo\Stored Procedures\CollectionUser_Delete.sql" />
<Build Include="dbo\Stored Procedures\CollectionUserDetails_ReadByCollectionId.sql" />
<Build Include="dbo\Stored Procedures\Cipher_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\Group_Create.sql" />
<Build Include="dbo\Stored Procedures\CipherDetails_ReadByIdUserId.sql" />
<Build Include="dbo\Stored Procedures\Group_CreateWithCollections.sql" />
<Build Include="dbo\Stored Procedures\CipherDetails_ReadByTypeUserId.sql" />
<Build Include="dbo\Stored Procedures\Group_DeleteById.sql" />
<Build Include="dbo\Stored Procedures\CipherDetails_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\Group_ReadById.sql" />
<Build Include="dbo\Stored Procedures\CipherDetails_ReadByUserIdHasCollection.sql" />
<Build Include="dbo\Stored Procedures\Group_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\Group_ReadWithCollectionsById.sql" />
<Build Include="dbo\Stored Procedures\Collection_Create.sql" />
<Build Include="dbo\Stored Procedures\Group_Update.sql" />
<Build Include="dbo\Stored Procedures\Collection_DeleteById.sql" />
<Build Include="dbo\Stored Procedures\Group_UpdateWithCollections.sql" />
<Build Include="dbo\Stored Procedures\Collection_ReadById.sql" />
<Build Include="dbo\Stored Procedures\GroupUser_Delete.sql" />
<Build Include="dbo\Stored Procedures\Collection_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\GroupUser_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\Collection_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\GroupUser_ReadGroupIdsByOrganizationUserId.sql" />
<Build Include="dbo\Stored Procedures\Collection_ReadCountByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\GroupUser_UpdateGroups.sql" />
<Build Include="dbo\Stored Procedures\Collection_Update.sql" />
<Build Include="dbo\Stored Procedures\GroupUser_UpdateUsers.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\GroupUserDetails_ReadByGroupId.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_CreateWithCollections.sql" />
<Build Include="dbo\Stored Procedures\CollectionCipher_ReadByUserIdCipherId.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadWithCollectionsById.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_UpdateWithCollections.sql" />
<Build Include="dbo\Stored Procedures\Folder_ReadById.sql" />
<Build Include="dbo\Stored Procedures\Folder_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\Organization_Create.sql" />
<Build Include="dbo\Stored Procedures\Organization_ReadById.sql" />
<Build Include="dbo\Stored Procedures\Organization_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\Organization_Update.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_Create.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_DeleteById.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadById.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadByOrganizationIdEmail.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadByOrganizationIdUserId.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadByUserId.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadCountByFreeOrganizationAdminUser.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadCountByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_Update.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUserOrganizationDetails_ReadByUserIdStatus.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadWithCollectionsById.sql" />
<Build Include="dbo\User Defined Types\GuidIdArray.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_ReadCountByOrganizationOwnerUser.sql" />
<Build Include="dbo\Stored Procedures\Cipher_ReadCanEditByIdUserId.sql" />
<Build Include="dbo\Stored Procedures\Group_Create.sql" />
<Build Include="dbo\Stored Procedures\Group_DeleteById.sql" />
<Build Include="dbo\Stored Procedures\Group_ReadById.sql" />
<Build Include="dbo\Stored Procedures\Group_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\Group_Update.sql" />
<Build Include="dbo\Views\GroupView.sql" />
<Build Include="dbo\Stored Procedures\Group_CreateWithCollections.sql" />
<Build Include="dbo\Stored Procedures\Group_UpdateWithCollections.sql" />
<Build Include="dbo\Stored Procedures\Group_ReadWithCollectionsById.sql" />
<Build Include="dbo\Stored Procedures\Collection_UpdateWithGroups.sql" />
<Build Include="dbo\Stored Procedures\Collection_CreateWithGroups.sql" />
<Build Include="dbo\Stored Procedures\Collection_ReadWithGroupsById.sql" />
<Build Include="dbo\Stored Procedures\GroupUserDetails_ReadByGroupId.sql" />
<Build Include="dbo\Stored Procedures\GroupUser_ReadGroupIdsByOrganizationUserId.sql" />
<Build Include="dbo\Stored Procedures\GroupUser_UpdateGroups.sql" />
<Build Include="dbo\Stored Procedures\GroupUser_Delete.sql" />
<Build Include="dbo\User Defined Types\SelectionReadOnlyArray.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_CreateWithCollections.sql" />
<Build Include="dbo\Stored Procedures\OrganizationUser_UpdateWithCollections.sql" />
<Build Include="dbo\Stored Procedures\CollectionUser_Delete.sql" />
<Build Include="dbo\Stored Procedures\GroupUser_ReadByOrganizationId.sql" />
<Build Include="dbo\Stored Procedures\GroupUser_UpdateUsers.sql" />
</ItemGroup>
</Project>

View File

@ -41,4 +41,4 @@ BEGIN
OR G.[AccessAll] = 1
)
)
END
END

View File

@ -19,4 +19,4 @@ BEGIN
[dbo].[User] U ON U.[Id] = OU.[UserId]
WHERE
GU.[GroupId] = @GroupId
END
END

View File

@ -1,7 +1,7 @@
CREATE TABLE [dbo].[CollectionUser] (
[CollectionId] UNIQUEIDENTIFIER NOT NULL,
[OrganizationUserId] UNIQUEIDENTIFIER NOT NULL,
[ReadOnly] BIT NOT NULL
[ReadOnly] BIT NOT NULL,
CONSTRAINT [PK_CollectionUser] PRIMARY KEY CLUSTERED ([CollectionId] ASC, [OrganizationUserId] ASC),
CONSTRAINT [FK_CollectionUser_Collection] FOREIGN KEY ([CollectionId]) REFERENCES [dbo].[Collection] ([Id]) ON DELETE CASCADE,
CONSTRAINT [FK_CollectionUser_OrganizationUser] FOREIGN KEY ([OrganizationUserId]) REFERENCES [dbo].[OrganizationUser] ([Id])

View File

@ -1,6 +1,6 @@
CREATE TABLE [dbo].[GroupUser] (
[GroupId] UNIQUEIDENTIFIER NOT NULL,
[OrganizationUserId] UNIQUEIDENTIFIER NOT NULL,
[GroupId] UNIQUEIDENTIFIER NOT NULL,
[OrganizationUserId] UNIQUEIDENTIFIER NOT NULL,
CONSTRAINT [PK_GroupUser] PRIMARY KEY CLUSTERED ([GroupId] ASC, [OrganizationUserId] ASC),
CONSTRAINT [FK_GroupUser_Group] FOREIGN KEY ([GroupId]) REFERENCES [dbo].[Group] ([Id]) ON DELETE CASCADE,
CONSTRAINT [FK_GroupUser_OrganizationUser] FOREIGN KEY ([OrganizationUserId]) REFERENCES [dbo].[OrganizationUser] ([Id])

View File

@ -1,15 +1,15 @@
CREATE TABLE [dbo].[OrganizationUser] (
[Id] UNIQUEIDENTIFIER NOT NULL,
[OrganizationId] UNIQUEIDENTIFIER NOT NULL,
[UserId] UNIQUEIDENTIFIER NULL,
[Email] NVARCHAR (50) NULL,
[Key] VARCHAR (MAX) NULL,
[Status] TINYINT NOT NULL,
[Type] TINYINT NOT NULL,
[AccessAll] BIT NOT NULL,
[ExternalId] NVARCHAR (300) NULL,
[CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
[Id] UNIQUEIDENTIFIER NOT NULL,
[OrganizationId] UNIQUEIDENTIFIER NOT NULL,
[UserId] UNIQUEIDENTIFIER NULL,
[Email] NVARCHAR (50) NULL,
[Key] VARCHAR (MAX) NULL,
[Status] TINYINT NOT NULL,
[Type] TINYINT NOT NULL,
[AccessAll] BIT NOT NULL,
[ExternalId] NVARCHAR (300) NULL,
[CreationDate] DATETIME2 (7) NOT NULL,
[RevisionDate] DATETIME2 (7) NOT NULL,
CONSTRAINT [PK_OrganizationUser] PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_OrganizationUser_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE,
CONSTRAINT [FK_OrganizationUser_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id])

View File

@ -1,4 +1,4 @@
CREATE TYPE [dbo].[SelectionReadOnlyArray] AS TABLE (
[Id] UNIQUEIDENTIFIER NOT NULL,
[ReadOnly] BIT NOT NULL);
[Id] UNIQUEIDENTIFIER NOT NULL,
[ReadOnly] BIT NOT NULL);