tgstation-server 6.9.2
The /tg/station 13 server suite
Loading...
Searching...
No Matches
DatabaseContext.cs
Go to the documentation of this file.
1using System;
2using System.Globalization;
3using System.Linq;
4using System.Reflection;
5using System.Threading;
6using System.Threading.Tasks;
7
8using Microsoft.EntityFrameworkCore;
9using Microsoft.EntityFrameworkCore.Infrastructure;
10using Microsoft.EntityFrameworkCore.Migrations;
11using Microsoft.Extensions.DependencyInjection;
12using Microsoft.Extensions.Logging;
13
17
19{
23#pragma warning disable CA1506 // TODO: Decomplexify
25 {
29 public DbSet<User> Users { get; set; }
30
34 public DbSet<Instance> Instances { get; set; }
35
39 public DbSet<CompileJob> CompileJobs { get; set; }
40
44 public DbSet<RevisionInformation> RevisionInformations { get; set; }
45
49 public DbSet<DreamMakerSettings> DreamMakerSettings { get; set; }
50
54 public DbSet<ChatBot> ChatBots { get; set; }
55
59 public DbSet<DreamDaemonSettings> DreamDaemonSettings { get; set; }
60
64 public DbSet<RepositorySettings> RepositorySettings { get; set; }
65
69 public DbSet<InstancePermissionSet> InstancePermissionSets { get; set; }
70
74 public DbSet<ChatChannel> ChatChannels { get; set; }
75
79 public DbSet<Job> Jobs { get; set; }
80
84 public DbSet<ReattachInformation> ReattachInformations { get; set; }
85
89 public DbSet<TestMerge> TestMerges { get; set; }
90
94 public DbSet<RevInfoTestMerge> RevInfoTestMerges { get; set; }
95
99 public DbSet<OAuthConnection> OAuthConnections { get; set; }
100
104 public DbSet<PermissionSet> PermissionSets { get; set; }
105
109 public DbSet<UserGroup> Groups { get; set; }
110
113
116
119
121 IDatabaseCollection<Job> IDatabaseContext.Jobs => jobsCollection;
122
125
128
131
134
137
140
143
146
149
152
154 IDatabaseCollection<OAuthConnection> IDatabaseContext.OAuthConnections => oAuthConnections;
155
157 IDatabaseCollection<UserGroup> IDatabaseContext.Groups => groups;
158
160 IDatabaseCollection<PermissionSet> IDatabaseContext.PermissionSets => permissionSets;
161
165 protected virtual DeleteBehavior RevInfoCompileJobDeleteBehavior => DeleteBehavior.ClientNoAction;
166
171
176
181
186
191
196
201
206
211
216
221
226
231
236
241
246
251
257 public static Action<DbContextOptionsBuilder, DatabaseConfiguration> GetConfigureAction<TDatabaseContext>()
258 where TDatabaseContext : DatabaseContext
259 {
260 // HACK HACK HACK HACK HACK
261 const string ConfigureMethodName = nameof(SqlServerDatabaseContext.ConfigureWith);
262 var configureFunction = typeof(TDatabaseContext).GetMethod(
263 ConfigureMethodName,
264 BindingFlags.Public | BindingFlags.Static)
265 ?? throw new InvalidOperationException($"Context type {typeof(TDatabaseContext).FullName} missing static {ConfigureMethodName} function!");
266 return (optionsBuilder, config) => configureFunction.Invoke(null, new object[] { optionsBuilder, config });
267 }
268
273 protected DatabaseContext(DbContextOptions dbContextOptions)
274 : base(dbContextOptions)
275 {
293 }
294
296 public Task Save(CancellationToken cancellationToken) => SaveChangesAsync(cancellationToken);
297
299 public Task Drop(CancellationToken cancellationToken) => Database.EnsureDeletedAsync(cancellationToken);
300
302 public async ValueTask<bool> Migrate(ILogger<DatabaseContext> logger, CancellationToken cancellationToken)
303 {
304 ArgumentNullException.ThrowIfNull(logger);
305 var migrations = await Database.GetAppliedMigrationsAsync(cancellationToken);
306 var wasEmpty = !migrations.Any();
307
308 if (wasEmpty || (await Database.GetPendingMigrationsAsync(cancellationToken)).Any())
309 {
310 logger.LogInformation("Migrating database...");
311 await Database.MigrateAsync(cancellationToken);
312 }
313 else
314 logger.LogDebug("No migrations to apply");
315
316 wasEmpty |= !await Users.AsQueryable().AnyAsync(cancellationToken);
317
318 return wasEmpty;
319 }
320
322 protected override void OnModelCreating(ModelBuilder modelBuilder)
323 {
324 ArgumentNullException.ThrowIfNull(modelBuilder);
325
326 base.OnModelCreating(modelBuilder);
327
328 var userModel = modelBuilder.Entity<User>();
329 userModel.HasIndex(x => x.CanonicalName).IsUnique();
330 userModel.HasIndex(x => x.SystemIdentifier).IsUnique();
331 userModel.HasMany(x => x.TestMerges).WithOne(x => x.MergedBy).OnDelete(DeleteBehavior.Restrict);
332 userModel.HasMany(x => x.OAuthConnections).WithOne(x => x.User).OnDelete(DeleteBehavior.Cascade);
333
334 modelBuilder.Entity<OAuthConnection>().HasIndex(x => new { x.Provider, x.ExternalUserId }).IsUnique();
335
336 var groupsModel = modelBuilder.Entity<UserGroup>();
337 groupsModel.HasIndex(x => x.Name).IsUnique();
338 groupsModel.HasMany(x => x.Users).WithOne(x => x.Group).OnDelete(DeleteBehavior.ClientSetNull);
339
340 var permissionSetModel = modelBuilder.Entity<PermissionSet>();
341 permissionSetModel.HasOne(x => x.Group).WithOne(x => x.PermissionSet).OnDelete(DeleteBehavior.Cascade);
342 permissionSetModel.HasOne(x => x.User).WithOne(x => x.PermissionSet).OnDelete(DeleteBehavior.Cascade);
343 permissionSetModel.HasMany(x => x.InstancePermissionSets).WithOne(x => x.PermissionSet).OnDelete(DeleteBehavior.Cascade);
344
345 modelBuilder.Entity<InstancePermissionSet>().HasIndex(x => new { x.PermissionSetId, x.InstanceId }).IsUnique();
346
347 var revInfo = modelBuilder.Entity<RevisionInformation>();
348 revInfo.HasMany(x => x.ActiveTestMerges).WithOne(x => x.RevisionInformation).OnDelete(DeleteBehavior.Cascade);
349 revInfo.HasOne(x => x.PrimaryTestMerge).WithOne(x => x.PrimaryRevisionInformation).OnDelete(DeleteBehavior.Cascade);
350 revInfo.HasIndex(x => new { x.InstanceId, x.CommitSha }).IsUnique();
351
352 // IMPORTANT: When an instance is deleted (detached) it cascades into the maze of revinfo/testmerge/ritm/compilejob/job/ri relations
353 // This maze starts at revInfo and jobs
354 // jobs takes care of deleting compile jobs and ris
355 // rev info takes care of the rest
356 // Break the link here so the db doesn't shit itself complaining about cascading deletes
357 // EF will handle making the right query to destroy everything
358 // UPDATE: I fuck with this constantly in hopes of eliminating FK issues on instance detack
359 revInfo.HasMany(x => x.CompileJobs).WithOne(x => x.RevisionInformation).OnDelete(RevInfoCompileJobDeleteBehavior);
360
361 // Also break the link between ritm and testmerge so it doesn't cycle in a triangle with rev info
362 modelBuilder.Entity<TestMerge>().HasMany(x => x.RevisonInformations).WithOne(x => x.TestMerge).OnDelete(DeleteBehavior.ClientNoAction);
363
364 var compileJob = modelBuilder.Entity<CompileJob>();
365 compileJob.HasIndex(x => x.DirectoryName);
366 compileJob.HasOne(x => x.Job).WithOne().OnDelete(DeleteBehavior.Cascade);
367
368 modelBuilder.Entity<ReattachInformation>().HasOne(x => x.CompileJob).WithMany().OnDelete(DeleteBehavior.Cascade);
369
370 var chatChannel = modelBuilder.Entity<ChatChannel>();
371 chatChannel.HasIndex(x => new { x.ChatSettingsId, x.IrcChannel }).IsUnique();
372 chatChannel.HasIndex(x => new { x.ChatSettingsId, x.DiscordChannelId }).IsUnique();
373 chatChannel.HasOne(x => x.ChatSettings).WithMany(x => x.Channels).HasForeignKey(x => x.ChatSettingsId).OnDelete(DeleteBehavior.Cascade);
374
375 modelBuilder.Entity<ChatBot>().HasIndex(x => new { x.InstanceId, x.Name }).IsUnique();
376
377 var instanceModel = modelBuilder.Entity<Instance>();
378 instanceModel.HasIndex(x => new { x.Path, x.SwarmIdentifer }).IsUnique();
379 instanceModel.HasMany(x => x.ChatSettings).WithOne(x => x.Instance).OnDelete(DeleteBehavior.Cascade);
380 instanceModel.HasOne(x => x.DreamDaemonSettings).WithOne(x => x.Instance).OnDelete(DeleteBehavior.Cascade);
381 instanceModel.HasOne(x => x.DreamMakerSettings).WithOne(x => x.Instance).OnDelete(DeleteBehavior.Cascade);
382 instanceModel.HasOne(x => x.RepositorySettings).WithOne(x => x.Instance).OnDelete(DeleteBehavior.Cascade);
383 instanceModel.HasMany(x => x.RevisionInformations).WithOne(x => x.Instance).OnDelete(DeleteBehavior.Cascade);
384 instanceModel.HasMany(x => x.InstancePermissionSets).WithOne(x => x.Instance).OnDelete(DeleteBehavior.Cascade);
385 instanceModel.HasMany(x => x.Jobs).WithOne(x => x.Instance).OnDelete(DeleteBehavior.Cascade);
386 }
387
388 // HEY YOU
389 // IF YOU HAVE A TEST THAT'S CREATING ERRORS BECAUSE THESE VALUES AREN'T SET CORRECTLY THERE'S MORE TO FIXING IT THAN JUST UPDATING THEM
390 // IN THE FUNCTION BELOW YOU ALSO NEED TO CORRECTLY SET THE RIGHT MIGRATION TO DOWNGRADE TO FOR THE LAST TGS VERSION
391 // IF THIS BREAKS AGAIN I WILL PERSONALLY HAUNT YOUR ASS WHEN I DIE
392
396 internal static readonly Type MSLatestMigration = typeof(MSAddOpenDreamTopicPort);
397
401 internal static readonly Type MYLatestMigration = typeof(MYAddOpenDreamTopicPort);
402
406 internal static readonly Type PGLatestMigration = typeof(PGAddOpenDreamTopicPort);
407
411 internal static readonly Type SLLatestMigration = typeof(SLAddOpenDreamTopicPort);
412
414#pragma warning disable CA1502 // Cyclomatic complexity
415 public async ValueTask SchemaDowngradeForServerVersion(
416 ILogger<DatabaseContext> logger,
417 Version targetVersion,
418 DatabaseType currentDatabaseType,
419 CancellationToken cancellationToken)
420 {
421 ArgumentNullException.ThrowIfNull(logger);
422 ArgumentNullException.ThrowIfNull(targetVersion);
423 if (targetVersion < new Version(4, 0))
424 throw new ArgumentOutOfRangeException(nameof(targetVersion), targetVersion, "Cannot migrate below version 4.0.0!");
425
426 if (currentDatabaseType == DatabaseType.PostgresSql && targetVersion < new Version(4, 3, 0))
427 throw new NotSupportedException("Cannot migrate below version 4.3.0 with PostgresSql!");
428
429 if (currentDatabaseType == DatabaseType.MariaDB)
430 currentDatabaseType = DatabaseType.MySql; // Keeping switch expressions while avoiding `or` syntax from C#9
431
432 if (targetVersion < new Version(4, 1, 0))
433 throw new NotSupportedException("Cannot migrate below version 4.1.0!");
434
435 // Update this with new migrations as they are made
436 string? targetMigration = null;
437
438 string BadDatabaseType() => throw new ArgumentException($"Invalid DatabaseType: {currentDatabaseType}", nameof(currentDatabaseType));
439
440 if (targetVersion < new Version(6, 7, 0))
441 targetMigration = currentDatabaseType switch
442 {
443 DatabaseType.MySql => nameof(MSAddCronAutoUpdates),
444 DatabaseType.PostgresSql => nameof(PGAddCronAutoUpdates),
445 DatabaseType.SqlServer => nameof(MSAddCronAutoUpdates),
446 DatabaseType.Sqlite => nameof(SLAddCronAutoUpdates),
447 _ => BadDatabaseType(),
448 };
449
450 if (targetVersion < new Version(6, 6, 0))
451 targetMigration = currentDatabaseType switch
452 {
453 DatabaseType.MySql => nameof(MYAddCompilerAdditionalArguments),
454 DatabaseType.PostgresSql => nameof(PGAddCompilerAdditionalArguments),
455 DatabaseType.SqlServer => nameof(MSAddCompilerAdditionalArguments),
456 DatabaseType.Sqlite => nameof(SLAddCompilerAdditionalArguments),
457 _ => BadDatabaseType(),
458 };
459
460 if (targetVersion < new Version(6, 5, 0))
461 targetMigration = currentDatabaseType switch
462 {
463 DatabaseType.MySql => nameof(MYAddMinidumpsOption),
464 DatabaseType.PostgresSql => nameof(PGAddMinidumpsOption),
465 DatabaseType.SqlServer => nameof(MSAddMinidumpsOption),
466 DatabaseType.Sqlite => nameof(SLAddMinidumpsOption),
467 _ => BadDatabaseType(),
468 };
469
470 if (targetVersion < new Version(6, 2, 0))
471 targetMigration = currentDatabaseType switch
472 {
473 DatabaseType.MySql => nameof(MYAddTopicPort),
474 DatabaseType.PostgresSql => nameof(PGAddTopicPort),
475 DatabaseType.SqlServer => nameof(MSAddTopicPort),
476 DatabaseType.Sqlite => nameof(SLAddTopicPort),
477 _ => BadDatabaseType(),
478 };
479
480 if (targetVersion < new Version(6, 0, 0))
481 targetMigration = currentDatabaseType switch
482 {
483 DatabaseType.MySql => nameof(MYAddJobCodes),
484 DatabaseType.PostgresSql => nameof(PGAddJobCodes),
485 DatabaseType.SqlServer => nameof(MSAddJobCodes),
486 DatabaseType.Sqlite => nameof(SLAddJobCodes),
487 _ => BadDatabaseType(),
488 };
489 if (targetVersion < new Version(5, 17, 0))
490 targetMigration = currentDatabaseType switch
491 {
492 DatabaseType.MySql => nameof(MYAddMapThreads),
493 DatabaseType.PostgresSql => nameof(PGAddMapThreads),
494 DatabaseType.SqlServer => nameof(MSAddMapThreads),
495 DatabaseType.Sqlite => nameof(SLAddMapThreads),
496 _ => BadDatabaseType(),
497 };
498 if (targetVersion < new Version(5, 13, 0))
499 targetMigration = currentDatabaseType switch
500 {
501 DatabaseType.MySql => nameof(MYAddReattachInfoInitialCompileJob),
502 DatabaseType.PostgresSql => nameof(PGAddReattachInfoInitialCompileJob),
503 DatabaseType.SqlServer => nameof(MSAddReattachInfoInitialCompileJob),
504 DatabaseType.Sqlite => nameof(SLAddReattachInfoInitialCompileJob),
505 _ => BadDatabaseType(),
506 };
507 if (targetVersion < new Version(5, 7, 3))
508 targetMigration = currentDatabaseType switch
509 {
510 DatabaseType.MySql => nameof(MYAddDreamDaemonLogOutput),
511 DatabaseType.PostgresSql => nameof(PGAddDreamDaemonLogOutput),
512 DatabaseType.SqlServer => nameof(MSAddDreamDaemonLogOutput),
513 DatabaseType.Sqlite => nameof(SLAddDreamDaemonLogOutput),
514 _ => BadDatabaseType(),
515 };
516 if (targetVersion < new Version(5, 7, 0))
517 targetMigration = currentDatabaseType switch
518 {
519 DatabaseType.MySql => nameof(MYAddProfiler),
520 DatabaseType.PostgresSql => nameof(PGAddProfiler),
521 DatabaseType.SqlServer => nameof(MSAddProfiler),
522 DatabaseType.Sqlite => nameof(SLAddProfiler),
523 _ => BadDatabaseType(),
524 };
525 if (targetVersion < new Version(4, 19, 0))
526 targetMigration = currentDatabaseType switch
527 {
528 DatabaseType.MySql => nameof(MYAddDumpOnHeartbeatRestart),
529 DatabaseType.PostgresSql => nameof(PGAddDumpOnHeartbeatRestart),
530 DatabaseType.SqlServer => nameof(MSAddDumpOnHeartbeatRestart),
531 DatabaseType.Sqlite => nameof(SLAddDumpOnHeartbeatRestart),
532 _ => BadDatabaseType(),
533 };
534 if (targetVersion < new Version(4, 18, 0))
535 targetMigration = currentDatabaseType switch
536 {
537 DatabaseType.MySql => nameof(MYAddUpdateSubmodules),
538 DatabaseType.PostgresSql => nameof(PGAddUpdateSubmodules),
539 DatabaseType.SqlServer => nameof(MSAddUpdateSubmodules),
540 DatabaseType.Sqlite => nameof(SLAddUpdateSubmodules),
541 _ => BadDatabaseType(),
542 };
543 if (targetVersion < new Version(4, 14, 0))
544 targetMigration = currentDatabaseType switch
545 {
546 DatabaseType.MySql => nameof(MYTruncateInstanceNames),
547 DatabaseType.PostgresSql => nameof(PGTruncateInstanceNames),
548 DatabaseType.SqlServer => nameof(MSTruncateInstanceNames),
549 DatabaseType.Sqlite => nameof(SLAddRevInfoTimestamp),
550 _ => BadDatabaseType(),
551 };
552 if (targetVersion < new Version(4, 10, 0))
553 targetMigration = currentDatabaseType switch
554 {
555 DatabaseType.MySql => nameof(MSAddRevInfoTimestamp),
556 DatabaseType.PostgresSql => nameof(PGAddRevInfoTimestamp),
557 DatabaseType.SqlServer => nameof(MSAddRevInfoTimestamp),
558 DatabaseType.Sqlite => nameof(SLAddRevInfoTimestamp),
559 _ => BadDatabaseType(),
560 };
561 if (targetVersion < new Version(4, 8, 0))
562 targetMigration = currentDatabaseType switch
563 {
564 DatabaseType.MySql => nameof(MYAddSwarmIdentifer),
565 DatabaseType.PostgresSql => nameof(PGAddSwarmIdentifer),
566 DatabaseType.SqlServer => nameof(MSAddSwarmIdentifer),
567 DatabaseType.Sqlite => nameof(SLAddSwarmIdentifer),
568 _ => BadDatabaseType(),
569 };
570 if (targetVersion < new Version(4, 7, 0))
571 targetMigration = currentDatabaseType switch
572 {
573 DatabaseType.MySql => nameof(MYAddAdditionalDDParameters),
574 DatabaseType.PostgresSql => nameof(PGAddAdditionalDDParameters),
575 DatabaseType.SqlServer => nameof(MSAddAdditionalDDParameters),
576 DatabaseType.Sqlite => nameof(SLAddAdditionalDDParameters),
577 _ => BadDatabaseType(),
578 };
579 if (targetVersion < new Version(4, 6, 0))
580 targetMigration = currentDatabaseType switch
581 {
582 DatabaseType.MySql => nameof(MYAddDeploymentColumns),
583 DatabaseType.PostgresSql => nameof(PGAddDeploymentColumns),
584 DatabaseType.SqlServer => nameof(MSAddDeploymentColumns),
585 DatabaseType.Sqlite => nameof(SLAddDeploymentColumns),
586 _ => BadDatabaseType(),
587 };
588 if (targetVersion < new Version(4, 5, 0))
589 targetMigration = currentDatabaseType switch
590 {
591 DatabaseType.MySql => nameof(MYAllowNullDMApi),
592 DatabaseType.PostgresSql => nameof(PGAllowNullDMApi),
593 DatabaseType.SqlServer => nameof(MSAllowNullDMApi),
594 DatabaseType.Sqlite => nameof(SLAllowNullDMApi),
595 _ => BadDatabaseType(),
596 };
597 if (targetVersion < new Version(4, 4, 0))
598 targetMigration = currentDatabaseType switch
599 {
600 DatabaseType.MySql => nameof(MYFixForeignKey),
601 DatabaseType.PostgresSql => nameof(PGCreate),
602 DatabaseType.SqlServer => nameof(MSRemoveSoftColumns),
603 DatabaseType.Sqlite => nameof(SLRemoveSoftColumns),
604 _ => BadDatabaseType(),
605 };
606 if (targetVersion < new Version(4, 2, 0))
607 targetMigration = currentDatabaseType == DatabaseType.Sqlite ? nameof(SLRebuild) : nameof(MSFixCascadingDelete);
608
609 if (targetMigration == null)
610 {
611 logger.LogDebug("No down migration required.");
612 return;
613 }
614
615 // already setup
616 var migrationSubstitution = currentDatabaseType switch
617 {
618 DatabaseType.SqlServer => null, // already setup
619 DatabaseType.MySql => "MY{0}",
620 DatabaseType.Sqlite => "SL{0}",
621 DatabaseType.PostgresSql => "PG{0}",
622 _ => throw new InvalidOperationException($"Invalid DatabaseType: {currentDatabaseType}"),
623 };
624
625 if (migrationSubstitution != null)
626 targetMigration = String.Format(CultureInfo.InvariantCulture, migrationSubstitution, targetMigration[2..]);
627
628 // even though it clearly implements it in the DatabaseFacade definition this won't work without casting (╯ಠ益ಠ)╯︵ ┻━┻
629 var dbServiceProvider = ((IInfrastructure<IServiceProvider>)Database).Instance;
630 var migrator = dbServiceProvider.GetRequiredService<IMigrator>();
631
632 logger.LogInformation("Migrating down to version {targetVersion}. Target: {targetMigration}", targetVersion, targetMigration);
633 try
634 {
635 await migrator.MigrateAsync(targetMigration, cancellationToken);
636 }
637 catch (Exception e)
638 {
639 logger.LogCritical(e, "Failed to migrate!");
640 }
641 }
642#pragma warning restore CA1502 // Cyclomatic complexity
643 }
644}
Backend abstract implementation of IDatabaseContext.
DbSet< ReattachInformation > ReattachInformations
The ReattachInformations in the DatabaseContext.
readonly IDatabaseCollection< UserGroup > groups
Backing field for IDatabaseContext.Groups.
DbSet< Job > Jobs
The Jobs in the DatabaseContext.
DbSet< Instance > Instances
The Instances in the DatabaseContext.
readonly IDatabaseCollection< RevInfoTestMerge > revInfoTestMergesCollection
Backing field for IDatabaseContext.RevInfoTestMerges.
readonly IDatabaseCollection< DreamMakerSettings > dreamMakerSettingsCollection
Backing field for IDatabaseContext.DreamMakerSettings.
virtual DeleteBehavior RevInfoCompileJobDeleteBehavior
The DeleteBehavior for the CompileJob/RevisionInformation foreign key.
readonly IDatabaseCollection< RepositorySettings > repositorySettingsCollection
Backing field for IDatabaseContext.RepositorySettings.
DbSet< OAuthConnection > OAuthConnections
The OAuthConnections in the DatabaseContext.
readonly IDatabaseCollection< User > usersCollection
Backing field for IDatabaseContext.Users.
readonly IDatabaseCollection< Job > jobsCollection
Backing field for IDatabaseContext.Jobs.
override void OnModelCreating(ModelBuilder modelBuilder)
DbSet< ChatChannel > ChatChannels
The ChatChannels in the DatabaseContext.
DatabaseContext(DbContextOptions dbContextOptions)
Initializes a new instance of the DatabaseContext class.
readonly IDatabaseCollection< DreamDaemonSettings > dreamDaemonSettingsCollection
Backing field for IDatabaseContext.DreamDaemonSettings.
readonly IDatabaseCollection< Instance > instancesCollection
Backing field for IDatabaseContext.Instances.
DbSet< InstancePermissionSet > InstancePermissionSets
The InstancePermissionSets in the DatabaseContext.
DbSet< PermissionSet > PermissionSets
The PermissionSets in the DatabaseContext.
readonly IDatabaseCollection< ChatChannel > chatChannelsCollection
Backing field for IDatabaseContext.ChatChannels.
DbSet< CompileJob > CompileJobs
The CompileJobs in the DatabaseContext.
async ValueTask< bool > Migrate(ILogger< DatabaseContext > logger, CancellationToken cancellationToken)
Creates and migrates the IDatabaseContext.A ValueTask<TResult> resulting in true if the database shou...
readonly IDatabaseCollection< RevisionInformation > revisionInformationsCollection
Backing field for IDatabaseContext.RevisionInformations.
DbSet< TestMerge > TestMerges
The TestMerges in the DatabaseContext.
async ValueTask SchemaDowngradeForServerVersion(ILogger< DatabaseContext > logger, Version targetVersion, DatabaseType currentDatabaseType, CancellationToken cancellationToken)
Attempt to downgrade the schema to the migration used for a given server targetVersion ....
readonly IDatabaseCollection< InstancePermissionSet > instancePermissionSetsCollection
Backing field for IDatabaseContext.InstancePermissionSets.
Task Drop(CancellationToken cancellationToken)
Attempts to delete all tables and drop the database in use.A Task representing the running operation.
readonly IDatabaseCollection< ReattachInformation > reattachInformationsCollection
Backing field for IDatabaseContext.ReattachInformations.
Task Save(CancellationToken cancellationToken)
Saves changes made to the IDatabaseContext.A Task representing the running operation.
readonly IDatabaseCollection< PermissionSet > permissionSets
Backing field for IDatabaseContext.PermissionSets.
readonly IDatabaseCollection< ChatBot > chatBotsCollection
Backing field for IDatabaseContext.ChatBots.
readonly IDatabaseCollection< CompileJob > compileJobsCollection
Backing field for IDatabaseContext.CompileJobs.
DbSet< User > Users
The Users in the DatabaseContext.
DbSet< ChatBot > ChatBots
The ChatBots in the DatabaseContext.
DbSet< RevInfoTestMerge > RevInfoTestMerges
The RevInfoTestMerges in the DatabaseContext.
readonly IDatabaseCollection< OAuthConnection > oAuthConnections
Backing field for IDatabaseContext.OAuthConnections.
readonly IDatabaseCollection< TestMerge > testMergesCollection
Backing field for IDatabaseContext.TestMerges.
static Action< DbContextOptionsBuilder, DatabaseConfiguration > GetConfigureAction< TDatabaseContext >()
Gets the configure action for a given TDatabaseContext .
DbSet< RevisionInformation > RevisionInformations
The RevisionInformations in the DatabaseContext.
DbSet< UserGroup > Groups
The UserGroups in the DatabaseContext.
Adds the DreamMakerSettings DumpOnHeartbeatRestart column for MSSQL.
Adds the MapThreads DreamDaemonSettings column for MSSQL.
Adds the option to start the profiler with DreamDaemon for MSSQL.
Add the Timestamp column to RevisionInformations for MSSQL.
Update models for making the DMAPI optional for MSSQL.
Adds the DreamMakerSettings DumpOnHeartbeatRestart column for MYSQL.
Adds the MapThreads DreamDaemonSettings column for MYSQL.
Adds the option to start the profiler with DreamDaemon for MYSQL.
Update models for making the DMAPI optional for MYSQL.
Fix the CompileJob/RevisionInformation foreign key for MySQL.
Adds the DreamMakerSettings DumpOnHeartbeatRestart column for PostgresSQL.
Adds the MapThreads DreamDaemonSettings column for PostgresSQL.
Adds the option to start the profiler with DreamDaemon for PostgresSQL.
Adds the InitialCompileJobId to the ReattachInformations table for PostgresSQL.
Add the Timestamp column to RevisionInformations for PostgresSQL.
Adds the UpdateSubmodules repository setting for PostgresSQL.
Update models for making the DMAPI optional for PostgresSQL.
Adds the DreamMakerSettings DumpOnHeartbeatRestart column for SQLite.
Adds the MapThreads DreamDaemonSettings column for SQLite.
Adds the option to start the profiler with DreamDaemon for SQLite.
Add the Timestamp column to RevisionInformations for SQLite.
Update models for making the DMAPI optional for SQLite.
static void ConfigureWith(DbContextOptionsBuilder options, DatabaseConfiguration databaseConfiguration)
Configure the SqlServerDatabaseContext.
Represents an Api.Models.Instance in the database.
Definition Instance.cs:11
Database representation of Components.Session.ReattachInformation.
Represents a group of Users.
Definition UserGroup.cs:15
DatabaseType
Type of database to user.