-
Notifications
You must be signed in to change notification settings - Fork 23
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
PAS-148 | Data export #465
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
private async Task BackupEntityAsync<TEntity>(Guid groupId, string tenant) where TEntity : PerTenant | ||
{ |
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.
@abergs & @jrmccannon For this I required to make ApplicationEvent
inherit from PerTenant
.
@@ -87,9 +90,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) | |||
modelBuilder.Entity<ApplicationEvent>(builder => | |||
{ | |||
builder.HasKey(x => x.Id); |
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.
This adds backwards compatibility, so we don't need to migrate any data, it just maps it to the new CLR property.
Re-iterating earlier comment: Let's review this PR but do not merge it until we've shipped some of the things currently in |
Ticket
Description
We need to be able to export individual applications with all their relevant data, so customers can migrate to self-hosted instances.
Shape
Given applications with either a lot of users or enterprise applications with event logging enabled can end up having a lot of records.
Considerations:
Remarks:
Split to one file per entity type. Every file is a csv document compliant with RFC-4180. Splitting to a file per record makes it also easier theoretically to enable paging at a later stage when a file grows to a certain size.
POST /backup/schedule
: Schedules a new backup job.GET /backup/jobs
: Retrieves a list of backup jobs with their relevant status past or present.Example response:
The data stored is stored as a UTF-8 encoded byte array.
The upload process would likely involve a user to create a new organization, and import an old app by uploading the exported files. The restoration would only be able to start if the schema's match and when all documents were successfully uploaded.
ApplicationEvents
An additional migration for
ApplicationEvents
had to be included, as it was not inheriting fromPerTenant
according to the conventions we had laid out forDbTenantContext
. This was then essentially messing with the generics I had implemented inBackupWorkerService
. This would have otherwise significantly impacted maintainability as well.To prevent any unnecessary migrations from being executed which could result into data loss, the database column was mapped manually to its original value. Just the snapshot was essentially updated to reflect the mapping from the column name to the property (CLR).
Screenshots
n/a
Checklist
I did the following to ensure that my changes were tested thoroughly:
I did the following to ensure that my changes did not introduce new security vulnerabilities: