Add migrations

MySQL currently unsupported due to https://bugs.mysql.com/bug.php?id=89855
This commit is contained in:
Cyberboss
2018-04-10 16:48:23 -04:00
parent 1d329c1605
commit aba5e114bc
19 changed files with 3339 additions and 63 deletions
+1
View File
@@ -11,3 +11,4 @@ artifacts/
*DS_Store
*.sln.ide
/TestResults
/src/Tgstation.Server.Host/appsettings.Development.json
@@ -2,6 +2,7 @@
{
sealed class DatabaseConfiguration
{
public const string Section = "Database";
public DatabaseType DatabaseType { get; set; }
public string ConnectionString { get; set; }
}
+40 -9
View File
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
@@ -22,11 +23,21 @@ namespace Tgstation.Server.Host.Core
/// </summary>
readonly IConfiguration configuration;
/// <summary>
/// The <see cref="IHostingEnvironment"/> for the <see cref="Application"/>
/// </summary>
readonly IHostingEnvironment hostingEnvironment;
/// <summary>
/// Construct an <see cref="Application"/>
/// </summary>
/// <param name="configuration">The value of <see cref="configuration"/></param>
public Application(IConfiguration configuration) => this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
/// <param name="hostingEnvironment">The value of <see cref="hostingEnvironment"/></param>
public Application(IConfiguration configuration, IHostingEnvironment hostingEnvironment)
{
this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
this.hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
}
/// <summary>
/// Configure dependency injected services
@@ -39,15 +50,38 @@ namespace Tgstation.Server.Host.Core
if (services == null)
throw new ArgumentNullException(nameof(services));
var workingDir = Environment.CurrentDirectory;
services.Configure<DatabaseConfiguration>(configuration.GetSection("Database"));
var databaseConfigurationSection = configuration.GetSection(DatabaseConfiguration.Section);
services.Configure<DatabaseConfiguration>(databaseConfigurationSection);
services.AddMvc();
services.AddOptions();
services.AddLocalization();
var databaseConfiguration = databaseConfigurationSection.Get<DatabaseConfiguration>();
void ConfigureDatabase(DbContextOptionsBuilder builder)
{
if (hostingEnvironment.IsDevelopment())
builder.EnableSensitiveDataLogging();
};
services.AddDbContext<DatabaseContext>();
services.AddScoped<IDatabaseContext>(x => x.GetRequiredService<DatabaseContext>());
switch (databaseConfiguration.DatabaseType)
{
case DatabaseType.MySql:
services.AddDbContext<MySqlDatabaseContext>(ConfigureDatabase);
services.AddScoped<IDatabaseContext>(x => x.GetRequiredService<MySqlDatabaseContext>());
break;
case DatabaseType.Sqlite:
services.AddDbContext<SqliteDatabaseContext>(ConfigureDatabase);
services.AddScoped<IDatabaseContext>(x => x.GetRequiredService<SqliteDatabaseContext>());
break;
case DatabaseType.SqlServer:
services.AddDbContext<SqlServerDatabaseContext>(ConfigureDatabase);
services.AddScoped<IDatabaseContext>(x => x.GetRequiredService<SqlServerDatabaseContext>());
break;
default:
throw new InvalidOperationException("Invalid DatabaseType!");
}
services.AddSingleton<ICryptographySuite, CryptographySuite>();
services.AddSingleton<IDatabaseSeeder, DatabaseSeeder>();
services.AddSingleton<IPasswordHasher<User>, PasswordHasher<User>>();
@@ -57,13 +91,10 @@ namespace Tgstation.Server.Host.Core
/// Configure the <see cref="Application"/>
/// </summary>
/// <param name="applicationBuilder">The <see cref="IApplicationBuilder"/> to configure</param>
/// <param name="hostingEnvironment">The <see cref="IHostingEnvironment"/> of the <see cref="Application"/></param>
public void Configure(IApplicationBuilder applicationBuilder, IHostingEnvironment hostingEnvironment)
public void Configure(IApplicationBuilder applicationBuilder)
{
if (applicationBuilder == null)
throw new ArgumentNullException(nameof(applicationBuilder));
if (hostingEnvironment == null)
throw new ArgumentNullException(nameof(hostingEnvironment));
if (hostingEnvironment.IsDevelopment())
applicationBuilder.UseDeveloperExceptionPage();
@@ -1,21 +1,17 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Tgstation.Server.Api.Models;
using Tgstation.Server.Api.Rights;
using Tgstation.Server.Host.Configuration;
using Tgstation.Server.Host.Core;
using ZNetCS.AspNetCore.Logging.EntityFrameworkCore;
namespace Tgstation.Server.Host.Models
{
sealed class DatabaseContext : DbContext, IDatabaseContext
/// <inheritdoc />
abstract class DatabaseContext<TParentContext> : DbContext, IDatabaseContext where TParentContext : DbContext
{
/// <inheritdoc />
public DbSet<ServerSettings> ServerSettings { get; set; }
@@ -41,6 +37,11 @@ namespace Tgstation.Server.Host.Models
public DbSet<RevisionInformation> RevisionInformations { get; set; }
public DbSet<RepositorySettings> RepositorySettings { get; set; }
/// <summary>
/// The connection string for the <see cref="DatabaseContext"/>
/// </summary>
protected string ConnectionString => databaseConfiguration.ConnectionString;
/// <summary>
/// The <see cref="DatabaseConfiguration"/> for the <see cref="DatabaseContext"/>
/// </summary>
@@ -50,10 +51,6 @@ namespace Tgstation.Server.Host.Models
/// </summary>
readonly ILoggerFactory loggerFactory;
/// <summary>
/// The <see cref="IHostingEnvironment"/> for the <see cref="DatabaseContext"/>
/// </summary>
readonly IHostingEnvironment hostingEnvironment;
/// <summary>
/// The <see cref="IDatabaseSeeder"/> for the <see cref="DatabaseContext"/>
/// </summary>
readonly IDatabaseSeeder databaseSeeder;
@@ -61,16 +58,14 @@ namespace Tgstation.Server.Host.Models
/// <summary>
/// Construct a <see cref="DatabaseContext"/>
/// </summary>
/// <param name="dbContextOptions">The <see cref="DbContextOptions{TContext}"/> for the <see cref="DatabaseContext"/></param>
/// <param name="dbContextOptions">The <see cref="DbContextOptions{TContext}"/> for the <see cref="DatabaseContext{TParentContext}"/></param>
/// <param name="databaseConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="databaseConfiguration"/></param>
/// <param name="loggerFactory">The value of <see cref="loggerFactory"/></param>
/// <param name="hostingEnvironment">The value of <see cref="hostingEnvironment"/></param>
/// <param name="databaseSeeder">The value of <see cref="databaseSeeder"/></param>
public DatabaseContext(DbContextOptions<DatabaseContext> dbContextOptions, IOptions<DatabaseConfiguration> databaseConfigurationOptions, ILoggerFactory loggerFactory, IHostingEnvironment hostingEnvironment, IDatabaseSeeder databaseSeeder) : base(dbContextOptions)
public DatabaseContext(DbContextOptions<TParentContext> dbContextOptions, IOptions<DatabaseConfiguration> databaseConfigurationOptions, ILoggerFactory loggerFactory, IDatabaseSeeder databaseSeeder) : base(dbContextOptions)
{
databaseConfiguration = databaseConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(databaseConfigurationOptions));
this.loggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
this.hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
this.databaseSeeder = databaseSeeder ?? throw new ArgumentNullException(nameof(databaseSeeder));
}
@@ -90,21 +85,9 @@ namespace Tgstation.Server.Host.Models
/// <inheritdoc />
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
switch (databaseConfiguration.DatabaseType)
{
case DatabaseType.MySql:
optionsBuilder.UseMySQL(databaseConfiguration.ConnectionString);
break;
case DatabaseType.Sqlite:
optionsBuilder.UseSqlite(databaseConfiguration.ConnectionString);
break;
case DatabaseType.SqlServer:
optionsBuilder.UseSqlServer(databaseConfiguration.ConnectionString);
break;
}
base.OnConfiguring(optionsBuilder);
optionsBuilder.UseLoggerFactory(loggerFactory);
if (hostingEnvironment.IsDevelopment())
optionsBuilder.EnableSensitiveDataLogging();
}
/// <inheritdoc />
@@ -0,0 +1,29 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Options;
using System.IO;
using System.Reflection;
using Tgstation.Server.Host.Configuration;
namespace Tgstation.Server.Host.Models.Migrations
{
/// <summary>
/// Contains helpers for creating design time <see cref="Models.DatabaseContext"/>s
/// </summary>
static class DesignTimeDbContextFactoryHelpers
{
/// <summary>
/// Path to the json file to use for migrations configuration
/// </summary>
const string MigrationsJson = "appsettings.Development.json";
/// <inheritdoc />
public static IOptions<DatabaseConfiguration> GetDbContextOptions()
{
var builder = new ConfigurationBuilder();
builder.SetBasePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
builder.AddJsonFile(MigrationsJson);
var configuration = builder.Build();
return Options.Create(configuration.GetSection(DatabaseConfiguration.Section).Get<DatabaseConfiguration>());
}
}
}
@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Logging;
using Tgstation.Server.Host.Core;
namespace Tgstation.Server.Host.Models.Migrations
{
/// <inheritdoc />
sealed class MySqlDesignTimeDbContextFactory : IDesignTimeDbContextFactory<MySqlDatabaseContext>
{
/// <inheritdoc />
public MySqlDatabaseContext CreateDbContext(string[] args) => new MySqlDatabaseContext(new DbContextOptions<MySqlDatabaseContext>(), DesignTimeDbContextFactoryHelpers.GetDbContextOptions(), new LoggerFactory(), new DatabaseSeeder(new CryptographySuite(new PasswordHasher<User>())));
}
}
@@ -0,0 +1,512 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Migrations;
using Tgstation.Server.Host.Models;
namespace Tgstation.Server.Host.Models.Migrations.SqlServer
{
[DbContext(typeof(SqlServerDatabaseContext))]
[Migration("20180410203936_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.0-preview2-30571")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<long?>("ChatSettingsId");
b.Property<long?>("ChatSettingsId1");
b.Property<long>("DiscordChannelId");
b.Property<string>("IrcChannel");
b.HasKey("Id");
b.HasIndex("ChatSettingsId");
b.HasIndex("ChatSettingsId1");
b.ToTable("ChatChannels");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("DiscordBotToken");
b.Property<bool>("DiscordEnabled");
b.Property<long>("InstanceId");
b.Property<bool>("IrcEnabled");
b.Property<string>("IrcHost")
.IsRequired();
b.Property<string>("IrcNickServPassword");
b.Property<int>("IrcPort");
b.HasKey("Id");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("ChatSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("ExitCode");
b.Property<DateTimeOffset>("FinishedAt");
b.Property<long?>("InstanceId");
b.Property<string>("Output");
b.Property<long>("RevisionInformationId");
b.Property<DateTimeOffset>("StartedAt");
b.Property<bool?>("TargetedPrimaryDirectory");
b.Property<long>("TriggeredById");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("RevisionInformationId");
b.HasIndex("TriggeredById");
b.ToTable("CompileJobs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AccessToken");
b.Property<bool>("AllowWebClient");
b.Property<bool>("AutoStart");
b.Property<long?>("CompileJobId");
b.Property<long>("InstanceId");
b.Property<int>("PrimaryPort");
b.Property<int?>("ProcessId");
b.Property<int>("SecondaryPort");
b.Property<int>("SecurityLevel");
b.Property<bool>("SoftRestart");
b.Property<bool>("SoftShutdown");
b.HasKey("Id");
b.HasIndex("CompileJobId");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("DreamDaemonSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("AutoCompileInterval");
b.Property<long?>("CompileJobId");
b.Property<long>("InstanceId");
b.Property<string>("TargetDme");
b.HasKey("Id");
b.HasIndex("CompileJobId");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("DreamMakerSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("ConfigurationAllowed");
b.Property<string>("Name")
.IsRequired();
b.Property<bool>("Online");
b.Property<string>("Path")
.IsRequired();
b.HasKey("Id");
b.ToTable("Instances");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.InstanceUser", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("ByondRights");
b.Property<int>("ChatSettingsRights");
b.Property<int>("ConfigurationRights");
b.Property<int>("DreamDaemonRights");
b.Property<int>("DreamMakerRights");
b.Property<long?>("InstanceId");
b.Property<int>("RepositoryRights");
b.Property<long?>("UserId");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("UserId");
b.ToTable("InstanceUsers");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Cancelled");
b.Property<string>("Description")
.IsRequired();
b.Property<long>("InstanceId");
b.Property<DateTimeOffset>("StartedAt");
b.Property<long>("StartedById");
b.Property<DateTimeOffset>("StoppedAt");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("StartedById");
b.ToTable("Jobs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AccessToken");
b.Property<string>("AccessUser");
b.Property<int?>("AutoUpdateInterval");
b.Property<string>("CommitterEmail")
.IsRequired();
b.Property<string>("CommitterName")
.IsRequired();
b.Property<long>("InstanceId");
b.Property<string>("Origin");
b.Property<bool>("PushTestMergeCommits");
b.Property<long?>("RevisionInformationId");
b.HasKey("Id");
b.HasIndex("InstanceId")
.IsUnique();
b.HasIndex("RevisionInformationId");
b.ToTable("RepositorySettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("OriginRevision")
.IsRequired()
.HasMaxLength(40);
b.Property<string>("Revision")
.IsRequired()
.HasMaxLength(40);
b.HasKey("Id");
b.HasIndex("Revision")
.IsUnique();
b.ToTable("RevisionInformations");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ServerSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("EnableTelemetry");
b.Property<string>("SystemAuthenticationGroup");
b.Property<string>("UpstreamRepository");
b.HasKey("Id");
b.ToTable("ServerSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Author")
.IsRequired();
b.Property<string>("BodyAtMerge")
.IsRequired();
b.Property<long?>("InstanceId");
b.Property<DateTimeOffset>("MergedAt");
b.Property<long>("MergedById");
b.Property<long?>("RevisionInformationId");
b.Property<string>("TitleAtMerge")
.IsRequired();
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("MergedById");
b.HasIndex("RevisionInformationId");
b.ToTable("TestMerges");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.User", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AdministrationRights");
b.Property<DateTimeOffset>("CreatedAt");
b.Property<int>("InstanceManagerRights");
b.Property<string>("Name")
.IsRequired();
b.Property<string>("PasswordHash");
b.Property<string>("SystemIdentifier");
b.Property<string>("TokenSecret")
.HasMaxLength(40);
b.HasKey("Id");
b.HasIndex("SystemIdentifier")
.IsUnique()
.HasFilter("[SystemIdentifier] IS NOT NULL");
b.ToTable("Users");
});
modelBuilder.Entity("ZNetCS.AspNetCore.Logging.EntityFrameworkCore.Log", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("EventId");
b.Property<int>("Level");
b.Property<string>("Message");
b.Property<string>("Name")
.HasMaxLength(255);
b.Property<DateTimeOffset>("TimeStamp");
b.HasKey("Id");
b.ToTable("Logs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
{
b.HasOne("Tgstation.Server.Host.Models.ChatSettings")
.WithMany("AdminChannels")
.HasForeignKey("ChatSettingsId");
b.HasOne("Tgstation.Server.Host.Models.ChatSettings")
.WithMany("GeneralChannels")
.HasForeignKey("ChatSettingsId1");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatSettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
.WithOne("ChatSettings")
.HasForeignKey("Tgstation.Server.Host.Models.ChatSettings", "InstanceId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance")
.WithMany("CompileJobs")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation")
.WithMany()
.HasForeignKey("RevisionInformationId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.User", "TriggeredBy")
.WithMany()
.HasForeignKey("TriggeredById")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.CompileJob", "CompileJob")
.WithMany()
.HasForeignKey("CompileJobId");
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.CompileJob", "CompileJob")
.WithMany()
.HasForeignKey("CompileJobId");
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")
.WithMany("InstanceUsers")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.User")
.WithMany("InstanceUsers")
.HasForeignKey("UserId");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b =>
{
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.RepositorySettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
.WithOne("RepositorySettings")
.HasForeignKey("Tgstation.Server.Host.Models.RepositorySettings", "InstanceId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation")
.WithMany()
.HasForeignKey("RevisionInformationId");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance")
.WithMany("TestMerges")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.User", "MergedBy")
.WithMany()
.HasForeignKey("MergedById")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation")
.WithMany("TestMerges")
.HasForeignKey("RevisionInformationId");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,537 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Tgstation.Server.Host.Models.Migrations.SqlServer
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Instances",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: false),
Path = table.Column<string>(nullable: false),
Online = table.Column<bool>(nullable: false),
ConfigurationAllowed = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Instances", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Logs",
columns: table => new
{
EventId = table.Column<int>(nullable: false),
Id = table.Column<int>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Level = table.Column<int>(nullable: false),
Message = table.Column<string>(nullable: true),
Name = table.Column<string>(maxLength: 255, nullable: true),
TimeStamp = table.Column<DateTimeOffset>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Logs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RevisionInformations",
columns: table => new
{
Revision = table.Column<string>(maxLength: 40, nullable: false),
OriginRevision = table.Column<string>(maxLength: 40, nullable: false),
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn)
},
constraints: table =>
{
table.PrimaryKey("PK_RevisionInformations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ServerSettings",
columns: table => new
{
SystemAuthenticationGroup = table.Column<string>(nullable: true),
EnableTelemetry = table.Column<bool>(nullable: false),
UpstreamRepository = table.Column<string>(nullable: true),
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn)
},
constraints: table =>
{
table.PrimaryKey("PK_ServerSettings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
AdministrationRights = table.Column<int>(nullable: false),
CreatedAt = table.Column<DateTimeOffset>(nullable: false),
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
InstanceManagerRights = table.Column<int>(nullable: false),
SystemIdentifier = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: false),
PasswordHash = table.Column<string>(nullable: true),
TokenSecret = table.Column<string>(maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ChatSettings",
columns: table => new
{
IrcEnabled = table.Column<bool>(nullable: false),
IrcHost = table.Column<string>(nullable: false),
IrcPort = table.Column<int>(nullable: false),
IrcNickServPassword = table.Column<string>(nullable: true),
DiscordEnabled = table.Column<bool>(nullable: false),
DiscordBotToken = table.Column<string>(nullable: true),
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
InstanceId = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChatSettings", x => x.Id);
table.ForeignKey(
name: "FK_ChatSettings_Instances_InstanceId",
column: x => x.InstanceId,
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RepositorySettings",
columns: table => new
{
Origin = table.Column<string>(nullable: true),
CommitterName = table.Column<string>(nullable: false),
CommitterEmail = table.Column<string>(nullable: false),
AccessUser = table.Column<string>(nullable: true),
AccessToken = table.Column<string>(nullable: true),
PushTestMergeCommits = table.Column<bool>(nullable: false),
AutoUpdateInterval = table.Column<int>(nullable: true),
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
InstanceId = table.Column<long>(nullable: false),
RevisionInformationId = table.Column<long>(nullable: true)
},
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);
table.ForeignKey(
name: "FK_RepositorySettings_RevisionInformations_RevisionInformationId",
column: x => x.RevisionInformationId,
principalTable: "RevisionInformations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "CompileJobs",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
StartedAt = table.Column<DateTimeOffset>(nullable: false),
FinishedAt = table.Column<DateTimeOffset>(nullable: false),
TargetedPrimaryDirectory = table.Column<bool>(nullable: true),
Output = table.Column<string>(nullable: true),
ExitCode = table.Column<int>(nullable: true),
TriggeredById = table.Column<long>(nullable: false),
RevisionInformationId = table.Column<long>(nullable: false),
InstanceId = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CompileJobs", x => x.Id);
table.ForeignKey(
name: "FK_CompileJobs_Instances_InstanceId",
column: x => x.InstanceId,
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_CompileJobs_RevisionInformations_RevisionInformationId",
column: x => x.RevisionInformationId,
principalTable: "RevisionInformations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CompileJobs_Users_TriggeredById",
column: x => x.TriggeredById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InstanceUsers",
columns: table => new
{
ByondRights = table.Column<int>(nullable: false),
DreamDaemonRights = table.Column<int>(nullable: false),
DreamMakerRights = table.Column<int>(nullable: false),
RepositoryRights = table.Column<int>(nullable: false),
ChatSettingsRights = table.Column<int>(nullable: false),
ConfigurationRights = table.Column<int>(nullable: false),
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
InstanceId = table.Column<long>(nullable: true),
UserId = table.Column<long>(nullable: true)
},
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.Restrict);
table.ForeignKey(
name: "FK_InstanceUsers_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Jobs",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
Description = table.Column<string>(nullable: false),
StartedAt = table.Column<DateTimeOffset>(nullable: false),
StoppedAt = table.Column<DateTimeOffset>(nullable: false),
Cancelled = table.Column<bool>(nullable: false),
StartedById = table.Column<long>(nullable: false),
InstanceId = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Jobs", x => x.Id);
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: "TestMerges",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
MergedAt = table.Column<DateTimeOffset>(nullable: false),
TitleAtMerge = table.Column<string>(nullable: false),
BodyAtMerge = table.Column<string>(nullable: false),
Author = table.Column<string>(nullable: false),
MergedById = table.Column<long>(nullable: false),
InstanceId = table.Column<long>(nullable: true),
RevisionInformationId = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TestMerges", x => x.Id);
table.ForeignKey(
name: "FK_TestMerges_Instances_InstanceId",
column: x => x.InstanceId,
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_TestMerges_Users_MergedById",
column: x => x.MergedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TestMerges_RevisionInformations_RevisionInformationId",
column: x => x.RevisionInformationId,
principalTable: "RevisionInformations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ChatChannels",
columns: table => new
{
IrcChannel = table.Column<string>(nullable: true),
DiscordChannelId = table.Column<long>(nullable: false),
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
ChatSettingsId = table.Column<long>(nullable: true),
ChatSettingsId1 = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ChatChannels", x => x.Id);
table.ForeignKey(
name: "FK_ChatChannels_ChatSettings_ChatSettingsId",
column: x => x.ChatSettingsId,
principalTable: "ChatSettings",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_ChatChannels_ChatSettings_ChatSettingsId1",
column: x => x.ChatSettingsId1,
principalTable: "ChatSettings",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "DreamDaemonSettings",
columns: table => new
{
AutoStart = table.Column<bool>(nullable: false),
AllowWebClient = table.Column<bool>(nullable: false),
SoftRestart = table.Column<bool>(nullable: false),
SoftShutdown = table.Column<bool>(nullable: false),
SecurityLevel = table.Column<int>(nullable: false),
PrimaryPort = table.Column<int>(nullable: false),
SecondaryPort = table.Column<int>(nullable: false),
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
ProcessId = table.Column<int>(nullable: true),
AccessToken = table.Column<string>(nullable: true),
InstanceId = table.Column<long>(nullable: false),
CompileJobId = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DreamDaemonSettings", x => x.Id);
table.ForeignKey(
name: "FK_DreamDaemonSettings_CompileJobs_CompileJobId",
column: x => x.CompileJobId,
principalTable: "CompileJobs",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
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
{
AutoCompileInterval = table.Column<int>(nullable: true),
TargetDme = table.Column<string>(nullable: true),
Id = table.Column<long>(nullable: false)
.Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
InstanceId = table.Column<long>(nullable: false),
CompileJobId = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DreamMakerSettings", x => x.Id);
table.ForeignKey(
name: "FK_DreamMakerSettings_CompileJobs_CompileJobId",
column: x => x.CompileJobId,
principalTable: "CompileJobs",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_DreamMakerSettings_Instances_InstanceId",
column: x => x.InstanceId,
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ChatChannels_ChatSettingsId",
table: "ChatChannels",
column: "ChatSettingsId");
migrationBuilder.CreateIndex(
name: "IX_ChatChannels_ChatSettingsId1",
table: "ChatChannels",
column: "ChatSettingsId1");
migrationBuilder.CreateIndex(
name: "IX_ChatSettings_InstanceId",
table: "ChatSettings",
column: "InstanceId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_CompileJobs_InstanceId",
table: "CompileJobs",
column: "InstanceId");
migrationBuilder.CreateIndex(
name: "IX_CompileJobs_RevisionInformationId",
table: "CompileJobs",
column: "RevisionInformationId");
migrationBuilder.CreateIndex(
name: "IX_CompileJobs_TriggeredById",
table: "CompileJobs",
column: "TriggeredById");
migrationBuilder.CreateIndex(
name: "IX_DreamDaemonSettings_CompileJobId",
table: "DreamDaemonSettings",
column: "CompileJobId");
migrationBuilder.CreateIndex(
name: "IX_DreamDaemonSettings_InstanceId",
table: "DreamDaemonSettings",
column: "InstanceId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_DreamMakerSettings_CompileJobId",
table: "DreamMakerSettings",
column: "CompileJobId");
migrationBuilder.CreateIndex(
name: "IX_DreamMakerSettings_InstanceId",
table: "DreamMakerSettings",
column: "InstanceId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_InstanceUsers_InstanceId",
table: "InstanceUsers",
column: "InstanceId");
migrationBuilder.CreateIndex(
name: "IX_InstanceUsers_UserId",
table: "InstanceUsers",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Jobs_InstanceId",
table: "Jobs",
column: "InstanceId");
migrationBuilder.CreateIndex(
name: "IX_Jobs_StartedById",
table: "Jobs",
column: "StartedById");
migrationBuilder.CreateIndex(
name: "IX_RepositorySettings_InstanceId",
table: "RepositorySettings",
column: "InstanceId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_RepositorySettings_RevisionInformationId",
table: "RepositorySettings",
column: "RevisionInformationId");
migrationBuilder.CreateIndex(
name: "IX_RevisionInformations_Revision",
table: "RevisionInformations",
column: "Revision",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_TestMerges_InstanceId",
table: "TestMerges",
column: "InstanceId");
migrationBuilder.CreateIndex(
name: "IX_TestMerges_MergedById",
table: "TestMerges",
column: "MergedById");
migrationBuilder.CreateIndex(
name: "IX_TestMerges_RevisionInformationId",
table: "TestMerges",
column: "RevisionInformationId");
migrationBuilder.CreateIndex(
name: "IX_Users_SystemIdentifier",
table: "Users",
column: "SystemIdentifier",
unique: true,
filter: "[SystemIdentifier] IS NOT NULL");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChatChannels");
migrationBuilder.DropTable(
name: "DreamDaemonSettings");
migrationBuilder.DropTable(
name: "DreamMakerSettings");
migrationBuilder.DropTable(
name: "InstanceUsers");
migrationBuilder.DropTable(
name: "Jobs");
migrationBuilder.DropTable(
name: "Logs");
migrationBuilder.DropTable(
name: "RepositorySettings");
migrationBuilder.DropTable(
name: "ServerSettings");
migrationBuilder.DropTable(
name: "TestMerges");
migrationBuilder.DropTable(
name: "ChatSettings");
migrationBuilder.DropTable(
name: "CompileJobs");
migrationBuilder.DropTable(
name: "Instances");
migrationBuilder.DropTable(
name: "RevisionInformations");
migrationBuilder.DropTable(
name: "Users");
}
}
}
@@ -0,0 +1,511 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Migrations;
using Tgstation.Server.Host.Models;
namespace Tgstation.Server.Host.Models.Migrations.SqlServer
{
[DbContext(typeof(SqlServerDatabaseContext))]
partial class SqlServerDatabaseContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.0-preview2-30571")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<long?>("ChatSettingsId");
b.Property<long?>("ChatSettingsId1");
b.Property<long>("DiscordChannelId");
b.Property<string>("IrcChannel");
b.HasKey("Id");
b.HasIndex("ChatSettingsId");
b.HasIndex("ChatSettingsId1");
b.ToTable("ChatChannels");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("DiscordBotToken");
b.Property<bool>("DiscordEnabled");
b.Property<long>("InstanceId");
b.Property<bool>("IrcEnabled");
b.Property<string>("IrcHost")
.IsRequired();
b.Property<string>("IrcNickServPassword");
b.Property<int>("IrcPort");
b.HasKey("Id");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("ChatSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("ExitCode");
b.Property<DateTimeOffset>("FinishedAt");
b.Property<long?>("InstanceId");
b.Property<string>("Output");
b.Property<long>("RevisionInformationId");
b.Property<DateTimeOffset>("StartedAt");
b.Property<bool?>("TargetedPrimaryDirectory");
b.Property<long>("TriggeredById");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("RevisionInformationId");
b.HasIndex("TriggeredById");
b.ToTable("CompileJobs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AccessToken");
b.Property<bool>("AllowWebClient");
b.Property<bool>("AutoStart");
b.Property<long?>("CompileJobId");
b.Property<long>("InstanceId");
b.Property<int>("PrimaryPort");
b.Property<int?>("ProcessId");
b.Property<int>("SecondaryPort");
b.Property<int>("SecurityLevel");
b.Property<bool>("SoftRestart");
b.Property<bool>("SoftShutdown");
b.HasKey("Id");
b.HasIndex("CompileJobId");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("DreamDaemonSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("AutoCompileInterval");
b.Property<long?>("CompileJobId");
b.Property<long>("InstanceId");
b.Property<string>("TargetDme");
b.HasKey("Id");
b.HasIndex("CompileJobId");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("DreamMakerSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("ConfigurationAllowed");
b.Property<string>("Name")
.IsRequired();
b.Property<bool>("Online");
b.Property<string>("Path")
.IsRequired();
b.HasKey("Id");
b.ToTable("Instances");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.InstanceUser", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("ByondRights");
b.Property<int>("ChatSettingsRights");
b.Property<int>("ConfigurationRights");
b.Property<int>("DreamDaemonRights");
b.Property<int>("DreamMakerRights");
b.Property<long?>("InstanceId");
b.Property<int>("RepositoryRights");
b.Property<long?>("UserId");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("UserId");
b.ToTable("InstanceUsers");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Cancelled");
b.Property<string>("Description")
.IsRequired();
b.Property<long>("InstanceId");
b.Property<DateTimeOffset>("StartedAt");
b.Property<long>("StartedById");
b.Property<DateTimeOffset>("StoppedAt");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("StartedById");
b.ToTable("Jobs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AccessToken");
b.Property<string>("AccessUser");
b.Property<int?>("AutoUpdateInterval");
b.Property<string>("CommitterEmail")
.IsRequired();
b.Property<string>("CommitterName")
.IsRequired();
b.Property<long>("InstanceId");
b.Property<string>("Origin");
b.Property<bool>("PushTestMergeCommits");
b.Property<long?>("RevisionInformationId");
b.HasKey("Id");
b.HasIndex("InstanceId")
.IsUnique();
b.HasIndex("RevisionInformationId");
b.ToTable("RepositorySettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("OriginRevision")
.IsRequired()
.HasMaxLength(40);
b.Property<string>("Revision")
.IsRequired()
.HasMaxLength(40);
b.HasKey("Id");
b.HasIndex("Revision")
.IsUnique();
b.ToTable("RevisionInformations");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ServerSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("EnableTelemetry");
b.Property<string>("SystemAuthenticationGroup");
b.Property<string>("UpstreamRepository");
b.HasKey("Id");
b.ToTable("ServerSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Author")
.IsRequired();
b.Property<string>("BodyAtMerge")
.IsRequired();
b.Property<long?>("InstanceId");
b.Property<DateTimeOffset>("MergedAt");
b.Property<long>("MergedById");
b.Property<long?>("RevisionInformationId");
b.Property<string>("TitleAtMerge")
.IsRequired();
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("MergedById");
b.HasIndex("RevisionInformationId");
b.ToTable("TestMerges");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.User", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AdministrationRights");
b.Property<DateTimeOffset>("CreatedAt");
b.Property<int>("InstanceManagerRights");
b.Property<string>("Name")
.IsRequired();
b.Property<string>("PasswordHash");
b.Property<string>("SystemIdentifier");
b.Property<string>("TokenSecret")
.HasMaxLength(40);
b.HasKey("Id");
b.HasIndex("SystemIdentifier")
.IsUnique()
.HasFilter("[SystemIdentifier] IS NOT NULL");
b.ToTable("Users");
});
modelBuilder.Entity("ZNetCS.AspNetCore.Logging.EntityFrameworkCore.Log", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("EventId");
b.Property<int>("Level");
b.Property<string>("Message");
b.Property<string>("Name")
.HasMaxLength(255);
b.Property<DateTimeOffset>("TimeStamp");
b.HasKey("Id");
b.ToTable("Logs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
{
b.HasOne("Tgstation.Server.Host.Models.ChatSettings")
.WithMany("AdminChannels")
.HasForeignKey("ChatSettingsId");
b.HasOne("Tgstation.Server.Host.Models.ChatSettings")
.WithMany("GeneralChannels")
.HasForeignKey("ChatSettingsId1");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatSettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
.WithOne("ChatSettings")
.HasForeignKey("Tgstation.Server.Host.Models.ChatSettings", "InstanceId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance")
.WithMany("CompileJobs")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation")
.WithMany()
.HasForeignKey("RevisionInformationId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.User", "TriggeredBy")
.WithMany()
.HasForeignKey("TriggeredById")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.CompileJob", "CompileJob")
.WithMany()
.HasForeignKey("CompileJobId");
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.CompileJob", "CompileJob")
.WithMany()
.HasForeignKey("CompileJobId");
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")
.WithMany("InstanceUsers")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.User")
.WithMany("InstanceUsers")
.HasForeignKey("UserId");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b =>
{
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.RepositorySettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
.WithOne("RepositorySettings")
.HasForeignKey("Tgstation.Server.Host.Models.RepositorySettings", "InstanceId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation")
.WithMany()
.HasForeignKey("RevisionInformationId");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance")
.WithMany("TestMerges")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.User", "MergedBy")
.WithMany()
.HasForeignKey("MergedById")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation")
.WithMany("TestMerges")
.HasForeignKey("RevisionInformationId");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Logging;
using Tgstation.Server.Host.Core;
namespace Tgstation.Server.Host.Models.Migrations
{
/// <inheritdoc />
sealed class SqlServerDesignTimeDbContextFactory : IDesignTimeDbContextFactory<SqlServerDatabaseContext>
{
/// <inheritdoc />
public SqlServerDatabaseContext CreateDbContext(string[] args) => new SqlServerDatabaseContext(new DbContextOptions<SqlServerDatabaseContext>(), DesignTimeDbContextFactoryHelpers.GetDbContextOptions(), new LoggerFactory(), new DatabaseSeeder(new CryptographySuite(new PasswordHasher<User>())));
}
}
@@ -0,0 +1,510 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Migrations;
using Tgstation.Server.Host.Models;
namespace Tgstation.Server.Host.Models.Migrations.Sqlite
{
[DbContext(typeof(SqliteDatabaseContext))]
[Migration("20180410204120_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.0-preview2-30571");
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<long?>("ChatSettingsId");
b.Property<long?>("ChatSettingsId1");
b.Property<long>("DiscordChannelId");
b.Property<string>("IrcChannel");
b.HasKey("Id");
b.HasIndex("ChatSettingsId");
b.HasIndex("ChatSettingsId1");
b.ToTable("ChatChannels");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("DiscordBotToken");
b.Property<bool>("DiscordEnabled");
b.Property<long>("InstanceId");
b.Property<bool>("IrcEnabled");
b.Property<string>("IrcHost")
.IsRequired();
b.Property<string>("IrcNickServPassword");
b.Property<ushort>("IrcPort");
b.HasKey("Id");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("ChatSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("ExitCode");
b.Property<DateTimeOffset>("FinishedAt");
b.Property<long?>("InstanceId");
b.Property<string>("Output");
b.Property<long>("RevisionInformationId");
b.Property<DateTimeOffset>("StartedAt");
b.Property<bool?>("TargetedPrimaryDirectory");
b.Property<long>("TriggeredById");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("RevisionInformationId");
b.HasIndex("TriggeredById");
b.ToTable("CompileJobs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AccessToken");
b.Property<bool>("AllowWebClient");
b.Property<bool>("AutoStart");
b.Property<long?>("CompileJobId");
b.Property<long>("InstanceId");
b.Property<ushort>("PrimaryPort");
b.Property<int?>("ProcessId");
b.Property<ushort>("SecondaryPort");
b.Property<int>("SecurityLevel");
b.Property<bool>("SoftRestart");
b.Property<bool>("SoftShutdown");
b.HasKey("Id");
b.HasIndex("CompileJobId");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("DreamDaemonSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("AutoCompileInterval");
b.Property<long?>("CompileJobId");
b.Property<long>("InstanceId");
b.Property<string>("TargetDme");
b.HasKey("Id");
b.HasIndex("CompileJobId");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("DreamMakerSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("ConfigurationAllowed");
b.Property<string>("Name")
.IsRequired();
b.Property<bool>("Online");
b.Property<string>("Path")
.IsRequired();
b.HasKey("Id");
b.ToTable("Instances");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.InstanceUser", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("ByondRights");
b.Property<int>("ChatSettingsRights");
b.Property<int>("ConfigurationRights");
b.Property<int>("DreamDaemonRights");
b.Property<int>("DreamMakerRights");
b.Property<long?>("InstanceId");
b.Property<int>("RepositoryRights");
b.Property<long?>("UserId");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("UserId");
b.ToTable("InstanceUsers");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Cancelled");
b.Property<string>("Description")
.IsRequired();
b.Property<long>("InstanceId");
b.Property<DateTimeOffset>("StartedAt");
b.Property<long>("StartedById");
b.Property<DateTimeOffset>("StoppedAt");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("StartedById");
b.ToTable("Jobs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AccessToken");
b.Property<string>("AccessUser");
b.Property<int?>("AutoUpdateInterval");
b.Property<string>("CommitterEmail")
.IsRequired();
b.Property<string>("CommitterName")
.IsRequired();
b.Property<long>("InstanceId");
b.Property<string>("Origin");
b.Property<bool>("PushTestMergeCommits");
b.Property<long?>("RevisionInformationId");
b.HasKey("Id");
b.HasIndex("InstanceId")
.IsUnique();
b.HasIndex("RevisionInformationId");
b.ToTable("RepositorySettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("OriginRevision")
.IsRequired()
.HasMaxLength(40);
b.Property<string>("Revision")
.IsRequired()
.HasMaxLength(40);
b.HasKey("Id");
b.HasIndex("Revision")
.IsUnique();
b.ToTable("RevisionInformations");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ServerSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("EnableTelemetry");
b.Property<string>("SystemAuthenticationGroup");
b.Property<string>("UpstreamRepository");
b.HasKey("Id");
b.ToTable("ServerSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Author")
.IsRequired();
b.Property<string>("BodyAtMerge")
.IsRequired();
b.Property<long?>("InstanceId");
b.Property<DateTimeOffset>("MergedAt");
b.Property<long>("MergedById");
b.Property<long?>("RevisionInformationId");
b.Property<string>("TitleAtMerge")
.IsRequired();
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("MergedById");
b.HasIndex("RevisionInformationId");
b.ToTable("TestMerges");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.User", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AdministrationRights");
b.Property<DateTimeOffset>("CreatedAt");
b.Property<int>("InstanceManagerRights");
b.Property<string>("Name")
.IsRequired();
b.Property<string>("PasswordHash");
b.Property<string>("SystemIdentifier");
b.Property<string>("TokenSecret")
.HasMaxLength(40);
b.HasKey("Id");
b.HasIndex("SystemIdentifier")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("ZNetCS.AspNetCore.Logging.EntityFrameworkCore.Log", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("EventId");
b.Property<int>("Level");
b.Property<string>("Message");
b.Property<string>("Name")
.HasMaxLength(255);
b.Property<DateTimeOffset>("TimeStamp");
b.HasKey("Id");
b.ToTable("Logs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
{
b.HasOne("Tgstation.Server.Host.Models.ChatSettings")
.WithMany("AdminChannels")
.HasForeignKey("ChatSettingsId");
b.HasOne("Tgstation.Server.Host.Models.ChatSettings")
.WithMany("GeneralChannels")
.HasForeignKey("ChatSettingsId1");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatSettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
.WithOne("ChatSettings")
.HasForeignKey("Tgstation.Server.Host.Models.ChatSettings", "InstanceId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance")
.WithMany("CompileJobs")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation")
.WithMany()
.HasForeignKey("RevisionInformationId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.User", "TriggeredBy")
.WithMany()
.HasForeignKey("TriggeredById")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.CompileJob", "CompileJob")
.WithMany()
.HasForeignKey("CompileJobId");
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.CompileJob", "CompileJob")
.WithMany()
.HasForeignKey("CompileJobId");
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")
.WithMany("InstanceUsers")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.User")
.WithMany("InstanceUsers")
.HasForeignKey("UserId");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b =>
{
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.RepositorySettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
.WithOne("RepositorySettings")
.HasForeignKey("Tgstation.Server.Host.Models.RepositorySettings", "InstanceId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation")
.WithMany()
.HasForeignKey("RevisionInformationId");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance")
.WithMany("TestMerges")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.User", "MergedBy")
.WithMany()
.HasForeignKey("MergedById")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation")
.WithMany("TestMerges")
.HasForeignKey("RevisionInformationId");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,535 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Tgstation.Server.Host.Models.Migrations.Sqlite
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Instances",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(nullable: false),
Path = table.Column<string>(nullable: false),
Online = table.Column<bool>(nullable: false),
ConfigurationAllowed = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Instances", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Logs",
columns: table => new
{
EventId = table.Column<int>(nullable: false),
Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Level = table.Column<int>(nullable: false),
Message = table.Column<string>(nullable: true),
Name = table.Column<string>(maxLength: 255, nullable: true),
TimeStamp = table.Column<DateTimeOffset>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Logs", x => x.Id);
});
migrationBuilder.CreateTable(
name: "RevisionInformations",
columns: table => new
{
Revision = table.Column<string>(maxLength: 40, nullable: false),
OriginRevision = table.Column<string>(maxLength: 40, nullable: false),
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true)
},
constraints: table =>
{
table.PrimaryKey("PK_RevisionInformations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ServerSettings",
columns: table => new
{
SystemAuthenticationGroup = table.Column<string>(nullable: true),
EnableTelemetry = table.Column<bool>(nullable: false),
UpstreamRepository = table.Column<string>(nullable: true),
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true)
},
constraints: table =>
{
table.PrimaryKey("PK_ServerSettings", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
AdministrationRights = table.Column<int>(nullable: false),
CreatedAt = table.Column<DateTimeOffset>(nullable: false),
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
InstanceManagerRights = table.Column<int>(nullable: false),
SystemIdentifier = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: false),
PasswordHash = table.Column<string>(nullable: true),
TokenSecret = table.Column<string>(maxLength: 40, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ChatSettings",
columns: table => new
{
IrcEnabled = table.Column<bool>(nullable: false),
IrcHost = table.Column<string>(nullable: false),
IrcPort = table.Column<ushort>(nullable: false),
IrcNickServPassword = table.Column<string>(nullable: true),
DiscordEnabled = table.Column<bool>(nullable: false),
DiscordBotToken = table.Column<string>(nullable: true),
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
InstanceId = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ChatSettings", x => x.Id);
table.ForeignKey(
name: "FK_ChatSettings_Instances_InstanceId",
column: x => x.InstanceId,
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "RepositorySettings",
columns: table => new
{
Origin = table.Column<string>(nullable: true),
CommitterName = table.Column<string>(nullable: false),
CommitterEmail = table.Column<string>(nullable: false),
AccessUser = table.Column<string>(nullable: true),
AccessToken = table.Column<string>(nullable: true),
PushTestMergeCommits = table.Column<bool>(nullable: false),
AutoUpdateInterval = table.Column<int>(nullable: true),
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
InstanceId = table.Column<long>(nullable: false),
RevisionInformationId = table.Column<long>(nullable: true)
},
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);
table.ForeignKey(
name: "FK_RepositorySettings_RevisionInformations_RevisionInformationId",
column: x => x.RevisionInformationId,
principalTable: "RevisionInformations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "CompileJobs",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
StartedAt = table.Column<DateTimeOffset>(nullable: false),
FinishedAt = table.Column<DateTimeOffset>(nullable: false),
TargetedPrimaryDirectory = table.Column<bool>(nullable: true),
Output = table.Column<string>(nullable: true),
ExitCode = table.Column<int>(nullable: true),
TriggeredById = table.Column<long>(nullable: false),
RevisionInformationId = table.Column<long>(nullable: false),
InstanceId = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CompileJobs", x => x.Id);
table.ForeignKey(
name: "FK_CompileJobs_Instances_InstanceId",
column: x => x.InstanceId,
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_CompileJobs_RevisionInformations_RevisionInformationId",
column: x => x.RevisionInformationId,
principalTable: "RevisionInformations",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CompileJobs_Users_TriggeredById",
column: x => x.TriggeredById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InstanceUsers",
columns: table => new
{
ByondRights = table.Column<int>(nullable: false),
DreamDaemonRights = table.Column<int>(nullable: false),
DreamMakerRights = table.Column<int>(nullable: false),
RepositoryRights = table.Column<int>(nullable: false),
ChatSettingsRights = table.Column<int>(nullable: false),
ConfigurationRights = table.Column<int>(nullable: false),
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
InstanceId = table.Column<long>(nullable: true),
UserId = table.Column<long>(nullable: true)
},
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.Restrict);
table.ForeignKey(
name: "FK_InstanceUsers_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Jobs",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Description = table.Column<string>(nullable: false),
StartedAt = table.Column<DateTimeOffset>(nullable: false),
StoppedAt = table.Column<DateTimeOffset>(nullable: false),
Cancelled = table.Column<bool>(nullable: false),
StartedById = table.Column<long>(nullable: false),
InstanceId = table.Column<long>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Jobs", x => x.Id);
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: "TestMerges",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
MergedAt = table.Column<DateTimeOffset>(nullable: false),
TitleAtMerge = table.Column<string>(nullable: false),
BodyAtMerge = table.Column<string>(nullable: false),
Author = table.Column<string>(nullable: false),
MergedById = table.Column<long>(nullable: false),
InstanceId = table.Column<long>(nullable: true),
RevisionInformationId = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_TestMerges", x => x.Id);
table.ForeignKey(
name: "FK_TestMerges_Instances_InstanceId",
column: x => x.InstanceId,
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_TestMerges_Users_MergedById",
column: x => x.MergedById,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TestMerges_RevisionInformations_RevisionInformationId",
column: x => x.RevisionInformationId,
principalTable: "RevisionInformations",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ChatChannels",
columns: table => new
{
IrcChannel = table.Column<string>(nullable: true),
DiscordChannelId = table.Column<long>(nullable: false),
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ChatSettingsId = table.Column<long>(nullable: true),
ChatSettingsId1 = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ChatChannels", x => x.Id);
table.ForeignKey(
name: "FK_ChatChannels_ChatSettings_ChatSettingsId",
column: x => x.ChatSettingsId,
principalTable: "ChatSettings",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_ChatChannels_ChatSettings_ChatSettingsId1",
column: x => x.ChatSettingsId1,
principalTable: "ChatSettings",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "DreamDaemonSettings",
columns: table => new
{
AutoStart = table.Column<bool>(nullable: false),
AllowWebClient = table.Column<bool>(nullable: false),
SoftRestart = table.Column<bool>(nullable: false),
SoftShutdown = table.Column<bool>(nullable: false),
SecurityLevel = table.Column<int>(nullable: false),
PrimaryPort = table.Column<ushort>(nullable: false),
SecondaryPort = table.Column<ushort>(nullable: false),
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
ProcessId = table.Column<int>(nullable: true),
AccessToken = table.Column<string>(nullable: true),
InstanceId = table.Column<long>(nullable: false),
CompileJobId = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DreamDaemonSettings", x => x.Id);
table.ForeignKey(
name: "FK_DreamDaemonSettings_CompileJobs_CompileJobId",
column: x => x.CompileJobId,
principalTable: "CompileJobs",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
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
{
AutoCompileInterval = table.Column<int>(nullable: true),
TargetDme = table.Column<string>(nullable: true),
Id = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
InstanceId = table.Column<long>(nullable: false),
CompileJobId = table.Column<long>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_DreamMakerSettings", x => x.Id);
table.ForeignKey(
name: "FK_DreamMakerSettings_CompileJobs_CompileJobId",
column: x => x.CompileJobId,
principalTable: "CompileJobs",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_DreamMakerSettings_Instances_InstanceId",
column: x => x.InstanceId,
principalTable: "Instances",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ChatChannels_ChatSettingsId",
table: "ChatChannels",
column: "ChatSettingsId");
migrationBuilder.CreateIndex(
name: "IX_ChatChannels_ChatSettingsId1",
table: "ChatChannels",
column: "ChatSettingsId1");
migrationBuilder.CreateIndex(
name: "IX_ChatSettings_InstanceId",
table: "ChatSettings",
column: "InstanceId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_CompileJobs_InstanceId",
table: "CompileJobs",
column: "InstanceId");
migrationBuilder.CreateIndex(
name: "IX_CompileJobs_RevisionInformationId",
table: "CompileJobs",
column: "RevisionInformationId");
migrationBuilder.CreateIndex(
name: "IX_CompileJobs_TriggeredById",
table: "CompileJobs",
column: "TriggeredById");
migrationBuilder.CreateIndex(
name: "IX_DreamDaemonSettings_CompileJobId",
table: "DreamDaemonSettings",
column: "CompileJobId");
migrationBuilder.CreateIndex(
name: "IX_DreamDaemonSettings_InstanceId",
table: "DreamDaemonSettings",
column: "InstanceId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_DreamMakerSettings_CompileJobId",
table: "DreamMakerSettings",
column: "CompileJobId");
migrationBuilder.CreateIndex(
name: "IX_DreamMakerSettings_InstanceId",
table: "DreamMakerSettings",
column: "InstanceId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_InstanceUsers_InstanceId",
table: "InstanceUsers",
column: "InstanceId");
migrationBuilder.CreateIndex(
name: "IX_InstanceUsers_UserId",
table: "InstanceUsers",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Jobs_InstanceId",
table: "Jobs",
column: "InstanceId");
migrationBuilder.CreateIndex(
name: "IX_Jobs_StartedById",
table: "Jobs",
column: "StartedById");
migrationBuilder.CreateIndex(
name: "IX_RepositorySettings_InstanceId",
table: "RepositorySettings",
column: "InstanceId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_RepositorySettings_RevisionInformationId",
table: "RepositorySettings",
column: "RevisionInformationId");
migrationBuilder.CreateIndex(
name: "IX_RevisionInformations_Revision",
table: "RevisionInformations",
column: "Revision",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_TestMerges_InstanceId",
table: "TestMerges",
column: "InstanceId");
migrationBuilder.CreateIndex(
name: "IX_TestMerges_MergedById",
table: "TestMerges",
column: "MergedById");
migrationBuilder.CreateIndex(
name: "IX_TestMerges_RevisionInformationId",
table: "TestMerges",
column: "RevisionInformationId");
migrationBuilder.CreateIndex(
name: "IX_Users_SystemIdentifier",
table: "Users",
column: "SystemIdentifier",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ChatChannels");
migrationBuilder.DropTable(
name: "DreamDaemonSettings");
migrationBuilder.DropTable(
name: "DreamMakerSettings");
migrationBuilder.DropTable(
name: "InstanceUsers");
migrationBuilder.DropTable(
name: "Jobs");
migrationBuilder.DropTable(
name: "Logs");
migrationBuilder.DropTable(
name: "RepositorySettings");
migrationBuilder.DropTable(
name: "ServerSettings");
migrationBuilder.DropTable(
name: "TestMerges");
migrationBuilder.DropTable(
name: "ChatSettings");
migrationBuilder.DropTable(
name: "CompileJobs");
migrationBuilder.DropTable(
name: "Instances");
migrationBuilder.DropTable(
name: "RevisionInformations");
migrationBuilder.DropTable(
name: "Users");
}
}
}
@@ -0,0 +1,509 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Migrations;
using Tgstation.Server.Host.Models;
namespace Tgstation.Server.Host.Models.Migrations.Sqlite
{
[DbContext(typeof(SqliteDatabaseContext))]
partial class SqliteDatabaseContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.1.0-preview2-30571");
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<long?>("ChatSettingsId");
b.Property<long?>("ChatSettingsId1");
b.Property<long>("DiscordChannelId");
b.Property<string>("IrcChannel");
b.HasKey("Id");
b.HasIndex("ChatSettingsId");
b.HasIndex("ChatSettingsId1");
b.ToTable("ChatChannels");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("DiscordBotToken");
b.Property<bool>("DiscordEnabled");
b.Property<long>("InstanceId");
b.Property<bool>("IrcEnabled");
b.Property<string>("IrcHost")
.IsRequired();
b.Property<string>("IrcNickServPassword");
b.Property<ushort>("IrcPort");
b.HasKey("Id");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("ChatSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("ExitCode");
b.Property<DateTimeOffset>("FinishedAt");
b.Property<long?>("InstanceId");
b.Property<string>("Output");
b.Property<long>("RevisionInformationId");
b.Property<DateTimeOffset>("StartedAt");
b.Property<bool?>("TargetedPrimaryDirectory");
b.Property<long>("TriggeredById");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("RevisionInformationId");
b.HasIndex("TriggeredById");
b.ToTable("CompileJobs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AccessToken");
b.Property<bool>("AllowWebClient");
b.Property<bool>("AutoStart");
b.Property<long?>("CompileJobId");
b.Property<long>("InstanceId");
b.Property<ushort>("PrimaryPort");
b.Property<int?>("ProcessId");
b.Property<ushort>("SecondaryPort");
b.Property<int>("SecurityLevel");
b.Property<bool>("SoftRestart");
b.Property<bool>("SoftShutdown");
b.HasKey("Id");
b.HasIndex("CompileJobId");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("DreamDaemonSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int?>("AutoCompileInterval");
b.Property<long?>("CompileJobId");
b.Property<long>("InstanceId");
b.Property<string>("TargetDme");
b.HasKey("Id");
b.HasIndex("CompileJobId");
b.HasIndex("InstanceId")
.IsUnique();
b.ToTable("DreamMakerSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("ConfigurationAllowed");
b.Property<string>("Name")
.IsRequired();
b.Property<bool>("Online");
b.Property<string>("Path")
.IsRequired();
b.HasKey("Id");
b.ToTable("Instances");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.InstanceUser", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("ByondRights");
b.Property<int>("ChatSettingsRights");
b.Property<int>("ConfigurationRights");
b.Property<int>("DreamDaemonRights");
b.Property<int>("DreamMakerRights");
b.Property<long?>("InstanceId");
b.Property<int>("RepositoryRights");
b.Property<long?>("UserId");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("UserId");
b.ToTable("InstanceUsers");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Cancelled");
b.Property<string>("Description")
.IsRequired();
b.Property<long>("InstanceId");
b.Property<DateTimeOffset>("StartedAt");
b.Property<long>("StartedById");
b.Property<DateTimeOffset>("StoppedAt");
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("StartedById");
b.ToTable("Jobs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("AccessToken");
b.Property<string>("AccessUser");
b.Property<int?>("AutoUpdateInterval");
b.Property<string>("CommitterEmail")
.IsRequired();
b.Property<string>("CommitterName")
.IsRequired();
b.Property<long>("InstanceId");
b.Property<string>("Origin");
b.Property<bool>("PushTestMergeCommits");
b.Property<long?>("RevisionInformationId");
b.HasKey("Id");
b.HasIndex("InstanceId")
.IsUnique();
b.HasIndex("RevisionInformationId");
b.ToTable("RepositorySettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("OriginRevision")
.IsRequired()
.HasMaxLength(40);
b.Property<string>("Revision")
.IsRequired()
.HasMaxLength(40);
b.HasKey("Id");
b.HasIndex("Revision")
.IsUnique();
b.ToTable("RevisionInformations");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ServerSettings", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("EnableTelemetry");
b.Property<string>("SystemAuthenticationGroup");
b.Property<string>("UpstreamRepository");
b.HasKey("Id");
b.ToTable("ServerSettings");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Author")
.IsRequired();
b.Property<string>("BodyAtMerge")
.IsRequired();
b.Property<long?>("InstanceId");
b.Property<DateTimeOffset>("MergedAt");
b.Property<long>("MergedById");
b.Property<long?>("RevisionInformationId");
b.Property<string>("TitleAtMerge")
.IsRequired();
b.HasKey("Id");
b.HasIndex("InstanceId");
b.HasIndex("MergedById");
b.HasIndex("RevisionInformationId");
b.ToTable("TestMerges");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.User", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AdministrationRights");
b.Property<DateTimeOffset>("CreatedAt");
b.Property<int>("InstanceManagerRights");
b.Property<string>("Name")
.IsRequired();
b.Property<string>("PasswordHash");
b.Property<string>("SystemIdentifier");
b.Property<string>("TokenSecret")
.HasMaxLength(40);
b.HasKey("Id");
b.HasIndex("SystemIdentifier")
.IsUnique();
b.ToTable("Users");
});
modelBuilder.Entity("ZNetCS.AspNetCore.Logging.EntityFrameworkCore.Log", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("EventId");
b.Property<int>("Level");
b.Property<string>("Message");
b.Property<string>("Name")
.HasMaxLength(255);
b.Property<DateTimeOffset>("TimeStamp");
b.HasKey("Id");
b.ToTable("Logs");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b =>
{
b.HasOne("Tgstation.Server.Host.Models.ChatSettings")
.WithMany("AdminChannels")
.HasForeignKey("ChatSettingsId");
b.HasOne("Tgstation.Server.Host.Models.ChatSettings")
.WithMany("GeneralChannels")
.HasForeignKey("ChatSettingsId1");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.ChatSettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
.WithOne("ChatSettings")
.HasForeignKey("Tgstation.Server.Host.Models.ChatSettings", "InstanceId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance")
.WithMany("CompileJobs")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation")
.WithMany()
.HasForeignKey("RevisionInformationId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.User", "TriggeredBy")
.WithMany()
.HasForeignKey("TriggeredById")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.CompileJob", "CompileJob")
.WithMany()
.HasForeignKey("CompileJobId");
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.CompileJob", "CompileJob")
.WithMany()
.HasForeignKey("CompileJobId");
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")
.WithMany("InstanceUsers")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.User")
.WithMany("InstanceUsers")
.HasForeignKey("UserId");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b =>
{
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.RepositorySettings", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance")
.WithOne("RepositorySettings")
.HasForeignKey("Tgstation.Server.Host.Models.RepositorySettings", "InstanceId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation")
.WithMany()
.HasForeignKey("RevisionInformationId");
});
modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b =>
{
b.HasOne("Tgstation.Server.Host.Models.Instance")
.WithMany("TestMerges")
.HasForeignKey("InstanceId");
b.HasOne("Tgstation.Server.Host.Models.User", "MergedBy")
.WithMany()
.HasForeignKey("MergedById")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Tgstation.Server.Host.Models.RevisionInformation")
.WithMany("TestMerges")
.HasForeignKey("RevisionInformationId");
});
#pragma warning restore 612, 618
}
}
}
@@ -0,0 +1,15 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Logging;
using Tgstation.Server.Host.Core;
namespace Tgstation.Server.Host.Models.Migrations
{
/// <inheritdoc />
sealed class SqliteDesignTimeDbContextFactory : IDesignTimeDbContextFactory<SqliteDatabaseContext>
{
/// <inheritdoc />
public SqliteDatabaseContext CreateDbContext(string[] args) => new SqliteDatabaseContext(new DbContextOptions<SqliteDatabaseContext>(), DesignTimeDbContextFactoryHelpers.GetDbContextOptions(), new LoggerFactory(), new DatabaseSeeder(new CryptographySuite(new PasswordHasher<User>())));
}
}
@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Tgstation.Server.Host.Configuration;
namespace Tgstation.Server.Host.Models
{
/// <summary>
/// <see cref="DatabaseContext"/> for MySQL
/// </summary>
sealed class MySqlDatabaseContext : DatabaseContext<MySqlDatabaseContext>
{
/// <summary>
/// Construct a <see cref="MySqlDatabaseContext"/>
/// </summary>
/// <param name="dbContextOptions">The <see cref="DbContextOptions{TContext}"/> for the <see cref="DatabaseContext"/></param>
/// <param name="databaseConfiguration">The <see cref="IOptions{TOptions}"/> of <see cref="DatabaseConfiguration"/> for the <see cref="DatabaseContext"/></param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> for the <see cref="DatabaseContext"/></param>
/// <param name="databaseSeeder">The <see cref="IDatabaseSeeder"/> for the <see cref="DatabaseContext"/></param>
public MySqlDatabaseContext(DbContextOptions<MySqlDatabaseContext> dbContextOptions, IOptions<DatabaseConfiguration> databaseConfiguration, ILoggerFactory loggerFactory, IDatabaseSeeder databaseSeeder) : base(dbContextOptions, databaseConfiguration, loggerFactory, databaseSeeder)
{ }
/// <inheritdoc />
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
base.OnConfiguring(options);
options.UseMySQL(ConnectionString);
}
}
}
@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Tgstation.Server.Host.Configuration;
namespace Tgstation.Server.Host.Models
{
/// <summary>
/// <see cref="DatabaseContext"/> for Sqlserver
/// </summary>
sealed class SqlServerDatabaseContext : DatabaseContext<SqlServerDatabaseContext>
{
/// <summary>
/// Construct a <see cref="SqlServerDatabaseContext"/>
/// </summary>
/// <param name="dbContextOptions">The <see cref="DbContextOptions{TContext}"/> for the <see cref="DatabaseContext"/></param>
/// <param name="databaseConfiguration">The <see cref="IOptions{TOptions}"/> of <see cref="DatabaseConfiguration"/> for the <see cref="DatabaseContext"/></param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> for the <see cref="DatabaseContext"/></param>
/// <param name="databaseSeeder">The <see cref="IDatabaseSeeder"/> for the <see cref="DatabaseContext"/></param>
public SqlServerDatabaseContext(DbContextOptions<SqlServerDatabaseContext> dbContextOptions, IOptions<DatabaseConfiguration> databaseConfiguration, ILoggerFactory loggerFactory, IDatabaseSeeder databaseSeeder) : base(dbContextOptions, databaseConfiguration, loggerFactory, databaseSeeder)
{ }
/// <inheritdoc />
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
base.OnConfiguring(options);
options.UseSqlServer(ConnectionString);
}
}
}
@@ -0,0 +1,30 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Tgstation.Server.Host.Configuration;
namespace Tgstation.Server.Host.Models
{
/// <summary>
/// <see cref="DatabaseContext"/> for Sqlite
/// </summary>
sealed class SqliteDatabaseContext : DatabaseContext<SqliteDatabaseContext>
{
/// <summary>
/// Construct a <see cref="SqliteDatabaseContext"/>
/// </summary>
/// <param name="dbContextOptions">The <see cref="DbContextOptions{TContext}"/> for the <see cref="DatabaseContext"/></param>
/// <param name="databaseConfiguration">The <see cref="IOptions{TOptions}"/> of <see cref="DatabaseConfiguration"/> for the <see cref="DatabaseContext"/></param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/> for the <see cref="DatabaseContext"/></param>
/// <param name="databaseSeeder">The <see cref="IDatabaseSeeder"/> for the <see cref="DatabaseContext"/></param>
public SqliteDatabaseContext(DbContextOptions<SqliteDatabaseContext> dbContextOptions, IOptions<DatabaseConfiguration> databaseConfiguration, ILoggerFactory loggerFactory, IDatabaseSeeder databaseSeeder) : base(dbContextOptions, databaseConfiguration, loggerFactory, databaseSeeder)
{ }
/// <inheritdoc />
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
base.OnConfiguring(options);
options.UseSqlite(ConnectionString);
}
}
}
@@ -41,13 +41,19 @@
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.1.0-preview2-final" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.0-preview2-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0-preview2-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.0-preview2-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0-preview2-final" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0-preview2-final" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="6.10.6" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.10-rc" />
<PackageReference Include="Octokit" Version="0.29.0" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="1.7.17" />
<PackageReference Include="ZNetCS.AspNetCore.Logging.EntityFrameworkCore" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Tgstation.Server.Api\Tgstation.Server.Api.csproj" />
@@ -1,24 +0,0 @@
{
"Logging": {
"IncludeScopes": false,
"Debug": {
"LogLevel": {
"Default": "Debug"
}
},
"Console": {
"LogLevel": {
"Default": "Trace"
}
},
"EntityFramework": {
"LogLevel": {
"Default": "Warning"
}
}
},
"Database": {
"DatabaseType": "Sqlite",
"ConnectionString": "Data Source=TestDB.sqlite3"
}
}