This commit is contained in:
@@ -15,7 +15,7 @@ namespace AyaNova.Models
|
||||
public virtual DbSet<UserOptions> UserOptions { get; set; }
|
||||
public virtual DbSet<License> License { get; set; }
|
||||
public virtual DbSet<Widget> Widget { get; set; }
|
||||
public virtual DbSet<FileAttachment> FileAttachment { get; set; }
|
||||
public virtual DbSet<FileAttachment> FileAttachment { get; set; }
|
||||
public virtual DbSet<OpsJob> OpsJob { get; set; }
|
||||
public virtual DbSet<OpsJobLog> OpsJobLog { get; set; }
|
||||
public virtual DbSet<Locale> Locale { get; set; }
|
||||
@@ -40,7 +40,7 @@ namespace AyaNova.Models
|
||||
{
|
||||
// Replace table names
|
||||
//entity.Relational().TableName = "a" + entity.Relational().TableName.ToLowerInvariant();
|
||||
entity.SetTableName( "a" + entity.GetTableName().ToLowerInvariant());
|
||||
entity.SetTableName("a" + entity.GetTableName().ToLowerInvariant());
|
||||
|
||||
// Replace column names
|
||||
foreach (var property in entity.GetProperties())
|
||||
@@ -53,7 +53,7 @@ namespace AyaNova.Models
|
||||
property.SetColumnType("xid");
|
||||
// property.Relational().ColumnName = "xmin";
|
||||
// property.Relational().ColumnType = "xid";
|
||||
property.ValueGenerated = ValueGenerated.OnAddOrUpdate;
|
||||
property.ValueGenerated = ValueGenerated.OnAddOrUpdate;
|
||||
property.IsConcurrencyToken = true;
|
||||
}
|
||||
else
|
||||
@@ -63,13 +63,13 @@ namespace AyaNova.Models
|
||||
foreach (var key in entity.GetKeys())
|
||||
{
|
||||
key.SetName(key.GetName().ToLowerInvariant());
|
||||
// key.Relational().Name = key.Relational().Name.ToLowerInvariant();
|
||||
// key.Relational().Name = key.Relational().Name.ToLowerInvariant();
|
||||
}
|
||||
|
||||
foreach (var key in entity.GetForeignKeys())
|
||||
{
|
||||
//key.Relational().Name = key.Relational().Name.ToLowerInvariant();
|
||||
|
||||
|
||||
key.SetConstraintName(key.GetConstraintName().ToLowerInvariant());
|
||||
}
|
||||
|
||||
@@ -95,6 +95,15 @@ namespace AyaNova.Models
|
||||
.HasForeignKey<UserOptions>(b => b.UserId)
|
||||
.OnDelete(DeleteBehavior.Cascade);//Hopefully will delete the useroptions with the user?
|
||||
|
||||
//User->Widget this might be wrong
|
||||
modelBuilder.Entity<User>()
|
||||
.HasOne(p => p.Widget)
|
||||
.WithOne(i => i.User)
|
||||
.HasForeignKey<Widget>(b => b.UserId)
|
||||
.OnDelete(DeleteBehavior.NoAction);
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace AyaNova.Models
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
|
||||
|
||||
[Required]
|
||||
public bool Active { get; set; }
|
||||
[Required, MaxLength(255)]
|
||||
@@ -44,6 +44,9 @@ namespace AyaNova.Models
|
||||
[JsonIgnore]//hide from being returned (as null anyway) with User object in routes
|
||||
public UserOptions UserOptions { get; set; }
|
||||
|
||||
[JsonIgnore]//hide from being returned (as null anyway) with User object in routes
|
||||
public Widget Widget { get; set; }
|
||||
|
||||
public User()
|
||||
{
|
||||
Tags = new List<string>();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
@@ -14,7 +14,7 @@ namespace AyaNova.Models
|
||||
public long Id { get; set; }
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
|
||||
[Required]
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public uint Serial { get; set; }
|
||||
public decimal? DollarAmount { get; set; }
|
||||
@@ -26,10 +26,16 @@ namespace AyaNova.Models
|
||||
public int? Count { get; set; }
|
||||
public string CustomFields { get; set; }
|
||||
public List<string> Tags { get; set; }
|
||||
//relations
|
||||
//https://docs.microsoft.com/en-us/ef/core/modeling/relationships#other-relationship-patterns
|
||||
[JsonIgnore]//hide from being returned (as null anyway) with User object in routes
|
||||
public User User { get; set; }
|
||||
[Required]
|
||||
public long UserId { get; set; }
|
||||
|
||||
public Widget()
|
||||
{
|
||||
Tags = new List<string>();
|
||||
Tags = new List<string>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -209,7 +209,8 @@ namespace AyaNova.Util
|
||||
//Add widget table
|
||||
//id, text, longtext, boolean, currency,
|
||||
exec("CREATE TABLE awidget (id BIGSERIAL PRIMARY KEY, name varchar(255) not null, serial bigint not null," +
|
||||
"startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4, count integer, notes text, customfields text, tags varchar(255) ARRAY)");
|
||||
"startdate timestamp, enddate timestamp, dollaramount decimal(19,5), active bool, roles int4, count integer,"+
|
||||
"notes text, userid bigint, customfields text, tags varchar(255) ARRAY)");
|
||||
|
||||
//TEST TEST TEST ONLY FOR DEVELOPMENT TESTING TO ENSURE UNIQUENESS
|
||||
//exec("CREATE UNIQUE INDEX awidget_serial_idx ON awidget (serial);");
|
||||
|
||||
Reference in New Issue
Block a user