Skip to content

Commit

Permalink
[SM-222] [SM-357] Squash Secrets Manager migrations (#2540)
Browse files Browse the repository at this point in the history
* Fix tables not being cleaned up

* Fix migration

* Squash secrets manager migrations

* Reset EF to pre SM state

* Add EF migrations

* Fix unified docker

* Add missed copy
  • Loading branch information
Hinton authored Jan 10, 2023
1 parent 5a0d38c commit cb96fad
Show file tree
Hide file tree
Showing 76 changed files with 3,133 additions and 25,699 deletions.
2 changes: 2 additions & 0 deletions docker-unified/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ COPY util/MySqlMigrations/*.csproj ./util/MySqlMigrations/
COPY util/PostgresMigrations/*.csproj ./util/PostgresMigrations/
COPY util/SqliteMigrations/*.csproj ./util/SqliteMigrations/
COPY bitwarden_license/src/Commercial.Core/*.csproj ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/*.csproj ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY Directory.Build.props .

# Restore Admin project dependencies and tools
Expand Down Expand Up @@ -129,6 +130,7 @@ COPY util/PostgresMigrations/. ./util/PostgresMigrations/
COPY util/SqliteMigrations/. ./util/SqliteMigrations/
COPY util/EfShared/. ./util/EfShared/
COPY bitwarden_license/src/Commercial.Core/. ./bitwarden_license/src/Commercial.Core/
COPY bitwarden_license/src/Commercial.Infrastructure.EntityFramework/. ./bitwarden_license/src/Commercial.Infrastructure.EntityFramework/
COPY .git/. ./.git/

# Build Admin app
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
<ItemGroup>
<ProjectReference Include="..\SharedWeb\SharedWeb.csproj" />
<ProjectReference Include="..\Core\Core.csproj" />
<ProjectReference Include="..\..\bitwarden_license\src\Commercial.Infrastructure.EntityFramework\Commercial.Infrastructure.EntityFramework.csproj" />
</ItemGroup>

<Choose>
<When Condition="!$(DefineConstants.Contains('OSS'))">
<ItemGroup>
<ProjectReference Include="..\..\bitwarden_license\src\Commercial.Core\Commercial.Core.csproj" />
<ProjectReference Include="..\..\bitwarden_license\src\Commercial.Infrastructure.EntityFramework\Commercial.Infrastructure.EntityFramework.csproj" />
</ItemGroup>
</When>
</Choose>
Expand Down
1 change: 0 additions & 1 deletion src/Sql/Sql.sqlproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
<Build Include="dbo\Functions\UserCipherDetails.sql" />
<Build Include="dbo\Functions\UserCollectionDetails.sql" />
<Build Include="dbo\Stored Procedures\ApiKey\ApiKeyDetails_ReadById.sql" />
<Build Include="dbo\Stored Procedures\ApiKey\ApiKey_ReadById.sql" />
<Build Include="dbo\Stored Procedures\ApiKey\ApiKey_ReadByServiceAccountId.sql" />
<Build Include="dbo\Stored Procedures\ApiKey\ApiKey_Create.sql" />
<Build Include="dbo\Stored Procedures\AuthRequest_Create.sql" />
Expand Down
13 changes: 0 additions & 13 deletions src/Sql/dbo/Stored Procedures/ApiKey/ApiKey_ReadById.sql

This file was deleted.

14 changes: 14 additions & 0 deletions src/Sql/dbo/Stored Procedures/Organization_DeleteById.sql
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ BEGIN
WHERE
[OrganizationId] = @Id

DELETE AK
FROM
[dbo].[ApiKey] AK
INNER JOIN
[dbo].[ServiceAccount] SA ON [AK].[ServiceAccountId] = [SA].[Id]
WHERE
[SA].[OrganizationId] = @Id

DELETE
FROM
[dbo].[ServiceAccount]
WHERE
[OrganizationId] = @Id

DELETE
FROM
[dbo].[Organization]
Expand Down
10 changes: 10 additions & 0 deletions src/Sql/dbo/Stored Procedures/User_DeleteById.sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ BEGIN
WHERE
OU.[UserId] = @Id

-- Delete AccessPolicy
DELETE
AP
FROM
[dbo].[AccessPolicy] AP
INNER JOIN
[dbo].[OrganizationUser] OU ON OU.[Id] = AP.[OrganizationUserId]
WHERE
[UserId] = @Id

-- Delete organization users
DELETE
FROM
Expand Down
2 changes: 1 addition & 1 deletion src/Sql/dbo/Tables/ProjectSecret.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
);

GO
CREATE INDEX [IX_ProjectSecret_SecretsId] ON [ProjectSecret] ([SecretsId]);
CREATE NONCLUSTERED INDEX [IX_ProjectSecret_SecretsId] ON [ProjectSecret] ([SecretsId]);
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ SELECT
O.[Use2fa],
O.[UseApi],
O.[UseResetPassword],
O.[UseSecretsManager],
O.[SelfHost],
O.[UsersGetPremium],
O.[UseCustomPermissions],
O.[UseSecretsManager],
O.[Seats],
O.[MaxCollections],
O.[MaxStorageGb],
Expand Down
20 changes: 0 additions & 20 deletions util/Migrator/DbScripts/2022-07-20_00_CreateSecretTable.sql

This file was deleted.

20 changes: 0 additions & 20 deletions util/Migrator/DbScripts/2022-08-10_00_Project.sql

This file was deleted.

120 changes: 0 additions & 120 deletions util/Migrator/DbScripts/2022-09-19_00_ProjectSecret.sql

This file was deleted.

16 changes: 0 additions & 16 deletions util/Migrator/DbScripts/2022-09-26_00_SmServiceAccount.sql

This file was deleted.

43 changes: 0 additions & 43 deletions util/Migrator/DbScripts/2022-09-27_00_ApiKey.sql

This file was deleted.

Loading

0 comments on commit cb96fad

Please sign in to comment.