fixes the current date at testing phase
This commit is contained in:
parent
2e26cfcfa2
commit
65db349c0a
5 changed files with 46 additions and 22 deletions
|
|
@ -152,7 +152,7 @@ public static class HostingExtensions
|
|||
if (useInMemory)
|
||||
{
|
||||
services.AddDbContext<ApplicationDbContext>(options =>
|
||||
options.UseInMemoryDatabase("YavscInMemory"));
|
||||
options.UseSqlite("Data Source=file::memory:?cache=shared"));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -281,7 +281,7 @@ public static class HostingExtensions
|
|||
var migrationsAssembly = typeof(Program).GetTypeInfo().Assembly.GetName().Name;
|
||||
var connectionString = builder.Configuration.GetConnectionString(Constants.YavscConnectionStringName);
|
||||
bool useInMemory = builder.Configuration.GetValue<bool>("UseInMemoryDatabase", false);
|
||||
string inMemoryDatabaseName = "YavscInMemory";
|
||||
string sqliteInMemoryConnectionString = "Data Source=file::memory:?cache=shared";
|
||||
|
||||
var identityServerBuilder = builder.Services.AddIdentityServer(options =>
|
||||
{
|
||||
|
|
@ -303,7 +303,7 @@ public static class HostingExtensions
|
|||
{
|
||||
if (useInMemory)
|
||||
{
|
||||
options.ConfigureDbContext = b => b.UseInMemoryDatabase(inMemoryDatabaseName);
|
||||
options.ConfigureDbContext = b => b.UseSqlite(sqliteInMemoryConnectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -328,7 +328,7 @@ public static class HostingExtensions
|
|||
{
|
||||
if (useInMemory)
|
||||
{
|
||||
options.ConfigureDbContext = b => b.UseInMemoryDatabase(inMemoryDatabaseName);
|
||||
options.ConfigureDbContext = b => b.UseSqlite(sqliteInMemoryConnectionString);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@
|
|||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" />
|
||||
<PackageReference Include="Google.Apis.Compute.v1" />
|
||||
|
|
|
|||
|
|
@ -42,18 +42,30 @@ namespace Yavsc.Models
|
|||
}
|
||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
|
||||
{
|
||||
if (Database.IsRelational())
|
||||
{
|
||||
Database.SetCommandTimeout(180);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
if (Database.IsNpgsql())
|
||||
{
|
||||
NOW_SQL="LOCALTIMESTAMP";
|
||||
}
|
||||
else
|
||||
{
|
||||
NOW_SQL="CURRENT_TIMESTAMP";
|
||||
}
|
||||
builder.UseIdentityByDefaultColumns();
|
||||
|
||||
// Customize the ASP.NET Identity model and override the defaults if needed.
|
||||
// For example, you can rename the ASP.NET Identity table names and more.
|
||||
// Add your customizations after calling base.OnModelCreating(builder);
|
||||
builder.Entity<Contact>().HasKey(x => new { x.OwnerId, x.UserId });
|
||||
builder.Entity<DeviceDeclaration>().Property(x => x.DeclarationDate).HasDefaultValueSql("LOCALTIMESTAMP");
|
||||
builder.Entity<DeviceDeclaration>().Property(x => x.DeclarationDate).HasDefaultValueSql(NOW_SQL);
|
||||
builder.Entity<BlogTag>().HasKey(x => new { x.PostId, x.TagId });
|
||||
|
||||
builder.Entity<ApplicationUser>().Property(u => u.FullName).IsRequired(false);
|
||||
|
|
@ -337,6 +349,6 @@ namespace Yavsc.Models
|
|||
public DbSet<DeviceFlowCodes> DeviceFlowCodes { get; set; }
|
||||
|
||||
public DbSet<YavscApiScope> YavscApiScopes { get; set; }
|
||||
|
||||
public string NOW_SQL { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue