-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Initial PoC of seeder API #6424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Hinton
wants to merge
25
commits into
arch/seeder-sdk
Choose a base branch
from
arch/seeder-api
base: arch/seeder-sdk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+986
โ39
Draft
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
fa46919
Initial PoC of seeder API
Hinton d0d6bfb
Extract logic into service
Hinton 2b340b7
Reformat
Hinton 79f5d8f
Add support for destroying seeded data
Hinton 92f2555
Refactor to track entities rather than manually writing destroy
Hinton f4342e2
Add SingleUserRecipe for seeding a single known user
MGibson1 d93cd50
Fix launch settings
MGibson1 431a708
Delete all seeded data
MGibson1 44aef68
Merge branch 'arch/seeder-sdk' of github.com:bitwarden/server into arโฆ
Hinton 3d863c0
Fixup device table user FK cascade
MGibson1 9c4c88f
Wire up SDK
Hinton 13d666a
Fixup user mangling
MGibson1 ec82894
Prefer Repositories for Delete of entities
MGibson1 a7340c9
Add delete batch for playwright worker cleanup
MGibson1 fac2804
Force ef
Hinton 99fb70a
use named parameters
MGibson1 45ba8f8
Add support for setting email verified and premium in seed
Hinton 1137857
Add recipe for getting emergency access invites
Hinton 39cdb65
Add cargo as enabled manager in renovate
Hinton bb226ff
Delete Sdk2
Hinton 58c620e
Merge branch 'arch/seeder-sdk' of github.com:bitwarden/server into arโฆ
Hinton b9dcac4
Initial cleanup
Hinton f6fe7a9
Change to primary constructor
Hinton fd41332
Refactor recipies into scenes
Hinton 1daf9ad
Add queries, rename seed to scene
Hinton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Bit.Infrastructure.EntityFramework.Models; | ||
|
||
public class SeededData | ||
{ | ||
public Guid Id { get; set; } | ||
public required string RecipeName { get; set; } | ||
/// <summary> | ||
/// JSON blob containing all | ||
/// </summary> | ||
public required string Data { get; set; } | ||
public DateTime CreationDate { get; set; } | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
CREATE TABLE [dbo].[SeededData] ( | ||
[Id] UNIQUEIDENTIFIER NOT NULL, | ||
[RecipeName] NVARCHAR (MAX) NOT NULL, | ||
[Data] NVARCHAR (MAX) NULL, | ||
[CreationDate] DATETIME2 (7) NOT NULL, | ||
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
IF OBJECT_ID('dbo.SeededData') IS NULL | ||
BEGIN | ||
CREATE TABLE [dbo].[SeededData] ( | ||
[Id] UNIQUEIDENTIFIER NOT NULL, | ||
[RecipeName] NVARCHAR (MAX) NOT NULL, | ||
[Data] NVARCHAR (MAX) NULL, | ||
[CreationDate] DATETIME2 (7) NOT NULL, | ||
); | ||
END | ||
GO |
10 changes: 10 additions & 0 deletions
10
util/Migrator/DbScripts/2025-10-09_00_Device_AddUserCascadeDelete.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
IF OBJECT_ID('[dbo].[FK_Device_User]', 'F') IS NOT NULL | ||
BEGIN | ||
ALTER TABLE [dbo].[Device] | ||
DROP CONSTRAINT [FK_Device_User] | ||
END | ||
GO | ||
|
||
ALTER TABLE [dbo].[Device] | ||
ADD CONSTRAINT [FK_Device_User] FOREIGN KEY ([UserId]) REFERENCES [dbo].[User] ([Id]) ON DELETE CASCADE | ||
GO |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MGibson1 did we want to revert this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was undecided. I believe we don't need it anymore with the full repository injection we're using, but it's not wrong.
@rkac-bw @withinfocus Care to comment on using cascading delete here vs needing to understand delete through sprocs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not a fan of cascades personally and try to avoid them, but they were here when I showed up so I am working with it. Our approach -- and this could use documentation on our revamped SQL code style page -- is to manage deletions that touch critical tables explicitly e.g. Organization_DeleteById, and for smaller children of those tables to allow cascades so as to keep the coding pattern simple enough.
One example:
OrganizationIntegration
, being linked to the criticalOrganization
table, is deleted via the above proc. Its child tableOrganizationIntegrationConfiguration
has a cascade delete on it.