diff --git a/src/Tgstation.Server.Host/Database/DatabaseContext.cs b/src/Tgstation.Server.Host/Database/DatabaseContext.cs
index b247660562..0bbbbabbea 100644
--- a/src/Tgstation.Server.Host/Database/DatabaseContext.cs
+++ b/src/Tgstation.Server.Host/Database/DatabaseContext.cs
@@ -195,7 +195,25 @@ namespace Tgstation.Server.Host.Database
// Update this with new migrations as they are made
// Always use the MS class
if (version < new Version(4, 0, 2))
+ {
+ // Special handling because this is where SQLite was introduced
+ if (DatabaseType == DatabaseType.Sqlite)
+ throw new NotSupportedException("Cannot migrate below version 4.0.2.0 while using Sqlite!");
+
targetMigration = nameof(MSReattachCompileJobRequired);
+ }
+
+ // Uncomment once next migration/version step happens
+ /*
+ else if (version < new Version(V_NEXT_MIGRATION))
+ {
+ // Special handling because this is where SQLite was introduced
+ if (DatabaseType == DatabaseType.Sqlite)
+ targetMigration = nameof(SLAddSqlite);
+
+ targetMigration = nameof(V_NEXT_LAST_MIGRATION);
+ }
+ */
if (targetMigration == null)
{
@@ -214,6 +232,9 @@ namespace Tgstation.Server.Host.Database
case DatabaseType.MariaDB:
migrationSubstitution = "MY{0}";
break;
+ case DatabaseType.Sqlite:
+ migrationSubstitution = "SL{0}";
+ break;
default:
throw new InvalidOperationException($"Invalid DatabaseType: {DatabaseType}");
}
diff --git a/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs
new file mode 100644
index 0000000000..501e344bbf
--- /dev/null
+++ b/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs
@@ -0,0 +1,28 @@
+using Microsoft.AspNetCore.Identity;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Design;
+using Microsoft.Extensions.Logging;
+using Tgstation.Server.Host.Models;
+using Tgstation.Server.Host.Security;
+
+namespace Tgstation.Server.Host.Database.Design
+{
+ ///
+ sealed class SqliteDesignTimeDbContextFactory : IDesignTimeDbContextFactory
+ {
+ ///
+ public SqliteDatabaseContext CreateDbContext(string[] args)
+ {
+ using (var loggerFactory = new LoggerFactory())
+ {
+ return new SqliteDatabaseContext(
+ new DbContextOptions(),
+ DesignTimeDbContextFactoryHelpers.GetDbContextOptions(),
+ new DatabaseSeeder(
+ new CryptographySuite(
+ new PasswordHasher())),
+ loggerFactory.CreateLogger());
+ }
+ }
+ }
+}
diff --git a/src/Tgstation.Server.Host/Database/Migrations/20200322210825_SLAddSqlite.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20200322210825_SLAddSqlite.Designer.cs
new file mode 100644
index 0000000000..e624e85408
--- /dev/null
+++ b/src/Tgstation.Server.Host/Database/Migrations/20200322210825_SLAddSqlite.Designer.cs
@@ -0,0 +1,653 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Tgstation.Server.Host.Database.Migrations
+{
+ [DbContext(typeof(SqliteDatabaseContext))]
+ [Migration("20200322210825_SLAddSqlite")]
+ partial class SLAddSqlite
+ {
+ ///
+ /// Builds the target model
+ ///
+ /// The to use
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ConnectionString")
+ .IsRequired();
+
+ b.Property("Enabled");
+
+ b.Property("InstanceId");
+
+ b.Property("Name")
+ .IsRequired();
+
+ b.Property("Provider");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InstanceId");
+
+ b.HasIndex("Name")
+ .IsUnique();
+
+ b.ToTable("ChatBots");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ChatSettingsId");
+
+ b.Property("DiscordChannelId");
+
+ b.Property("IrcChannel");
+
+ b.Property("IsAdminChannel")
+ .IsRequired();
+
+ b.Property("IsUpdatesChannel")
+ .IsRequired();
+
+ b.Property("IsWatchdogChannel")
+ .IsRequired();
+
+ b.Property("Tag");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ChatSettingsId", "DiscordChannelId")
+ .IsUnique();
+
+ b.HasIndex("ChatSettingsId", "IrcChannel")
+ .IsUnique();
+
+ b.ToTable("ChatChannels");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ByondVersion")
+ .IsRequired();
+
+ b.Property("DirectoryName")
+ .IsRequired();
+
+ b.Property("DmeName")
+ .IsRequired();
+
+ b.Property("JobId");
+
+ b.Property("MinimumSecurityLevel");
+
+ b.Property("Output")
+ .IsRequired();
+
+ b.Property("RevisionInformationId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("DirectoryName");
+
+ b.HasIndex("JobId")
+ .IsUnique();
+
+ b.HasIndex("RevisionInformationId");
+
+ b.ToTable("CompileJobs");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AccessToken");
+
+ b.Property("AllowWebClient")
+ .IsRequired();
+
+ b.Property("AutoStart")
+ .IsRequired();
+
+ b.Property("InstanceId");
+
+ b.Property("PrimaryPort")
+ .IsRequired();
+
+ b.Property("ProcessId");
+
+ b.Property("SecondaryPort")
+ .IsRequired();
+
+ b.Property("SecurityLevel");
+
+ b.Property("SoftRestart")
+ .IsRequired();
+
+ b.Property("SoftShutdown")
+ .IsRequired();
+
+ b.Property("StartupTimeout")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasIndex("InstanceId")
+ .IsUnique();
+
+ b.ToTable("DreamDaemonSettings");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ApiValidationPort")
+ .IsRequired();
+
+ b.Property("ApiValidationSecurityLevel");
+
+ b.Property("InstanceId");
+
+ b.Property("ProjectName");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InstanceId")
+ .IsUnique();
+
+ b.ToTable("DreamMakerSettings");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AutoUpdateInterval")
+ .IsRequired();
+
+ b.Property("ConfigurationType");
+
+ b.Property("Name")
+ .IsRequired();
+
+ b.Property("Online")
+ .IsRequired();
+
+ b.Property("Path")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasIndex("Path")
+ .IsUnique();
+
+ b.ToTable("Instances");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.InstanceUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ByondRights");
+
+ b.Property("ChatBotRights");
+
+ b.Property("ConfigurationRights");
+
+ b.Property("DreamDaemonRights");
+
+ b.Property("DreamMakerRights");
+
+ b.Property("InstanceId");
+
+ b.Property("InstanceUserRights");
+
+ b.Property("RepositoryRights");
+
+ b.Property("UserId")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasIndex("InstanceId");
+
+ b.HasIndex("UserId", "InstanceId")
+ .IsUnique();
+
+ b.ToTable("InstanceUsers");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("CancelRight");
+
+ b.Property("CancelRightsType");
+
+ b.Property("Cancelled")
+ .IsRequired();
+
+ b.Property("CancelledById");
+
+ b.Property("Description")
+ .IsRequired();
+
+ b.Property("ExceptionDetails");
+
+ b.Property("InstanceId");
+
+ b.Property("StartedAt")
+ .IsRequired();
+
+ b.Property("StartedById");
+
+ b.Property("StoppedAt");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CancelledById");
+
+ b.HasIndex("InstanceId");
+
+ b.HasIndex("StartedById");
+
+ b.ToTable("Jobs");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AccessIdentifier")
+ .IsRequired();
+
+ b.Property("ChatChannelsJson")
+ .IsRequired();
+
+ b.Property("ChatCommandsJson")
+ .IsRequired();
+
+ b.Property("CompileJobId");
+
+ b.Property("IsPrimary");
+
+ b.Property("Port");
+
+ b.Property("ProcessId");
+
+ b.Property("RebootState");
+
+ b.Property("ServerCommandsJson")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasIndex("CompileJobId");
+
+ b.ToTable("ReattachInformations");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AccessToken");
+
+ b.Property("AccessUser");
+
+ b.Property("AutoUpdatesKeepTestMerges")
+ .IsRequired();
+
+ b.Property("AutoUpdatesSynchronize")
+ .IsRequired();
+
+ b.Property("CommitterEmail")
+ .IsRequired();
+
+ b.Property("CommitterName")
+ .IsRequired();
+
+ b.Property("InstanceId");
+
+ b.Property("PostTestMergeComment")
+ .IsRequired();
+
+ b.Property("PushTestMergeCommits")
+ .IsRequired();
+
+ b.Property("ShowTestMergeCommitters")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasIndex("InstanceId")
+ .IsUnique();
+
+ b.ToTable("RepositorySettings");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.RevInfoTestMerge", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("RevisionInformationId");
+
+ b.Property("TestMergeId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RevisionInformationId");
+
+ b.HasIndex("TestMergeId");
+
+ b.ToTable("RevInfoTestMerges");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("CommitSha")
+ .IsRequired()
+ .HasMaxLength(40);
+
+ b.Property("InstanceId");
+
+ b.Property("OriginCommitSha")
+ .IsRequired()
+ .HasMaxLength(40);
+
+ b.HasKey("Id");
+
+ b.HasIndex("InstanceId", "CommitSha")
+ .IsUnique();
+
+ b.ToTable("RevisionInformations");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("Author")
+ .IsRequired();
+
+ b.Property("BodyAtMerge")
+ .IsRequired();
+
+ b.Property("Comment");
+
+ b.Property("MergedAt");
+
+ b.Property("MergedById");
+
+ b.Property("Number")
+ .IsRequired();
+
+ b.Property("PrimaryRevisionInformationId")
+ .IsRequired();
+
+ b.Property("PullRequestRevision")
+ .IsRequired();
+
+ b.Property("TitleAtMerge")
+ .IsRequired();
+
+ b.Property("Url")
+ .IsRequired();
+
+ b.HasKey("Id");
+
+ b.HasIndex("MergedById");
+
+ b.HasIndex("PrimaryRevisionInformationId")
+ .IsUnique();
+
+ b.ToTable("TestMerges");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AdministrationRights");
+
+ b.Property("CanonicalName")
+ .IsRequired();
+
+ b.Property("CreatedAt")
+ .IsRequired();
+
+ b.Property("CreatedById");
+
+ b.Property("Enabled")
+ .IsRequired();
+
+ b.Property("InstanceManagerRights");
+
+ b.Property("LastPasswordUpdate");
+
+ b.Property("Name")
+ .IsRequired();
+
+ b.Property("PasswordHash");
+
+ b.Property("SystemIdentifier");
+
+ b.HasKey("Id");
+
+ b.HasIndex("CanonicalName")
+ .IsUnique();
+
+ b.HasIndex("CreatedById");
+
+ b.ToTable("Users");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.WatchdogReattachInformation", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("AlphaId");
+
+ b.Property("AlphaIsActive");
+
+ b.Property("BravoId");
+
+ b.Property("InstanceId");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AlphaId");
+
+ b.HasIndex("BravoId");
+
+ b.HasIndex("InstanceId")
+ .IsUnique();
+
+ b.ToTable("WatchdogReattachInformations");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
+ .WithMany("ChatSettings")
+ .HasForeignKey("InstanceId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.ChatBot", "ChatSettings")
+ .WithMany("Channels")
+ .HasForeignKey("ChatSettingsId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.Job", "Job")
+ .WithOne()
+ .HasForeignKey("Tgstation.Server.Host.Models.CompileJob", "JobId")
+ .OnDelete(DeleteBehavior.Restrict);
+
+ b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation")
+ .WithMany("CompileJobs")
+ .HasForeignKey("RevisionInformationId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
+ .WithOne("DreamDaemonSettings")
+ .HasForeignKey("Tgstation.Server.Host.Models.DreamDaemonSettings", "InstanceId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
+ .WithOne("DreamMakerSettings")
+ .HasForeignKey("Tgstation.Server.Host.Models.DreamMakerSettings", "InstanceId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.InstanceUser", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
+ .WithMany("InstanceUsers")
+ .HasForeignKey("InstanceId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("Tgstation.Server.Host.Models.User")
+ .WithMany("InstanceUsers")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.User", "CancelledBy")
+ .WithMany()
+ .HasForeignKey("CancelledById");
+
+ b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
+ .WithMany("Jobs")
+ .HasForeignKey("InstanceId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("Tgstation.Server.Host.Models.User", "StartedBy")
+ .WithMany()
+ .HasForeignKey("StartedById")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.CompileJob", "CompileJob")
+ .WithMany()
+ .HasForeignKey("CompileJobId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
+ .WithOne("RepositorySettings")
+ .HasForeignKey("Tgstation.Server.Host.Models.RepositorySettings", "InstanceId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.RevInfoTestMerge", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation")
+ .WithMany("ActiveTestMerges")
+ .HasForeignKey("RevisionInformationId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.HasOne("Tgstation.Server.Host.Models.TestMerge", "TestMerge")
+ .WithMany("RevisonInformations")
+ .HasForeignKey("TestMergeId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
+ .WithMany("RevisionInformations")
+ .HasForeignKey("InstanceId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.User", "MergedBy")
+ .WithMany("TestMerges")
+ .HasForeignKey("MergedById")
+ .OnDelete(DeleteBehavior.Restrict);
+
+ b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "PrimaryRevisionInformation")
+ .WithOne("PrimaryTestMerge")
+ .HasForeignKey("Tgstation.Server.Host.Models.TestMerge", "PrimaryRevisionInformationId")
+ .OnDelete(DeleteBehavior.Restrict);
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.User", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.User", "CreatedBy")
+ .WithMany("CreatedUsers")
+ .HasForeignKey("CreatedById");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.WatchdogReattachInformation", b =>
+ {
+ b.HasOne("Tgstation.Server.Host.Models.ReattachInformation", "Alpha")
+ .WithMany()
+ .HasForeignKey("AlphaId");
+
+ b.HasOne("Tgstation.Server.Host.Models.ReattachInformation", "Bravo")
+ .WithMany()
+ .HasForeignKey("BravoId");
+
+ b.HasOne("Tgstation.Server.Host.Models.Instance")
+ .WithOne("WatchdogReattachInformation")
+ .HasForeignKey("Tgstation.Server.Host.Models.WatchdogReattachInformation", "InstanceId")
+ .OnDelete(DeleteBehavior.Cascade);
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/Tgstation.Server.Host/Database/Migrations/20200322210825_SLAddSqlite.cs b/src/Tgstation.Server.Host/Database/Migrations/20200322210825_SLAddSqlite.cs
new file mode 100644
index 0000000000..99872e864c
--- /dev/null
+++ b/src/Tgstation.Server.Host/Database/Migrations/20200322210825_SLAddSqlite.cs
@@ -0,0 +1,639 @@
+// Suppress the too much class coupling warning
+#pragma warning disable CA1506
+
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Tgstation.Server.Host.Database.Migrations
+{
+ ///
+ /// Initial migration for SQLite.
+ ///
+ public partial class SLAddSqlite : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ if (migrationBuilder == null)
+ throw new ArgumentNullException(nameof(migrationBuilder));
+
+ migrationBuilder.CreateTable(
+ name: "Instances",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Name = table.Column(nullable: false),
+ Path = table.Column(nullable: false),
+ Online = table.Column(nullable: false),
+ ConfigurationType = table.Column(nullable: false),
+ AutoUpdateInterval = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Instances", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Users",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Enabled = table.Column(nullable: false),
+ CreatedAt = table.Column(nullable: false),
+ SystemIdentifier = table.Column(nullable: true),
+ Name = table.Column(nullable: false),
+ AdministrationRights = table.Column(nullable: false),
+ InstanceManagerRights = table.Column(nullable: false),
+ PasswordHash = table.Column(nullable: true),
+ CreatedById = table.Column(nullable: true),
+ CanonicalName = table.Column(nullable: false),
+ LastPasswordUpdate = table.Column(nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Users", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Users_Users_CreatedById",
+ column: x => x.CreatedById,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "ChatBots",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Name = table.Column(nullable: false),
+ Enabled = table.Column(nullable: true),
+ Provider = table.Column(nullable: true),
+ ConnectionString = table.Column(nullable: false),
+ InstanceId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ChatBots", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ChatBots_Instances_InstanceId",
+ column: x => x.InstanceId,
+ principalTable: "Instances",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "DreamDaemonSettings",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ AllowWebClient = table.Column(nullable: false),
+ SecurityLevel = table.Column(nullable: false),
+ PrimaryPort = table.Column(nullable: false),
+ SecondaryPort = table.Column(nullable: false),
+ StartupTimeout = table.Column(nullable: false),
+ AutoStart = table.Column(nullable: false),
+ SoftRestart = table.Column(nullable: false),
+ SoftShutdown = table.Column(nullable: false),
+ ProcessId = table.Column(nullable: true),
+ AccessToken = table.Column(nullable: true),
+ InstanceId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_DreamDaemonSettings", x => x.Id);
+ table.ForeignKey(
+ name: "FK_DreamDaemonSettings_Instances_InstanceId",
+ column: x => x.InstanceId,
+ principalTable: "Instances",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "DreamMakerSettings",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ ProjectName = table.Column(nullable: true),
+ ApiValidationPort = table.Column(nullable: false),
+ ApiValidationSecurityLevel = table.Column(nullable: false),
+ InstanceId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_DreamMakerSettings", x => x.Id);
+ table.ForeignKey(
+ name: "FK_DreamMakerSettings_Instances_InstanceId",
+ column: x => x.InstanceId,
+ principalTable: "Instances",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "RepositorySettings",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ CommitterName = table.Column(nullable: false),
+ CommitterEmail = table.Column(nullable: false),
+ AccessUser = table.Column(nullable: true),
+ AccessToken = table.Column(nullable: true),
+ PushTestMergeCommits = table.Column(nullable: false),
+ ShowTestMergeCommitters = table.Column(nullable: false),
+ AutoUpdatesKeepTestMerges = table.Column(nullable: false),
+ AutoUpdatesSynchronize = table.Column(nullable: false),
+ PostTestMergeComment = table.Column(nullable: false),
+ InstanceId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_RepositorySettings", x => x.Id);
+ table.ForeignKey(
+ name: "FK_RepositorySettings_Instances_InstanceId",
+ column: x => x.InstanceId,
+ principalTable: "Instances",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "RevisionInformations",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ CommitSha = table.Column(maxLength: 40, nullable: false),
+ OriginCommitSha = table.Column(maxLength: 40, nullable: false),
+ InstanceId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_RevisionInformations", x => x.Id);
+ table.ForeignKey(
+ name: "FK_RevisionInformations_Instances_InstanceId",
+ column: x => x.InstanceId,
+ principalTable: "Instances",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "InstanceUsers",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ UserId = table.Column(nullable: false),
+ InstanceUserRights = table.Column(nullable: false),
+ ByondRights = table.Column(nullable: false),
+ DreamDaemonRights = table.Column(nullable: false),
+ DreamMakerRights = table.Column(nullable: false),
+ RepositoryRights = table.Column(nullable: false),
+ ChatBotRights = table.Column(nullable: false),
+ ConfigurationRights = table.Column(nullable: false),
+ InstanceId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_InstanceUsers", x => x.Id);
+ table.ForeignKey(
+ name: "FK_InstanceUsers_Instances_InstanceId",
+ column: x => x.InstanceId,
+ principalTable: "Instances",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_InstanceUsers_Users_UserId",
+ column: x => x.UserId,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Jobs",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Description = table.Column(nullable: false),
+ ExceptionDetails = table.Column(nullable: true),
+ StartedAt = table.Column(nullable: false),
+ StoppedAt = table.Column(nullable: true),
+ Cancelled = table.Column(nullable: false),
+ CancelRightsType = table.Column(nullable: true),
+ CancelRight = table.Column(nullable: true),
+ StartedById = table.Column(nullable: false),
+ CancelledById = table.Column(nullable: true),
+ InstanceId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Jobs", x => x.Id);
+ table.ForeignKey(
+ name: "FK_Jobs_Users_CancelledById",
+ column: x => x.CancelledById,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ table.ForeignKey(
+ name: "FK_Jobs_Instances_InstanceId",
+ column: x => x.InstanceId,
+ principalTable: "Instances",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_Jobs_Users_StartedById",
+ column: x => x.StartedById,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "ChatChannels",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ IrcChannel = table.Column(nullable: true),
+ DiscordChannelId = table.Column(nullable: true),
+ IsAdminChannel = table.Column(nullable: false),
+ IsWatchdogChannel = table.Column(nullable: false),
+ IsUpdatesChannel = table.Column(nullable: false),
+ Tag = table.Column(nullable: true),
+ ChatSettingsId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ChatChannels", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ChatChannels_ChatBots_ChatSettingsId",
+ column: x => x.ChatSettingsId,
+ principalTable: "ChatBots",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "TestMerges",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Number = table.Column(nullable: false),
+ PullRequestRevision = table.Column(nullable: false),
+ Comment = table.Column(nullable: true),
+ TitleAtMerge = table.Column(nullable: false),
+ BodyAtMerge = table.Column(nullable: false),
+ Url = table.Column(nullable: false),
+ Author = table.Column(nullable: false),
+ MergedAt = table.Column(nullable: false),
+ MergedById = table.Column(nullable: false),
+ PrimaryRevisionInformationId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_TestMerges", x => x.Id);
+ table.ForeignKey(
+ name: "FK_TestMerges_Users_MergedById",
+ column: x => x.MergedById,
+ principalTable: "Users",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ table.ForeignKey(
+ name: "FK_TestMerges_RevisionInformations_PrimaryRevisionInformationId",
+ column: x => x.PrimaryRevisionInformationId,
+ principalTable: "RevisionInformations",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "CompileJobs",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ DmeName = table.Column(nullable: false),
+ Output = table.Column(nullable: false),
+ DirectoryName = table.Column(nullable: false),
+ MinimumSecurityLevel = table.Column(nullable: false),
+ JobId = table.Column(nullable: false),
+ RevisionInformationId = table.Column(nullable: false),
+ ByondVersion = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_CompileJobs", x => x.Id);
+ table.ForeignKey(
+ name: "FK_CompileJobs_Jobs_JobId",
+ column: x => x.JobId,
+ principalTable: "Jobs",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ table.ForeignKey(
+ name: "FK_CompileJobs_RevisionInformations_RevisionInformationId",
+ column: x => x.RevisionInformationId,
+ principalTable: "RevisionInformations",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "RevInfoTestMerges",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ TestMergeId = table.Column(nullable: false),
+ RevisionInformationId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_RevInfoTestMerges", x => x.Id);
+ table.ForeignKey(
+ name: "FK_RevInfoTestMerges_RevisionInformations_RevisionInformationId",
+ column: x => x.RevisionInformationId,
+ principalTable: "RevisionInformations",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_RevInfoTestMerges_TestMerges_TestMergeId",
+ column: x => x.TestMergeId,
+ principalTable: "TestMerges",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "ReattachInformations",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ ChatCommandsJson = table.Column(nullable: false),
+ ChatChannelsJson = table.Column(nullable: false),
+ ServerCommandsJson = table.Column(nullable: false),
+ AccessIdentifier = table.Column(nullable: false),
+ ProcessId = table.Column(nullable: false),
+ IsPrimary = table.Column(nullable: false),
+ Port = table.Column(nullable: false),
+ RebootState = table.Column(nullable: false),
+ CompileJobId = table.Column(nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ReattachInformations", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ReattachInformations_CompileJobs_CompileJobId",
+ column: x => x.CompileJobId,
+ principalTable: "CompileJobs",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "WatchdogReattachInformations",
+ columns: table => new
+ {
+ Id = table.Column(nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ AlphaIsActive = table.Column(nullable: false),
+ InstanceId = table.Column(nullable: false),
+ AlphaId = table.Column(nullable: true),
+ BravoId = table.Column(nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_WatchdogReattachInformations", x => x.Id);
+ table.ForeignKey(
+ name: "FK_WatchdogReattachInformations_ReattachInformations_AlphaId",
+ column: x => x.AlphaId,
+ principalTable: "ReattachInformations",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ table.ForeignKey(
+ name: "FK_WatchdogReattachInformations_ReattachInformations_BravoId",
+ column: x => x.BravoId,
+ principalTable: "ReattachInformations",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Restrict);
+ table.ForeignKey(
+ name: "FK_WatchdogReattachInformations_Instances_InstanceId",
+ column: x => x.InstanceId,
+ principalTable: "Instances",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ChatBots_InstanceId",
+ table: "ChatBots",
+ column: "InstanceId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ChatBots_Name",
+ table: "ChatBots",
+ column: "Name",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ChatChannels_ChatSettingsId_DiscordChannelId",
+ table: "ChatChannels",
+ columns: new[] { "ChatSettingsId", "DiscordChannelId" },
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ChatChannels_ChatSettingsId_IrcChannel",
+ table: "ChatChannels",
+ columns: new[] { "ChatSettingsId", "IrcChannel" },
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_CompileJobs_DirectoryName",
+ table: "CompileJobs",
+ column: "DirectoryName");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_CompileJobs_JobId",
+ table: "CompileJobs",
+ column: "JobId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_CompileJobs_RevisionInformationId",
+ table: "CompileJobs",
+ column: "RevisionInformationId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_DreamDaemonSettings_InstanceId",
+ table: "DreamDaemonSettings",
+ column: "InstanceId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_DreamMakerSettings_InstanceId",
+ table: "DreamMakerSettings",
+ column: "InstanceId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Instances_Path",
+ table: "Instances",
+ column: "Path",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_InstanceUsers_InstanceId",
+ table: "InstanceUsers",
+ column: "InstanceId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_InstanceUsers_UserId_InstanceId",
+ table: "InstanceUsers",
+ columns: new[] { "UserId", "InstanceId" },
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Jobs_CancelledById",
+ table: "Jobs",
+ column: "CancelledById");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Jobs_InstanceId",
+ table: "Jobs",
+ column: "InstanceId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Jobs_StartedById",
+ table: "Jobs",
+ column: "StartedById");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ReattachInformations_CompileJobId",
+ table: "ReattachInformations",
+ column: "CompileJobId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_RepositorySettings_InstanceId",
+ table: "RepositorySettings",
+ column: "InstanceId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_RevInfoTestMerges_RevisionInformationId",
+ table: "RevInfoTestMerges",
+ column: "RevisionInformationId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_RevInfoTestMerges_TestMergeId",
+ table: "RevInfoTestMerges",
+ column: "TestMergeId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_RevisionInformations_InstanceId_CommitSha",
+ table: "RevisionInformations",
+ columns: new[] { "InstanceId", "CommitSha" },
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TestMerges_MergedById",
+ table: "TestMerges",
+ column: "MergedById");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_TestMerges_PrimaryRevisionInformationId",
+ table: "TestMerges",
+ column: "PrimaryRevisionInformationId",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Users_CanonicalName",
+ table: "Users",
+ column: "CanonicalName",
+ unique: true);
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Users_CreatedById",
+ table: "Users",
+ column: "CreatedById");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_WatchdogReattachInformations_AlphaId",
+ table: "WatchdogReattachInformations",
+ column: "AlphaId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_WatchdogReattachInformations_BravoId",
+ table: "WatchdogReattachInformations",
+ column: "BravoId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_WatchdogReattachInformations_InstanceId",
+ table: "WatchdogReattachInformations",
+ column: "InstanceId",
+ unique: true);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ if (migrationBuilder == null)
+ throw new ArgumentNullException(nameof(migrationBuilder));
+
+ migrationBuilder.DropTable(
+ name: "ChatChannels");
+
+ migrationBuilder.DropTable(
+ name: "DreamDaemonSettings");
+
+ migrationBuilder.DropTable(
+ name: "DreamMakerSettings");
+
+ migrationBuilder.DropTable(
+ name: "InstanceUsers");
+
+ migrationBuilder.DropTable(
+ name: "RepositorySettings");
+
+ migrationBuilder.DropTable(
+ name: "RevInfoTestMerges");
+
+ migrationBuilder.DropTable(
+ name: "WatchdogReattachInformations");
+
+ migrationBuilder.DropTable(
+ name: "ChatBots");
+
+ migrationBuilder.DropTable(
+ name: "TestMerges");
+
+ migrationBuilder.DropTable(
+ name: "ReattachInformations");
+
+ migrationBuilder.DropTable(
+ name: "CompileJobs");
+
+ migrationBuilder.DropTable(
+ name: "Jobs");
+
+ migrationBuilder.DropTable(
+ name: "RevisionInformations");
+
+ migrationBuilder.DropTable(
+ name: "Users");
+
+ migrationBuilder.DropTable(
+ name: "Instances");
+ }
+ }
+}
diff --git a/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs b/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs
new file mode 100644
index 0000000000..394bbd016d
--- /dev/null
+++ b/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs
@@ -0,0 +1,649 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Tgstation.Server.Host.Database;
+
+namespace Tgstation.Server.Host.Migrations
+{
+ [DbContext(typeof(SqliteDatabaseContext))]
+ partial class SqliteDatabaseContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "2.2.6-servicing-10079");
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ConnectionString")
+ .IsRequired();
+
+ b.Property("Enabled");
+
+ b.Property("InstanceId");
+
+ b.Property("Name")
+ .IsRequired();
+
+ b.Property("Provider");
+
+ b.HasKey("Id");
+
+ b.HasIndex("InstanceId");
+
+ b.HasIndex("Name")
+ .IsUnique();
+
+ b.ToTable("ChatBots");
+ });
+
+ modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd();
+
+ b.Property("ChatSettingsId");
+
+ b.Property