From 6bc7ec9ced7e5b773e4c25635c1d8c50c2a6de8c Mon Sep 17 00:00:00 2001 From: Dao Yu Lai Date: Mon, 30 Dec 2024 15:29:54 -0800 Subject: [PATCH] MMI-244 Fixed CBRA report issues - fixed the time zone issues that the publish on time in db has time zone info, updated the view to convert it to local time - updated staff summary time to show in hh:mm:ss format --- .../Down/PostDown/00-CbraReportFunctions.sql | 334 + .../Up/PostUp/00-CbraReportFunctions.sql | 334 + .../20241230195906_1.3.14.Designer.cs | 7485 +++++++++++++++++ .../dal/Migrations/20241230195906_1.3.14.cs | 27 + .../dal/Migrations/TNOContextModelSnapshot.cs | 81 +- libs/net/entities/CBRAReportStaffSummary.cs | 2 +- libs/net/reports/CBRAReport.cs | 2 +- 7 files changed, 8231 insertions(+), 34 deletions(-) create mode 100644 libs/net/dal/Migrations/1.3.14/Down/PostDown/00-CbraReportFunctions.sql create mode 100644 libs/net/dal/Migrations/1.3.14/Up/PostUp/00-CbraReportFunctions.sql create mode 100644 libs/net/dal/Migrations/20241230195906_1.3.14.Designer.cs create mode 100644 libs/net/dal/Migrations/20241230195906_1.3.14.cs diff --git a/libs/net/dal/Migrations/1.3.14/Down/PostDown/00-CbraReportFunctions.sql b/libs/net/dal/Migrations/1.3.14/Down/PostDown/00-CbraReportFunctions.sql new file mode 100644 index 000000000..1286af47b --- /dev/null +++ b/libs/net/dal/Migrations/1.3.14/Down/PostDown/00-CbraReportFunctions.sql @@ -0,0 +1,334 @@ +DO $$ +BEGIN + +-- CBRA report view -- +CREATE OR REPLACE VIEW public.vw_cbra_published_contents AS +SELECT DISTINCT + c.id + , c.source + , c.source_id + , c.series_id + , c.media_type_id + , c.published_on + , COALESCE(ss.name, '') AS series_name +FROM content c +LEFT JOIN source s ON c.source_id = s.id +LEFT JOIN series ss ON c.series_id = ss.id +JOIN ( + SELECT unnest(string_to_array(setting.value::TEXT, ','::TEXT)::INTEGER[]) AS media_type_id + FROM setting + WHERE setting.name::text = 'CBRAReportMediaTypeIds'::TEXT + ) m ON c.media_type_id = m.media_type_id +WHERE ((ss.id IS NOT NULL AND ss.is_cbra_source = true) + OR (ss.id IS NULL AND s.is_cbra_source = true)) +AND c.status = 2; + +DROP FUNCTION IF EXISTS public.fn_cbra_report_total_entries(date, date); +DROP FUNCTION IF EXISTS public.fn_cbra_report_totals_by_broadcaster(date, date); +DROP FUNCTION IF EXISTS public.fn_cbra_report_totals_by_program(date, date); +DROP FUNCTION IF EXISTS public.fn_cbra_report_staff_summary(date, date); +DROP FUNCTION IF EXISTS public.fn_cbra_report_total_excerpts(date, date); + +-- Function: fn_cbra_report_total_excerpts +CREATE OR REPLACE FUNCTION public.fn_cbra_report_total_excerpts ( + f_from_date DATE + , f_to_date DATE + ) + RETURNS TABLE(category CHARACTER varying, totals numeric) + LANGUAGE 'plpgsql' +AS $BODY$ +DECLARE cbra_unqualified integer; +DECLARE cbra_totals integer; +DECLARE cbra_action_id integer; +BEGIN + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_content_total_excerpts ( + content_id NUMERIC + ); + INSERT INTO temp_table_content_total_excerpts + SELECT DISTINCT c.id + FROM public.vw_cbra_published_contents c + WHERE c.published_on >= f_from_date + AND c.published_on <= f_to_date; + + SELECT + CAST("value" AS INTEGER) INTO cbra_action_id + FROM setting + WHERE "name" = 'CBRAUnqualifiedActionId' + LIMIT 1; + + SELECT COUNT(*) INTO cbra_unqualified + FROM content_action ca + JOIN temp_table_content_total_excerpts c ON ca.content_id = c.content_id + WHERE ca.action_id = cbra_action_id + AND CASE WHEN ca.value = '' + THEN false + ELSE CAST(ca.value AS BOOLEAN) + END = true; + + SELECT COUNT(*) INTO cbra_totals + FROM temp_table_content_total_excerpts; + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_total_excerpts ( + category VARCHAR(255) + , totals NUMERIC + ); + INSERT INTO temp_table_total_excerpts + SELECT + 'Total Number of Excerpts' + , (cbra_totals - cbra_unqualified); + + INSERT INTO temp_table_total_excerpts + SELECT + 'Total Number of Excerpts which do not meet the definition of Qualified Subject Matter' + , cbra_unqualified; + + INSERT iNto temp_table_total_excerpts + SELECT + 'Total Number of Excerpts over 10 min.' + , ( + SELECT COUNT(*) + FROM temp_table_content_total_excerpts c + LEFT JOIN file_reference f ON f.content_id = c.content_id + WHERE COALESCE(f.running_time,0)/60000 >= 10 + ); + + INSERT INTO temp_table_total_excerpts + SELECT + 'Total' + , cbra_totals; + + RETURN query + SELECT + tt.category + , CAST(tt.totals AS DECIMAL) AS totals + FROM temp_table_total_excerpts tt; + + DROP TABLE IF EXISTS temp_table_content_total_excerpts; + DROP TABLE IF EXISTS temp_table_total_excerpts; + +END; +$BODY$; + +-- Function: fn_cbra_report_staff_summary +CREATE OR REPLACE FUNCTION public.fn_cbra_report_staff_summary ( + f_from_date DATE + , f_to_date DATE + ) +RETURNS TABLE(staff TEXT, cbra_hours NUMERIC) +LANGUAGE 'plpgsql' +AS $BODY$ +BEGIN + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_staff_summary AS + SELECT + tt.user_id + , CAST(SUM(COALESCE(tt.Effort,0)) AS DECIMAL) AS cbra_hours + FROM time_tracking tt + JOIN public.vw_cbra_published_contents c ON tt.content_id = c.id + WHERE c.published_on >= f_from_date + AND c.published_on <= f_to_date + GROUP BY tt.user_id; + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_user_table_staff_summary AS + SELECT DISTINCT + id + , first_name + , last_name + FROM public.user; + + RETURN query + + SELECT + u.first_name || ' ' || u.last_name + , tt.cbra_hours + FROM temp_table_staff_summary tt + JOIN temp_user_table_staff_summary u ON tt.user_id = u.id; + + DROP TABLE temp_table_staff_summary; + DROP TABLE temp_user_table_staff_summary; +END; +$BODY$; + +-- Function: fn_cbra_report_total_entries +CREATE OR REPLACE FUNCTION public.fn_cbra_report_total_entries ( + f_from_date DATE + , f_to_date DATE + ) +RETURNS TABLE ( + day_of_week TEXT + , total_count NUMERIC + , total_cbra NUMERIC +) +LANGUAGE 'plpgsql' +AS $BODY$ +BEGIN + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_total_table_total_entries AS + SELECT + DATE_PART('dow', published_on) AS day_of_week + , COUNT(*) AS total_count + FROM content + WHERE published_on >= f_from_date + AND published_on <= f_to_date + GROUP BY DATE_PART('dow', published_on); + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_cbra_total_table_total_entries AS + SELECT + DATE_PART('dow', c.published_on) AS day_of_week + , COUNT(c.*) AS total_count + FROM public.vw_cbra_published_contents c + WHERE c.published_on >= f_from_date + AND c.published_on <= f_to_date + GROUP BY DATE_PART('dow', c.published_on); + + RETURN query + SELECT + CASE + WHEN tt.day_of_week=0 THEN 'Sunday' + WHEN tt.day_of_week=1 THEN 'Monday' + WHEN tt.day_of_week=2 THEN 'Tuesday' + WHEN tt.day_of_week=3 THEN 'Wednesday' + WHEN tt.day_of_week=4 THEN 'Thursday' + WHEN tt.day_of_week=5 THEN 'Friday' + WHEN tt.day_of_week=6 THEN 'Saturday' + ELSE 'other' + END AS day_of_week + , CAST(COALESCE(tt.total_count,0) AS DECIMAL) AS total_count + , CAST(COALESCE(c.total_count, 0) AS DECIMAL) AS total_cbra + FROM temp_total_table_total_entries tt + LEFT JOIN temp_cbra_total_table_total_entries c ON tt.day_of_week = c.day_of_week; + + DROP TABLE IF EXISTS temp_total_table_total_entries; + DROP TABLE IF EXISTS temp_cbra_total_table_total_entries; +END; +$BODY$; + +-- Function: fn_cbra_report_totals_by_broadcaster +CREATE OR REPLACE FUNCTION public.fn_cbra_report_totals_by_broadcaster ( + f_from_date DATE, + f_to_date DATE +) +RETURNS TABLE ( + source_type CHARACTER varying + , total_running_time TEXT + , percentage_of_total_running_time NUMERIC +) +LANGUAGE 'plpgsql' +AS $BODY$ +DECLARE sum_total_running_time NUMERIC; +begin + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_content_by_broadcaster ( + content_id NUMERIC, + source CHARACTER varying(100) + ); + INSERT INTO temp_table_content_by_broadcaster + SELECT DISTINCT c.id, c.source + FROM public.vw_cbra_published_contents c + WHERE c.published_on >= f_from_date + AND c.published_on <= f_to_date; + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_by_broadcaster AS + SELECT + c.source, + SUM(COALESCE(f.running_time,0)) AS total_running_time + FROM temp_table_content_by_broadcaster c + LEFT JOIN file_reference f ON f.content_id = c.content_id + GROUP BY c.source; + + select sum(COALESCE(tt.total_running_time,0)) INTO sum_total_running_time + from temp_table_by_broadcaster tt; + + RETURN query + SELECT + tt.source + , TO_CHAR((CAST(COALESCE(tt.total_running_time,0) AS DECIMAL)/1000)*'1 SECOND'::INTERVAL, 'HH24:MI:SS') AS total_running_time + , COALESCE(tt.total_running_time,0) / CASE COALESCE(sum_total_running_time,0) + WHEN 0 THEN 1 + ELSE COALESCE(sum_total_running_time,0) + END AS percentage_of_total_running_time + FROM temp_table_by_broadcaster tt; + + DROP TABLE IF EXISTS temp_table_content_by_broadcaster; + DROP TABLE IF EXISTS temp_table_by_broadcaster; + +END; +$BODY$; + +-- Function: fn_cbra_report_totals_by_program +CREATE OR REPLACE FUNCTION public.fn_cbra_report_totals_by_program( + f_from_date DATE, + f_to_date DATE) + RETURNS TABLE( + media_type CHARACTER varying + , source_type CHARACTER varying + , series CHARACTER varying + , total_count BIGINT + , total_running_time TEXT + , percentage_of_total_running_time NUMERIC + ) + LANGUAGE 'plpgsql' +AS $BODY$ +DECLARE sum_total_running_time NUMERIC; +BEGIN + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_content_by_program ( + content_id NUMERIC, + source CHARACTER VARYING(100), + source_id NUMERIC, + series_id NUMERIC, + series_name CHARACTER VARYING(100), + media_type_id INTEGER, + media_type_name CHARACTER VARYING(100)); + INSERT INTO temp_table_content_by_program + SELECT DISTINCT + c.id + , c.source + , c.source_id + , c.series_id + , c.series_name + , c.media_type_id + , COALESCE(mm.name, '') + FROM public.vw_cbra_published_contents c + JOIN media_type mm ON mm.id = c.media_type_id + WHERE c.published_on >= f_from_date + AND c.published_on <= f_to_date; + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_by_program AS + SELECT + c.media_type_id, + c.source, + c.source_id, + c.series_id, + c.series_name, + c.media_type_name, + COUNT(*) AS total_count, + SUM(COALESCE(f.running_time,0)) AS total_running_time + FROM temp_table_content_by_program c + LEFT JOIN file_reference f ON f.content_id = c.content_id + GROUP BY c.media_type_id, c.source, c.source_id, c.series_id, c.series_name, c.media_type_name; + + SELECT SUM(COALESCE(tt.total_running_time,0)) INTO sum_total_running_time + FROM temp_table_by_program tt; + + RETURN query + SELECT + tt.media_type_name AS media_type, + tt.source, + tt.series_name, + tt.total_count, + TO_CHAR((cast(COALESCE(tt.total_running_time,0) AS DECIMAL)/1000)*'1 SECOND'::INTERVAL, 'HH24:MI:SS') AS total_running_time, + COALESCE(tt.total_running_time,0) / CASE COALESCE(sum_total_running_time,0) + WHEN 0 THEN 1 + ELSE COALESCE(sum_total_running_time,0) + END AS percentage_of_total_running_time + FROM temp_table_by_program tt; + + DROP TABLE IF EXISTS temp_table_content_by_program; + DROP TABLE IF EXISTS temp_table_by_program; + +END; +$BODY$; + +END $$; diff --git a/libs/net/dal/Migrations/1.3.14/Up/PostUp/00-CbraReportFunctions.sql b/libs/net/dal/Migrations/1.3.14/Up/PostUp/00-CbraReportFunctions.sql new file mode 100644 index 000000000..fe5ed2c18 --- /dev/null +++ b/libs/net/dal/Migrations/1.3.14/Up/PostUp/00-CbraReportFunctions.sql @@ -0,0 +1,334 @@ +DO $$ +BEGIN + +-- CBRA report view -- +CREATE OR REPLACE VIEW public.vw_cbra_published_contents AS +SELECT DISTINCT + c.id + , c.source + , c.source_id + , c.series_id + , c.media_type_id + , timezone('utc'::text, timezone('America/Vancouver'::text, c.published_on)) AS published_on + , COALESCE(ss.name, '') AS series_name +FROM content c +LEFT JOIN source s ON c.source_id = s.id +LEFT JOIN series ss ON c.series_id = ss.id +JOIN ( + SELECT unnest(string_to_array(setting.value::TEXT, ','::TEXT)::INTEGER[]) AS media_type_id + FROM setting + WHERE setting.name::text = 'CBRAReportMediaTypeIds'::TEXT + ) m ON c.media_type_id = m.media_type_id +WHERE ((ss.id IS NOT NULL AND ss.is_cbra_source = true) + OR (ss.id IS NULL AND s.is_cbra_source = true)) +AND c.status = 2; + +DROP FUNCTION IF EXISTS public.fn_cbra_report_total_entries(date, date); +DROP FUNCTION IF EXISTS public.fn_cbra_report_totals_by_broadcaster(date, date); +DROP FUNCTION IF EXISTS public.fn_cbra_report_totals_by_program(date, date); +DROP FUNCTION IF EXISTS public.fn_cbra_report_staff_summary(date, date); +DROP FUNCTION IF EXISTS public.fn_cbra_report_total_excerpts(date, date); + +-- Function: fn_cbra_report_total_excerpts +CREATE OR REPLACE FUNCTION public.fn_cbra_report_total_excerpts ( + f_from_date DATE + , f_to_date DATE + ) + RETURNS TABLE(category CHARACTER varying, totals numeric) + LANGUAGE 'plpgsql' +AS $BODY$ +DECLARE cbra_unqualified integer; +DECLARE cbra_totals integer; +DECLARE cbra_action_id integer; +BEGIN + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_content_total_excerpts ( + content_id NUMERIC + ); + INSERT INTO temp_table_content_total_excerpts + SELECT DISTINCT c.id + FROM public.vw_cbra_published_contents c + WHERE c.published_on >= f_from_date + AND c.published_on < f_to_date + '1 day'::interval; + + SELECT + CAST("value" AS INTEGER) INTO cbra_action_id + FROM setting + WHERE "name" = 'CBRAUnqualifiedActionId' + LIMIT 1; + + SELECT COUNT(*) INTO cbra_unqualified + FROM content_action ca + JOIN temp_table_content_total_excerpts c ON ca.content_id = c.content_id + WHERE ca.action_id = cbra_action_id + AND CASE WHEN ca.value = '' + THEN false + ELSE CAST(ca.value AS BOOLEAN) + END = true; + + SELECT COUNT(*) INTO cbra_totals + FROM temp_table_content_total_excerpts; + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_total_excerpts ( + category VARCHAR(255) + , totals NUMERIC + ); + INSERT INTO temp_table_total_excerpts + SELECT + 'Total Number of Excerpts' + , (cbra_totals - cbra_unqualified); + + INSERT INTO temp_table_total_excerpts + SELECT + 'Total Number of Excerpts which do not meet the definition of Qualified Subject Matter' + , cbra_unqualified; + + INSERT iNto temp_table_total_excerpts + SELECT + 'Total Number of Excerpts over 10 min.' + , ( + SELECT COUNT(*) + FROM temp_table_content_total_excerpts c + LEFT JOIN file_reference f ON f.content_id = c.content_id + WHERE COALESCE(f.running_time,0)/60000 >= 10 + ); + + INSERT INTO temp_table_total_excerpts + SELECT + 'Total' + , cbra_totals; + + RETURN query + SELECT + tt.category + , CAST(tt.totals AS DECIMAL) AS totals + FROM temp_table_total_excerpts tt; + + DROP TABLE IF EXISTS temp_table_content_total_excerpts; + DROP TABLE IF EXISTS temp_table_total_excerpts; + +END; +$BODY$; + +-- Function: fn_cbra_report_staff_summary +CREATE OR REPLACE FUNCTION public.fn_cbra_report_staff_summary ( + f_from_date DATE + , f_to_date DATE + ) +RETURNS TABLE(staff TEXT, cbra_hours TEXT) +LANGUAGE 'plpgsql' +AS $BODY$ +BEGIN + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_staff_summary AS + SELECT + tt.user_id + , TO_CHAR((CAST(SUM(COALESCE(tt.Effort,0))*60 AS DECIMAL))*'1 SECOND'::INTERVAL, 'HH24:MI:SS') AS cbra_hours + FROM time_tracking tt + JOIN public.vw_cbra_published_contents c ON tt.content_id = c.id + WHERE c.published_on >= f_from_date + AND c.published_on < f_to_date + '1 day'::interval + GROUP BY tt.user_id; + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_user_table_staff_summary AS + SELECT DISTINCT + id + , first_name + , last_name + FROM public.user; + + RETURN query + + SELECT + u.first_name || ' ' || u.last_name + , tt.cbra_hours + FROM temp_table_staff_summary tt + JOIN temp_user_table_staff_summary u ON tt.user_id = u.id; + + DROP TABLE temp_table_staff_summary; + DROP TABLE temp_user_table_staff_summary; +END; +$BODY$; + +-- Function: fn_cbra_report_total_entries +CREATE OR REPLACE FUNCTION public.fn_cbra_report_total_entries ( + f_from_date DATE + , f_to_date DATE + ) +RETURNS TABLE ( + day_of_week TEXT + , total_count NUMERIC + , total_cbra NUMERIC +) +LANGUAGE 'plpgsql' +AS $BODY$ +BEGIN + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_total_table_total_entries AS + SELECT + DATE_PART('dow', published_on) AS day_of_week + , COUNT(*) AS total_count + FROM content + WHERE timezone('utc'::text, timezone('America/Vancouver'::text, published_on)) >= f_from_date + AND timezone('utc'::text, timezone('America/Vancouver'::text, published_on)) < f_to_date + '1 day'::interval + GROUP BY DATE_PART('dow', published_on); + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_cbra_total_table_total_entries AS + SELECT + DATE_PART('dow', c.published_on) AS day_of_week + , COUNT(c.*) AS total_count + FROM public.vw_cbra_published_contents c + WHERE c.published_on >= f_from_date + AND c.published_on < f_to_date + '1 day'::interval + GROUP BY DATE_PART('dow', c.published_on); + + RETURN query + SELECT + CASE + WHEN tt.day_of_week=0 THEN 'Sunday' + WHEN tt.day_of_week=1 THEN 'Monday' + WHEN tt.day_of_week=2 THEN 'Tuesday' + WHEN tt.day_of_week=3 THEN 'Wednesday' + WHEN tt.day_of_week=4 THEN 'Thursday' + WHEN tt.day_of_week=5 THEN 'Friday' + WHEN tt.day_of_week=6 THEN 'Saturday' + ELSE 'other' + END AS day_of_week + , CAST(COALESCE(tt.total_count,0) AS DECIMAL) AS total_count + , CAST(COALESCE(c.total_count, 0) AS DECIMAL) AS total_cbra + FROM temp_total_table_total_entries tt + LEFT JOIN temp_cbra_total_table_total_entries c ON tt.day_of_week = c.day_of_week; + + DROP TABLE IF EXISTS temp_total_table_total_entries; + DROP TABLE IF EXISTS temp_cbra_total_table_total_entries; +END; +$BODY$; + +-- Function: fn_cbra_report_totals_by_broadcaster +CREATE OR REPLACE FUNCTION public.fn_cbra_report_totals_by_broadcaster ( + f_from_date DATE, + f_to_date DATE +) +RETURNS TABLE ( + source_type CHARACTER varying + , total_running_time TEXT + , percentage_of_total_running_time NUMERIC +) +LANGUAGE 'plpgsql' +AS $BODY$ +DECLARE sum_total_running_time NUMERIC; +begin + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_content_by_broadcaster ( + content_id NUMERIC, + source CHARACTER varying(100) + ); + INSERT INTO temp_table_content_by_broadcaster + SELECT DISTINCT c.id, c.source + FROM public.vw_cbra_published_contents c + WHERE c.published_on >= f_from_date + AND c.published_on < f_to_date + '1 day'::interval; + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_by_broadcaster AS + SELECT + c.source, + SUM(COALESCE(f.running_time,0)) AS total_running_time + FROM temp_table_content_by_broadcaster c + LEFT JOIN file_reference f ON f.content_id = c.content_id + GROUP BY c.source; + + select sum(COALESCE(tt.total_running_time,0)) INTO sum_total_running_time + from temp_table_by_broadcaster tt; + + RETURN query + SELECT + tt.source + , TO_CHAR((CAST(COALESCE(tt.total_running_time,0) AS DECIMAL)/1000)*'1 SECOND'::INTERVAL, 'HH24:MI:SS') AS total_running_time + , COALESCE(tt.total_running_time,0) / CASE COALESCE(sum_total_running_time,0) + WHEN 0 THEN 1 + ELSE COALESCE(sum_total_running_time,0) + END AS percentage_of_total_running_time + FROM temp_table_by_broadcaster tt; + + DROP TABLE IF EXISTS temp_table_content_by_broadcaster; + DROP TABLE IF EXISTS temp_table_by_broadcaster; + +END; +$BODY$; + +-- Function: fn_cbra_report_totals_by_program +CREATE OR REPLACE FUNCTION public.fn_cbra_report_totals_by_program( + f_from_date DATE, + f_to_date DATE) + RETURNS TABLE( + media_type CHARACTER varying + , source_type CHARACTER varying + , series CHARACTER varying + , total_count BIGINT + , total_running_time TEXT + , percentage_of_total_running_time NUMERIC + ) + LANGUAGE 'plpgsql' +AS $BODY$ +DECLARE sum_total_running_time NUMERIC; +BEGIN + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_content_by_program ( + content_id NUMERIC, + source CHARACTER VARYING(100), + source_id NUMERIC, + series_id NUMERIC, + series_name CHARACTER VARYING(100), + media_type_id INTEGER, + media_type_name CHARACTER VARYING(100)); + INSERT INTO temp_table_content_by_program + SELECT DISTINCT + c.id + , c.source + , c.source_id + , c.series_id + , c.series_name + , c.media_type_id + , COALESCE(mm.name, '') + FROM public.vw_cbra_published_contents c + JOIN media_type mm ON mm.id = c.media_type_id + WHERE c.published_on >= f_from_date + AND c.published_on < f_to_date + '1 day'::interval; + + CREATE TEMPORARY TABLE IF NOT EXISTS temp_table_by_program AS + SELECT + c.media_type_id, + c.source, + c.source_id, + c.series_id, + c.series_name, + c.media_type_name, + COUNT(*) AS total_count, + SUM(COALESCE(f.running_time,0)) AS total_running_time + FROM temp_table_content_by_program c + LEFT JOIN file_reference f ON f.content_id = c.content_id + GROUP BY c.media_type_id, c.source, c.source_id, c.series_id, c.series_name, c.media_type_name; + + SELECT SUM(COALESCE(tt.total_running_time,0)) INTO sum_total_running_time + FROM temp_table_by_program tt; + + RETURN query + SELECT + tt.media_type_name AS media_type, + tt.source, + tt.series_name, + tt.total_count, + TO_CHAR((cast(COALESCE(tt.total_running_time,0) AS DECIMAL)/1000)*'1 SECOND'::INTERVAL, 'HH24:MI:SS') AS total_running_time, + COALESCE(tt.total_running_time,0) / CASE COALESCE(sum_total_running_time,0) + WHEN 0 THEN 1 + ELSE COALESCE(sum_total_running_time,0) + END AS percentage_of_total_running_time + FROM temp_table_by_program tt; + + DROP TABLE IF EXISTS temp_table_content_by_program; + DROP TABLE IF EXISTS temp_table_by_program; + +END; +$BODY$; + +END $$; diff --git a/libs/net/dal/Migrations/20241230195906_1.3.14.Designer.cs b/libs/net/dal/Migrations/20241230195906_1.3.14.Designer.cs new file mode 100644 index 000000000..3822a654f --- /dev/null +++ b/libs/net/dal/Migrations/20241230195906_1.3.14.Designer.cs @@ -0,0 +1,7485 @@ +// +using System; +using System.Collections.Generic; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using TNO.DAL; +using TNO.Entities.Models; + +#nullable disable + +namespace TNO.DAL.Migrations +{ + [DbContext(typeof(TNOContext))] + [Migration("20241230195906_1.3.14")] + partial class _1314 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "9.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("TNO.Entities.AVOverviewInstance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("IsPublished") + .HasColumnType("boolean"); + + b.Property("PublishedOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("published_on"); + + b.Property("Response") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("response") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("TemplateType") + .HasColumnType("integer") + .HasColumnName("template_type"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("PublishedOn") + .IsUnique(); + + b.HasIndex("TemplateType", "PublishedOn"); + + b.ToTable("av_overview_instance"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewSection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Anchors") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("anchors"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("InstanceId") + .HasColumnType("bigint") + .HasColumnName("av_overview_instance_id"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("OtherSource") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("other_source"); + + b.Property("SeriesId") + .HasColumnType("integer") + .HasColumnName("series_id"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasColumnName("sort_order"); + + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("StartTime") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character varying(8)") + .HasColumnName("start_time"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId"); + + b.HasIndex("SeriesId"); + + b.HasIndex("SourceId"); + + b.ToTable("av_overview_section"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewSectionItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("ItemType") + .HasColumnType("integer") + .HasColumnName("item_type"); + + b.Property("SectionId") + .HasColumnType("integer") + .HasColumnName("av_overview_section_id"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasColumnName("sort_order"); + + b.Property("Summary") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("summary"); + + b.Property("Time") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character varying(8)") + .HasColumnName("time"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("ContentId"); + + b.HasIndex("SectionId"); + + b.ToTable("av_overview_section_item"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewTemplate", b => + { + b.Property("TemplateType") + .HasColumnType("integer") + .HasColumnName("template_type"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("TemplateId") + .HasColumnType("integer") + .HasColumnName("report_template_id"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("TemplateType"); + + b.HasIndex("TemplateId"); + + b.ToTable("av_overview_template"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewTemplateSection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Anchors") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("anchors"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("OtherSource") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("other_source"); + + b.Property("SeriesId") + .HasColumnType("integer") + .HasColumnName("series_id"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasColumnName("sort_order"); + + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("StartTime") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character varying(8)") + .HasColumnName("start_time"); + + b.Property("TemplateType") + .HasColumnType("integer") + .HasColumnName("av_overview_template_id"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.HasIndex("SourceId"); + + b.HasIndex("TemplateType"); + + b.ToTable("av_overview_template_section"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewTemplateSectionItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("ItemType") + .HasColumnType("integer") + .HasColumnName("item_type"); + + b.Property("SectionId") + .HasColumnType("integer") + .HasColumnName("av_overview_template_section_id"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasColumnName("sort_order"); + + b.Property("Summary") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("summary"); + + b.Property("Time") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character varying(8)") + .HasColumnName("time"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("SectionId"); + + b.ToTable("av_overview_template_section_item"); + }); + + modelBuilder.Entity("TNO.Entities.Action", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("DefaultValue") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("default_value") + .HasDefaultValueSql("''"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("ValueLabel") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("value_label") + .HasDefaultValueSql("''"); + + b.Property("ValueType") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("value_type"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "ValueType", "ValueLabel" }, "IX_action"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_action_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_name") + .IsUnique(); + + b.ToTable("action"); + }); + + modelBuilder.Entity("TNO.Entities.CBRAReportStaffSummary", b => + { + b.Property("CbraHours") + .IsRequired() + .HasColumnType("text") + .HasColumnName("cbra_hours"); + + b.Property("Staff") + .IsRequired() + .HasColumnType("text") + .HasColumnName("staff"); + + b.ToTable((string)null); + + b.ToView(null, (string)null); + }); + + modelBuilder.Entity("TNO.Entities.CBRAReportTotalEntries", b => + { + b.Property("DayOfWeek") + .IsRequired() + .HasColumnType("text") + .HasColumnName("day_of_week"); + + b.Property("TotalCbra") + .HasColumnType("numeric") + .HasColumnName("total_cbra"); + + b.Property("TotalCount") + .HasColumnType("numeric") + .HasColumnName("total_count"); + + b.ToTable((string)null); + + b.ToView(null, (string)null); + }); + + modelBuilder.Entity("TNO.Entities.CBRAReportTotalExcerpts", b => + { + b.Property("Category") + .IsRequired() + .HasColumnType("text") + .HasColumnName("category"); + + b.Property("Totals") + .HasColumnType("integer") + .HasColumnName("totals"); + + b.ToTable((string)null); + + b.ToView(null, (string)null); + }); + + modelBuilder.Entity("TNO.Entities.CBRAReportTotalsByBroadcaster", b => + { + b.Property("PercentageOfTotalRunningTime") + .HasColumnType("numeric") + .HasColumnName("percentage_of_total_running_time"); + + b.Property("SourceType") + .IsRequired() + .HasColumnType("text") + .HasColumnName("source_type"); + + b.Property("TotalRunningTime") + .IsRequired() + .HasColumnType("text") + .HasColumnName("total_running_time"); + + b.ToTable((string)null); + + b.ToView(null, (string)null); + }); + + modelBuilder.Entity("TNO.Entities.CBRAReportTotalsByProgram", b => + { + b.Property("MediaType") + .IsRequired() + .HasColumnType("text") + .HasColumnName("media_type"); + + b.Property("PercentageOfTotalRunningTime") + .HasColumnType("numeric") + .HasColumnName("percentage_of_total_running_time"); + + b.Property("Series") + .IsRequired() + .HasColumnType("text") + .HasColumnName("series"); + + b.Property("SourceType") + .IsRequired() + .HasColumnType("text") + .HasColumnName("source_type"); + + b.Property("TotalCount") + .HasColumnType("numeric") + .HasColumnName("total_count"); + + b.Property("TotalRunningTime") + .IsRequired() + .HasColumnType("text") + .HasColumnName("total_running_time"); + + b.ToTable((string)null); + + b.ToView(null, (string)null); + }); + + modelBuilder.Entity("TNO.Entities.Cache", b => + { + b.Property("Key") + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("key"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)") + .HasColumnName("value"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Key"); + + b.HasIndex(new[] { "Key", "Value" }, "IX_cache"); + + b.ToTable("cache"); + }); + + modelBuilder.Entity("TNO.Entities.ChartTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsPublic") + .HasColumnType("boolean") + .HasColumnName("is_public"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("settings") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("Template") + .IsRequired() + .HasColumnType("text") + .HasColumnName("template"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_charttemplate_is_enabled"); + + b.ToTable("chart_template"); + }); + + modelBuilder.Entity("TNO.Entities.Connection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Configuration") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("configuration") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("ConnectionType") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("connection_type"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsReadOnly") + .HasColumnType("boolean") + .HasColumnName("is_read_only"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_connection_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_name") + .IsUnique() + .HasDatabaseName("IX_name1"); + + b.ToTable("connection"); + }); + + modelBuilder.Entity("TNO.Entities.Content", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Body") + .IsRequired() + .HasColumnType("text") + .HasColumnName("body"); + + b.Property("Byline") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("byline"); + + b.Property("ContentType") + .HasColumnType("integer") + .HasColumnName("content_type"); + + b.Property("ContributorId") + .HasColumnType("integer") + .HasColumnName("contributor_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Edition") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("edition"); + + b.Property("ExternalUid") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasDefaultValue("") + .HasColumnName("external_uid"); + + b.Property("Headline") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("headline"); + + b.Property("IngestTypeId") + .HasColumnType("integer"); + + b.Property("IsApproved") + .HasColumnType("boolean") + .HasColumnName("is_approved"); + + b.Property("IsHidden") + .HasColumnType("boolean") + .HasColumnName("is_hidden"); + + b.Property("IsPrivate") + .HasColumnType("boolean") + .HasColumnName("is_private"); + + b.Property("LicenseId") + .HasColumnType("integer") + .HasColumnName("license_id"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.Property("OtherSource") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("source"); + + b.Property("OwnerId") + .HasColumnType("integer") + .HasColumnName("owner_id"); + + b.Property("Page") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasColumnName("page"); + + b.Property("PostedOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("posted_on"); + + b.Property("PublishedOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("published_on"); + + b.Property("Section") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("section"); + + b.Property("SeriesId") + .HasColumnType("integer") + .HasColumnName("series_id"); + + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("SourceUrl") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("source_url"); + + b.Property("Status") + .HasColumnType("integer") + .HasColumnName("status"); + + b.Property("Summary") + .IsRequired() + .HasColumnType("text") + .HasColumnName("summary"); + + b.Property("Uid") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("uid"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.Property>("Versions") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("versions") + .HasDefaultValueSql("'{}'::jsonb"); + + b.HasKey("Id"); + + b.HasIndex("ContributorId"); + + b.HasIndex("IngestTypeId"); + + b.HasIndex("LicenseId"); + + b.HasIndex("MediaTypeId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("SeriesId"); + + b.HasIndex("SourceId"); + + b.HasIndex(new[] { "ContentType", "OtherSource", "Uid", "Page", "Status", "IsHidden" }, "IX_content"); + + b.HasIndex(new[] { "PublishedOn", "CreatedOn" }, "IX_content_dates"); + + b.HasIndex(new[] { "Headline" }, "IX_headline"); + + b.HasIndex(new[] { "Edition", "Section", "Byline" }, "IX_print_content"); + + b.ToTable("content"); + }); + + modelBuilder.Entity("TNO.Entities.ContentAction", b => + { + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("ActionId") + .HasColumnType("integer") + .HasColumnName("action_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("character varying(150)") + .HasColumnName("value"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("ContentId", "ActionId"); + + b.HasIndex("ActionId"); + + b.ToTable("content_action"); + }); + + modelBuilder.Entity("TNO.Entities.ContentLabel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("key"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("value"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("ContentId"); + + b.HasIndex(new[] { "Key", "Value" }, "IX_content_label"); + + b.ToTable("content_label"); + }); + + modelBuilder.Entity("TNO.Entities.ContentLink", b => + { + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("LinkId") + .HasColumnType("bigint") + .HasColumnName("link_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text") + .HasColumnName("value"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("ContentId", "LinkId"); + + b.HasIndex("LinkId"); + + b.ToTable("content_link"); + }); + + modelBuilder.Entity("TNO.Entities.ContentLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("message"); + + b.Property("Status") + .HasColumnType("integer") + .HasColumnName("status"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("ContentId"); + + b.ToTable("content_log"); + }); + + modelBuilder.Entity("TNO.Entities.ContentReference", b => + { + b.Property("Source") + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("source"); + + b.Property("Uid") + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("uid"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Metadata") + .HasColumnType("jsonb") + .HasColumnName("metadata"); + + b.Property("PublishedOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("published_on"); + + b.Property("SourceUpdateOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("source_updated_on"); + + b.Property("Status") + .HasColumnType("integer") + .HasColumnName("status"); + + b.Property("Topic") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("topic"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Source", "Uid"); + + b.HasIndex(new[] { "PublishedOn", "Status" }, "IX_content_reference"); + + b.HasIndex(new[] { "Source", "Uid" }, "IX_source_uid"); + + b.ToTable("content_reference"); + }); + + modelBuilder.Entity("TNO.Entities.ContentTag", b => + { + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("TagId") + .HasColumnType("integer") + .HasColumnName("tag_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("ContentId", "TagId"); + + b.HasIndex("TagId"); + + b.ToTable("content_tag"); + }); + + modelBuilder.Entity("TNO.Entities.ContentTonePool", b => + { + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("TonePoolId") + .HasColumnType("integer") + .HasColumnName("tone_pool_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Value") + .HasColumnType("integer") + .HasColumnName("value"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("ContentId", "TonePoolId"); + + b.HasIndex("TonePoolId"); + + b.ToTable("content_tone"); + }); + + modelBuilder.Entity("TNO.Entities.ContentTopic", b => + { + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("TopicId") + .HasColumnType("integer") + .HasColumnName("topic_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Score") + .HasColumnType("integer") + .HasColumnName("score"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("ContentId", "TopicId"); + + b.HasIndex("TopicId"); + + b.ToTable("content_topic"); + }); + + modelBuilder.Entity("TNO.Entities.ContentTypeAction", b => + { + b.Property("ContentType") + .HasColumnType("integer") + .HasColumnName("content_type"); + + b.Property("ActionId") + .HasColumnType("integer") + .HasColumnName("action_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("ContentType", "ActionId"); + + b.HasIndex("ActionId"); + + b.ToTable("content_type_action"); + }); + + modelBuilder.Entity("TNO.Entities.Contributor", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Aliases") + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("aliases"); + + b.Property("AutoTranscribe") + .HasColumnType("boolean") + .HasColumnName("auto_transcribe"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsPress") + .HasColumnType("boolean") + .HasColumnName("is_press"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("SourceId"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_contributor_is_enabled"); + + b.ToTable("contributor"); + }); + + modelBuilder.Entity("TNO.Entities.DataLocation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ConnectionId") + .HasColumnType("integer") + .HasColumnName("connection_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("ConnectionId"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_datalocation_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_name") + .IsUnique() + .HasDatabaseName("IX_name2"); + + b.ToTable("data_location"); + }); + + modelBuilder.Entity("TNO.Entities.EarnedMedia", b => + { + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("ContentType") + .HasColumnType("integer") + .HasColumnName("content_type"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("LengthOfContent") + .HasColumnType("integer") + .HasColumnName("length_of_content"); + + b.Property("Rate") + .HasColumnType("real") + .HasColumnName("rate"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("SourceId", "ContentType"); + + b.ToTable("earned_media"); + }); + + modelBuilder.Entity("TNO.Entities.EventSchedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description"); + + b.Property("EventType") + .HasColumnType("integer") + .HasColumnName("event_type"); + + b.Property("FolderId") + .HasColumnType("integer") + .HasColumnName("folder_id"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("LastRanOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("last_ran_on"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("NotificationId") + .HasColumnType("integer") + .HasColumnName("notification_id"); + + b.Property("ReportId") + .HasColumnType("integer") + .HasColumnName("report_id"); + + b.Property("RequestSentOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("request_sent_on"); + + b.Property("ScheduleId") + .HasColumnType("integer") + .HasColumnName("schedule_id"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("settings") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("FolderId"); + + b.HasIndex("NotificationId"); + + b.HasIndex("ReportId"); + + b.HasIndex("ScheduleId"); + + b.ToTable("event_schedule"); + }); + + modelBuilder.Entity("TNO.Entities.FileReference", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("ContentType") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("content_type"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("FileName") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("file_name"); + + b.Property("IsSyncedToS3") + .HasColumnType("boolean") + .HasColumnName("is_synced_to_s3"); + + b.Property("IsUploaded") + .HasColumnType("boolean") + .HasColumnName("is_uploaded"); + + b.Property("LastSyncedToS3On") + .HasColumnType("timestamp with time zone") + .HasColumnName("last_synced_to_s3_on"); + + b.Property("Path") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("path"); + + b.Property("RunningTime") + .HasColumnType("bigint") + .HasColumnName("running_time"); + + b.Property("S3Path") + .HasColumnType("text") + .HasColumnName("s3_path"); + + b.Property("Size") + .HasColumnType("bigint") + .HasColumnName("size"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("ContentId"); + + b.ToTable("file_reference"); + }); + + modelBuilder.Entity("TNO.Entities.Filter", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("OwnerId") + .HasColumnType("integer") + .HasColumnName("owner_id"); + + b.Property("Query") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("query") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("settings") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId", "Name") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_filter_is_enabled"); + + b.ToTable("filter"); + }); + + modelBuilder.Entity("TNO.Entities.Folder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("FilterId") + .HasColumnType("integer") + .HasColumnName("filter_id"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("OwnerId") + .HasColumnType("integer") + .HasColumnName("owner_id"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("settings") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("FilterId"); + + b.HasIndex("OwnerId", "Name") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_folder_is_enabled"); + + b.ToTable("folder"); + }); + + modelBuilder.Entity("TNO.Entities.FolderContent", b => + { + b.Property("FolderId") + .HasColumnType("integer") + .HasColumnName("folder_id"); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("FolderId", "ContentId"); + + b.HasIndex("ContentId"); + + b.ToTable("folder_content"); + }); + + modelBuilder.Entity("TNO.Entities.Ingest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Configuration") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("configuration") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("DestinationConnectionId") + .HasColumnType("integer") + .HasColumnName("destination_connection_id"); + + b.Property("IngestTypeId") + .HasColumnType("integer") + .HasColumnName("ingest_type_id"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("name"); + + b.Property("ResetRetryAfterDelayMs") + .HasColumnType("integer") + .HasColumnName("reset_retry_after_delay_ms"); + + b.Property("RetryLimit") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(3) + .HasColumnName("retry_limit"); + + b.Property("ScheduleType") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("schedule_type"); + + b.Property("SourceConnectionId") + .HasColumnType("integer") + .HasColumnName("source_connection_id"); + + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("Topic") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("topic"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("DestinationConnectionId"); + + b.HasIndex("MediaTypeId"); + + b.HasIndex("SourceConnectionId"); + + b.HasIndex("SourceId"); + + b.HasIndex(new[] { "IngestTypeId", "SourceId", "Topic" }, "IX_ingest"); + + b.HasIndex(new[] { "Name" }, "IX_name") + .IsUnique() + .HasDatabaseName("IX_name3"); + + b.ToTable("ingest"); + }); + + modelBuilder.Entity("TNO.Entities.IngestDataLocation", b => + { + b.Property("IngestId") + .HasColumnType("integer") + .HasColumnName("ingest_id"); + + b.Property("DataLocationId") + .HasColumnType("integer") + .HasColumnName("data_location_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("IngestId", "DataLocationId"); + + b.HasIndex("DataLocationId"); + + b.ToTable("ingest_data_location"); + }); + + modelBuilder.Entity("TNO.Entities.IngestSchedule", b => + { + b.Property("IngestId") + .HasColumnType("integer") + .HasColumnName("ingest_id"); + + b.Property("ScheduleId") + .HasColumnType("integer") + .HasColumnName("schedule_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("IngestId", "ScheduleId"); + + b.HasIndex("ScheduleId"); + + b.ToTable("ingest_schedule"); + }); + + modelBuilder.Entity("TNO.Entities.IngestState", b => + { + b.Property("IngestId") + .HasColumnType("integer") + .HasColumnName("ingest_id"); + + b.Property("CreationDateOfLastItem") + .HasColumnType("timestamp with time zone") + .HasColumnName("creation_date_of_last_item"); + + b.Property("FailedAttempts") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("failed_attempts"); + + b.Property("LastRanOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("last_ran_on"); + + b.HasKey("IngestId"); + + b.ToTable("ingest_state"); + }); + + modelBuilder.Entity("TNO.Entities.IngestType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AutoTranscribe") + .HasColumnType("boolean") + .HasColumnName("auto_transcribe"); + + b.Property("ContentType") + .HasColumnType("integer") + .HasColumnName("content_type"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("DisableTranscribe") + .HasColumnType("boolean") + .HasColumnName("disable_transcribe"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_ingesttype_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_name") + .IsUnique() + .HasDatabaseName("IX_name4"); + + b.ToTable("ingest_type"); + }); + + modelBuilder.Entity("TNO.Entities.License", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("TTL") + .HasColumnType("integer") + .HasColumnName("ttl"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_license_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_name") + .IsUnique() + .HasDatabaseName("IX_name5"); + + b.ToTable("license"); + }); + + modelBuilder.Entity("TNO.Entities.MediaType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AutoTranscribe") + .HasColumnType("boolean") + .HasColumnName("auto_transcribe"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("ListOption") + .HasColumnType("integer") + .HasColumnName("list_option"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_mediatype_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_name") + .IsUnique() + .HasDatabaseName("IX_name6"); + + b.ToTable("media_type"); + }); + + modelBuilder.Entity("TNO.Entities.Metric", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_metric_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_name") + .IsUnique() + .HasDatabaseName("IX_name7"); + + b.ToTable("metric"); + }); + + modelBuilder.Entity("TNO.Entities.Minister", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Aliases") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("aliases") + .HasDefaultValueSql("''"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("OrganizationId") + .HasColumnType("integer") + .HasColumnName("organization_id"); + + b.Property("Position") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("position") + .HasDefaultValueSql("''"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.HasIndex("OrganizationId"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_minister_is_enabled"); + + b.ToTable("minister"); + }); + + modelBuilder.Entity("TNO.Entities.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AlertOnIndex") + .HasColumnType("boolean") + .HasColumnName("alert_on_index"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsPublic") + .HasColumnType("boolean") + .HasColumnName("is_public"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("NotificationType") + .HasColumnType("integer") + .HasColumnName("notification_type"); + + b.Property("OwnerId") + .HasColumnType("integer") + .HasColumnName("owner_id"); + + b.Property("Query") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("query") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("Resend") + .HasColumnType("integer") + .HasColumnName("resend"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("settings") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("TemplateId") + .HasColumnType("integer") + .HasColumnName("notification_template_id"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("TemplateId"); + + b.HasIndex("OwnerId", "Name") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_notification_is_enabled"); + + b.ToTable("notification"); + }); + + modelBuilder.Entity("TNO.Entities.NotificationInstance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Body") + .IsRequired() + .HasColumnType("text") + .HasColumnName("body"); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("NotificationId") + .HasColumnType("integer") + .HasColumnName("notification_id"); + + b.Property("OwnerId") + .HasColumnType("integer") + .HasColumnName("owner_id"); + + b.Property("Response") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("response") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SentOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("sent_on"); + + b.Property("Status") + .HasColumnType("integer") + .HasColumnName("status"); + + b.Property("Subject") + .IsRequired() + .HasColumnType("text") + .HasColumnName("subject"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("ContentId"); + + b.HasIndex("NotificationId"); + + b.ToTable("notification_instance"); + }); + + modelBuilder.Entity("TNO.Entities.NotificationTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Body") + .IsRequired() + .HasColumnType("text") + .HasColumnName("body"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsPublic") + .HasColumnType("boolean") + .HasColumnName("is_public"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("settings") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("Subject") + .IsRequired() + .HasColumnType("text") + .HasColumnName("subject"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.HasIndex("IsPublic", "IsEnabled"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_notificationtemplate_is_enabled"); + + b.ToTable("notification_template"); + }); + + modelBuilder.Entity("TNO.Entities.Organization", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("ParentId") + .HasColumnType("integer") + .HasColumnName("parent_id"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("ParentId", "Name") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_organization_is_enabled"); + + b.ToTable("organization"); + }); + + modelBuilder.Entity("TNO.Entities.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsPublic") + .HasColumnType("boolean") + .HasColumnName("is_public"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("ProductType") + .HasColumnType("integer") + .HasColumnName("product_type"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("TargetProductId") + .HasColumnType("integer") + .HasColumnName("target_product_id"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("Name", "TargetProductId", "ProductType") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_product_is_enabled"); + + b.ToTable("product"); + }); + + modelBuilder.Entity("TNO.Entities.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Byline") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("byline"); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("IsRelevant") + .HasColumnType("boolean") + .HasColumnName("is_relevant"); + + b.Property("Statement") + .IsRequired() + .HasColumnType("text") + .HasColumnName("statement"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("ContentId"); + + b.HasIndex(new[] { "Statement" }, "IX_statement"); + + b.ToTable("quote"); + }); + + modelBuilder.Entity("TNO.Entities.Report", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsPublic") + .HasColumnType("boolean") + .HasColumnName("is_public"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("OwnerId") + .HasColumnType("integer") + .HasColumnName("owner_id"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("settings") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("TemplateId") + .HasColumnType("integer") + .HasColumnName("report_template_id"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("TemplateId"); + + b.HasIndex("OwnerId", "Name") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_report_is_enabled"); + + b.ToTable("report"); + }); + + modelBuilder.Entity("TNO.Entities.ReportInstance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Body") + .IsRequired() + .HasColumnType("text") + .HasColumnName("body"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("OwnerId") + .HasColumnType("integer") + .HasColumnName("owner_id"); + + b.Property("PublishedOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("published_on"); + + b.Property("ReportId") + .HasColumnType("integer") + .HasColumnName("report_id"); + + b.Property("Response") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("response") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SentOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("sent_on"); + + b.Property("Status") + .HasColumnType("integer") + .HasColumnName("status"); + + b.Property("Subject") + .IsRequired() + .HasColumnType("text") + .HasColumnName("subject"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ReportId"); + + b.HasIndex(new[] { "PublishedOn", "CreatedOn" }, "IX_report_dates"); + + b.ToTable("report_instance"); + }); + + modelBuilder.Entity("TNO.Entities.ReportInstanceContent", b => + { + b.Property("InstanceId") + .HasColumnType("bigint") + .HasColumnName("report_instance_id"); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("SectionName") + .ValueGeneratedOnAdd() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("section_name") + .HasDefaultValueSql("''"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("InstanceId", "ContentId", "SectionName"); + + b.HasIndex("ContentId"); + + b.ToTable("report_instance_content"); + }); + + modelBuilder.Entity("TNO.Entities.ReportSection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("FilterId") + .HasColumnType("integer") + .HasColumnName("filter_id"); + + b.Property("FolderId") + .HasColumnType("integer") + .HasColumnName("folder_id"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("LinkedReportId") + .HasColumnType("integer") + .HasColumnName("linked_report_id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("ReportId") + .HasColumnType("integer") + .HasColumnName("report_id"); + + b.Property("SectionType") + .HasColumnType("integer") + .HasColumnName("section_type"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("settings") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("FilterId"); + + b.HasIndex("FolderId"); + + b.HasIndex("LinkedReportId"); + + b.HasIndex("ReportId", "Name") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_reportsection_is_enabled"); + + b.ToTable("report_section"); + }); + + modelBuilder.Entity("TNO.Entities.ReportSectionChartTemplate", b => + { + b.Property("ReportSectionId") + .HasColumnType("integer") + .HasColumnName("report_section_id"); + + b.Property("ChartTemplateId") + .HasColumnType("integer") + .HasColumnName("chart_template_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("settings") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("ReportSectionId", "ChartTemplateId"); + + b.HasIndex("ChartTemplateId"); + + b.ToTable("report_section_chart_template"); + }); + + modelBuilder.Entity("TNO.Entities.ReportTemplate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Body") + .IsRequired() + .HasColumnType("text") + .HasColumnName("body"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsPublic") + .HasColumnType("boolean") + .HasColumnName("is_public"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("ReportType") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("report_type") + .HasDefaultValueSql("0"); + + b.Property("Settings") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("settings") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("Subject") + .IsRequired() + .HasColumnType("text") + .HasColumnName("subject"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.HasIndex("IsPublic", "IsEnabled"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_reporttemplate_is_enabled"); + + b.ToTable("report_template"); + }); + + modelBuilder.Entity("TNO.Entities.ReportTemplateChartTemplate", b => + { + b.Property("ReportTemplateId") + .HasColumnType("integer") + .HasColumnName("report_template_id"); + + b.Property("ChartTemplateId") + .HasColumnType("integer") + .HasColumnName("chart_template_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("ReportTemplateId", "ChartTemplateId"); + + b.HasIndex("ChartTemplateId"); + + b.ToTable("report_template_chart_template"); + }); + + modelBuilder.Entity("TNO.Entities.Schedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("DayOfMonth") + .HasColumnType("integer") + .HasColumnName("day_of_month"); + + b.Property("DelayMS") + .HasColumnType("integer") + .HasColumnName("delay_ms"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("Repeat") + .HasColumnType("boolean") + .HasColumnName("repeat"); + + b.Property("RequestedById") + .HasColumnType("integer") + .HasColumnName("requested_by_id"); + + b.Property("RunOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("run_on"); + + b.Property("RunOnMonths") + .HasColumnType("integer") + .HasColumnName("run_on_months"); + + b.Property("RunOnWeekDays") + .HasColumnType("integer") + .HasColumnName("run_on_week_days"); + + b.Property("RunOnlyOnce") + .HasColumnType("boolean") + .HasColumnName("run_only_once"); + + b.Property("StartAt") + .HasColumnType("interval") + .HasColumnName("start_at"); + + b.Property("StopAt") + .HasColumnType("interval") + .HasColumnName("stop_at"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("RequestedById"); + + b.HasIndex(new[] { "Name", "IsEnabled" }, "IX_schedule"); + + b.ToTable("schedule"); + }); + + modelBuilder.Entity("TNO.Entities.Sentiment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("Rate") + .HasColumnType("real") + .HasColumnName("rate"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Value") + .HasColumnType("real") + .HasColumnName("value"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_sentiment_is_enabled"); + + b.ToTable("sentiment"); + }); + + modelBuilder.Entity("TNO.Entities.Series", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AutoTranscribe") + .HasColumnType("boolean") + .HasColumnName("auto_transcribe"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsCBRASource") + .HasColumnType("boolean") + .HasColumnName("is_cbra_source"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsOther") + .HasColumnType("boolean") + .HasColumnName("is_other"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UseInTopics") + .HasColumnType("boolean") + .HasColumnName("use_in_topics"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("SourceId"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_series_is_enabled"); + + b.ToTable("series"); + }); + + modelBuilder.Entity("TNO.Entities.SeriesMediaTypeSearchMapping", b => + { + b.Property("SeriesId") + .HasColumnType("integer") + .HasColumnName("series_id"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("SeriesId", "MediaTypeId"); + + b.HasIndex("MediaTypeId"); + + b.ToTable("series_media_type_search_mapping"); + }); + + modelBuilder.Entity("TNO.Entities.Setting", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Value") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("value") + .HasDefaultValueSql("''"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_setting_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_setting_name") + .IsUnique(); + + b.ToTable("setting"); + }); + + modelBuilder.Entity("TNO.Entities.Source", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AutoTranscribe") + .HasColumnType("boolean") + .HasColumnName("auto_transcribe"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("character varying(20)") + .HasColumnName("code"); + + b.Property("Configuration") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("configuration") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("DisableTranscribe") + .HasColumnType("boolean") + .HasColumnName("disable_transcribe"); + + b.Property("IsCBRASource") + .HasColumnType("boolean") + .HasColumnName("is_cbra_source"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("LicenseId") + .HasColumnType("integer") + .HasColumnName("license_id"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("OwnerId") + .HasColumnType("integer") + .HasColumnName("owner_id"); + + b.Property("ShortName") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("short_name") + .HasDefaultValueSql("''"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UseInTopics") + .HasColumnType("boolean") + .HasColumnName("use_in_topics"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("LicenseId"); + + b.HasIndex("MediaTypeId"); + + b.HasIndex("OwnerId"); + + b.HasIndex(new[] { "Code" }, "IX_source_code") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_source_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_source_name") + .IsUnique(); + + b.ToTable("source"); + }); + + modelBuilder.Entity("TNO.Entities.SourceMediaTypeSearchMapping", b => + { + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("SourceId", "MediaTypeId"); + + b.HasIndex("MediaTypeId"); + + b.ToTable("source_media_type_search_mapping"); + }); + + modelBuilder.Entity("TNO.Entities.SourceMetric", b => + { + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("MetricId") + .HasColumnType("integer") + .HasColumnName("metric_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Earned") + .ValueGeneratedOnAdd() + .HasColumnType("real") + .HasDefaultValue(0f) + .HasColumnName("earned"); + + b.Property("Impression") + .ValueGeneratedOnAdd() + .HasColumnType("real") + .HasDefaultValue(0f) + .HasColumnName("impression"); + + b.Property("Reach") + .ValueGeneratedOnAdd() + .HasColumnType("real") + .HasDefaultValue(0f) + .HasColumnName("reach"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("SourceId", "MetricId"); + + b.HasIndex("MetricId"); + + b.ToTable("source_metric"); + }); + + modelBuilder.Entity("TNO.Entities.SystemMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("text") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text") + .HasColumnName("description"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Message") + .IsRequired() + .HasColumnType("text") + .HasColumnName("message"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text") + .HasColumnName("name"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasColumnType("text") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on"); + + b.Property("Version") + .HasColumnType("bigint") + .HasColumnName("version"); + + b.HasKey("Id"); + + b.ToTable("system_message"); + }); + + modelBuilder.Entity("TNO.Entities.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Code") + .IsRequired() + .HasMaxLength(15) + .HasColumnType("character varying(15)") + .HasColumnName("code"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "Code" }, "IX_tag_code") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_tag_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_tag_name") + .IsUnique(); + + b.ToTable("tag"); + }); + + modelBuilder.Entity("TNO.Entities.TimeTracking", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Activity") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("activity"); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Effort") + .HasColumnType("real") + .HasColumnName("effort"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("ContentId"); + + b.HasIndex("UserId"); + + b.ToTable("time_tracking"); + }); + + modelBuilder.Entity("TNO.Entities.TonePool", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsPublic") + .HasColumnType("boolean") + .HasColumnName("is_public"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("OwnerId") + .HasColumnType("integer") + .HasColumnName("owner_id"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "OwnerId", "Name" }, "IX_tone_pool_name") + .IsUnique(); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_tonepool_is_enabled"); + + b.ToTable("tone_pool"); + }); + + modelBuilder.Entity("TNO.Entities.Topic", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("description") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("name"); + + b.Property("SortOrder") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("sort_order"); + + b.Property("TopicType") + .HasColumnType("integer") + .HasColumnName("topic_type"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "IsEnabled", "Name" }, "IX_topic_is_enabled"); + + b.HasIndex(new[] { "Name" }, "IX_topic_name") + .IsUnique(); + + b.ToTable("topic"); + }); + + modelBuilder.Entity("TNO.Entities.TopicScoreRule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CharacterMax") + .HasColumnType("integer") + .HasColumnName("char_max"); + + b.Property("CharacterMin") + .HasColumnType("integer") + .HasColumnName("char_min"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("HasImage") + .HasColumnType("boolean") + .HasColumnName("has_image"); + + b.Property("PageMax") + .HasMaxLength(5) + .HasColumnType("character varying(5)") + .HasColumnName("page_max"); + + b.Property("PageMin") + .HasMaxLength(5) + .HasColumnType("character varying(5)") + .HasColumnName("page_min"); + + b.Property("Score") + .HasColumnType("integer") + .HasColumnName("score"); + + b.Property("Section") + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("section"); + + b.Property("SeriesId") + .HasColumnType("integer") + .HasColumnName("series_id"); + + b.Property("SortOrder") + .HasColumnType("integer") + .HasColumnName("sort_order"); + + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("TimeMax") + .HasColumnType("interval") + .HasColumnName("time_max"); + + b.Property("TimeMin") + .HasColumnType("interval") + .HasColumnName("time_min"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex("SeriesId"); + + b.HasIndex(new[] { "SourceId", "SeriesId", "Section" }, "IX_source_id_series_id_section"); + + b.ToTable("topic_score_rule"); + }); + + modelBuilder.Entity("TNO.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountType") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("account_type"); + + b.Property("Code") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(10) + .HasColumnType("character varying(10)") + .HasColumnName("code") + .HasDefaultValueSql("''"); + + b.Property("CodeCreatedOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("code_created_on"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("DisplayName") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("display_name") + .HasDefaultValueSql("''"); + + b.Property("Email") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("email") + .HasDefaultValueSql("''"); + + b.Property("EmailVerified") + .HasColumnType("boolean") + .HasColumnName("email_verified"); + + b.Property("FirstName") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("first_name") + .HasDefaultValueSql("''"); + + b.Property("IsEnabled") + .HasColumnType("boolean") + .HasColumnName("is_enabled"); + + b.Property("IsSystemAccount") + .HasColumnType("boolean") + .HasColumnName("is_system_account"); + + b.Property("Key") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("key"); + + b.Property("LastLoginOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("last_login_on"); + + b.Property("LastName") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(100) + .HasColumnType("character varying(100)") + .HasColumnName("last_name") + .HasDefaultValueSql("''"); + + b.Property("Note") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(2000) + .HasColumnType("character varying(2000)") + .HasColumnName("note") + .HasDefaultValueSql("''"); + + b.Property("Preferences") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("preferences") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("PreferredEmail") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("preferred_email") + .HasDefaultValueSql("''"); + + b.Property("Roles") + .IsRequired() + .ValueGeneratedOnAdd() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("roles") + .HasDefaultValueSql("''"); + + b.Property("Status") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasDefaultValue(0) + .HasColumnName("status"); + + b.Property("UniqueLogins") + .ValueGeneratedOnAdd() + .HasColumnType("integer") + .HasColumnName("unique_logins") + .HasDefaultValueSql("0"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("character varying(50)") + .HasColumnName("username"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("Id"); + + b.HasIndex(new[] { "Email" }, "IX_email"); + + b.HasIndex(new[] { "Key" }, "IX_key") + .IsUnique(); + + b.HasIndex(new[] { "LastName", "FirstName" }, "IX_last_first_name"); + + b.HasIndex(new[] { "Username" }, "IX_username") + .IsUnique(); + + b.ToTable("user"); + }); + + modelBuilder.Entity("TNO.Entities.UserAVOverview", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("TemplateType") + .HasColumnType("integer") + .HasColumnName("av_overview_template_type"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("IsSubscribed") + .HasColumnType("boolean") + .HasColumnName("is_subscribed"); + + b.Property("SendTo") + .HasColumnType("integer") + .HasColumnName("send_to"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "TemplateType"); + + b.HasIndex("TemplateType"); + + b.ToTable("user_av_overview"); + }); + + modelBuilder.Entity("TNO.Entities.UserAVOverviewInstance", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("InstanceId") + .HasColumnType("bigint") + .HasColumnName("report_instance_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Response") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("response") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("SentOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("sent_on"); + + b.Property("Status") + .HasColumnType("integer") + .HasColumnName("status"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "InstanceId"); + + b.HasIndex("InstanceId"); + + b.ToTable("user_av_overview_instance"); + }); + + modelBuilder.Entity("TNO.Entities.UserColleague", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("ColleagueId") + .HasColumnType("integer") + .HasColumnName("colleague_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "ColleagueId"); + + b.HasIndex("ColleagueId"); + + b.ToTable("user_colleague"); + }); + + modelBuilder.Entity("TNO.Entities.UserContentNotification", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("IsSubscribed") + .HasColumnType("boolean") + .HasColumnName("is_subscribed"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "ContentId"); + + b.HasIndex("ContentId"); + + b.ToTable("user_content_notification"); + }); + + modelBuilder.Entity("TNO.Entities.UserDistribution", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("LinkedUserId") + .HasColumnType("integer") + .HasColumnName("linked_user_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "LinkedUserId"); + + b.HasIndex("LinkedUserId"); + + b.ToTable("user_distribution"); + }); + + modelBuilder.Entity("TNO.Entities.UserMediaType", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("MediaTypeId") + .HasColumnType("integer") + .HasColumnName("media_type_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "MediaTypeId"); + + b.HasIndex("MediaTypeId"); + + b.ToTable("user_media_type"); + }); + + modelBuilder.Entity("TNO.Entities.UserNotification", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("NotificationId") + .HasColumnType("integer") + .HasColumnName("notification_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("IsSubscribed") + .HasColumnType("boolean") + .HasColumnName("is_subscribed"); + + b.Property("Resend") + .HasColumnType("integer") + .HasColumnName("resend"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "NotificationId"); + + b.HasIndex("NotificationId"); + + b.ToTable("user_notification"); + }); + + modelBuilder.Entity("TNO.Entities.UserOrganization", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("OrganizationId") + .HasColumnType("integer") + .HasColumnName("organization_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "OrganizationId"); + + b.HasIndex("OrganizationId"); + + b.ToTable("user_organization"); + }); + + modelBuilder.Entity("TNO.Entities.UserProduct", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("ProductId") + .HasColumnType("integer") + .HasColumnName("product_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Status") + .HasColumnType("integer") + .HasColumnName("status"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "ProductId"); + + b.HasIndex("ProductId"); + + b.ToTable("user_product"); + }); + + modelBuilder.Entity("TNO.Entities.UserReport", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("ReportId") + .HasColumnType("integer") + .HasColumnName("report_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Format") + .HasColumnType("integer") + .HasColumnName("format"); + + b.Property("IsSubscribed") + .HasColumnType("boolean") + .HasColumnName("is_subscribed"); + + b.Property("SendTo") + .HasColumnType("integer") + .HasColumnName("send_to"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "ReportId"); + + b.HasIndex("ReportId"); + + b.ToTable("user_report"); + }); + + modelBuilder.Entity("TNO.Entities.UserReportInstance", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("InstanceId") + .HasColumnType("bigint") + .HasColumnName("report_instance_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("LinkResponse") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("link_response") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("LinkSentOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("link_sent_on"); + + b.Property("LinkStatus") + .HasColumnType("integer") + .HasColumnName("link_status"); + + b.Property("TextResponse") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("text_response") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("TextSentOn") + .HasColumnType("timestamp with time zone") + .HasColumnName("text_sent_on"); + + b.Property("TextStatus") + .HasColumnType("integer") + .HasColumnName("text_status"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "InstanceId"); + + b.HasIndex("InstanceId"); + + b.ToTable("user_report_instance"); + }); + + modelBuilder.Entity("TNO.Entities.UserSource", b => + { + b.Property("UserId") + .HasColumnType("integer") + .HasColumnName("user_id"); + + b.Property("SourceId") + .HasColumnType("integer") + .HasColumnName("source_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.HasKey("UserId", "SourceId"); + + b.HasIndex("SourceId"); + + b.ToTable("user_source"); + }); + + modelBuilder.Entity("TNO.Entities.WorkOrder", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AssignedId") + .HasColumnType("integer") + .HasColumnName("assigned_id"); + + b.Property("Configuration") + .IsRequired() + .ValueGeneratedOnAdd() + .HasColumnType("jsonb") + .HasColumnName("configuration") + .HasDefaultValueSql("'{}'::jsonb"); + + b.Property("ContentId") + .HasColumnType("bigint") + .HasColumnName("content_id"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("created_by"); + + b.Property("CreatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("created_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(500) + .HasColumnType("character varying(500)") + .HasColumnName("description"); + + b.Property("Note") + .IsRequired() + .HasColumnType("text") + .HasColumnName("note"); + + b.Property("RequestorId") + .HasColumnType("integer") + .HasColumnName("requestor_id"); + + b.Property("Status") + .HasColumnType("integer") + .HasColumnName("status"); + + b.Property("UpdatedBy") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("character varying(250)") + .HasColumnName("updated_by"); + + b.Property("UpdatedOn") + .ValueGeneratedOnAdd() + .HasColumnType("timestamp with time zone") + .HasColumnName("updated_on") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); + + b.Property("Version") + .IsConcurrencyToken() + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("version") + .HasDefaultValueSql("0"); + + b.Property("WorkType") + .HasColumnType("integer") + .HasColumnName("work_type"); + + b.HasKey("Id"); + + b.HasIndex("AssignedId"); + + b.HasIndex("ContentId"); + + b.HasIndex("RequestorId"); + + b.HasIndex(new[] { "WorkType", "Status", "CreatedOn", "RequestorId", "AssignedId" }, "IX_work_order"); + + b.ToTable("work_order"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewInstance", b => + { + b.HasOne("TNO.Entities.AVOverviewTemplate", "Template") + .WithMany("Instances") + .HasForeignKey("TemplateType") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Template"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewSection", b => + { + b.HasOne("TNO.Entities.AVOverviewInstance", "Instance") + .WithMany("Sections") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Source", "Source") + .WithMany() + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Instance"); + + b.Navigation("Series"); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewSectionItem", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany() + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.AVOverviewSection", "Section") + .WithMany("Items") + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewTemplate", b => + { + b.HasOne("TNO.Entities.ReportTemplate", "Template") + .WithMany() + .HasForeignKey("TemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Template"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewTemplateSection", b => + { + b.HasOne("TNO.Entities.Series", "Series") + .WithMany() + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Source", "Source") + .WithMany() + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.AVOverviewTemplate", "Template") + .WithMany("Sections") + .HasForeignKey("TemplateType") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Series"); + + b.Navigation("Source"); + + b.Navigation("Template"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewTemplateSectionItem", b => + { + b.HasOne("TNO.Entities.AVOverviewTemplateSection", "Section") + .WithMany("Items") + .HasForeignKey("SectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Section"); + }); + + modelBuilder.Entity("TNO.Entities.Content", b => + { + b.HasOne("TNO.Entities.Contributor", "Contributor") + .WithMany("Contents") + .HasForeignKey("ContributorId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.IngestType", null) + .WithMany("Contents") + .HasForeignKey("IngestTypeId"); + + b.HasOne("TNO.Entities.License", "License") + .WithMany("Contents") + .HasForeignKey("LicenseId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.MediaType", "MediaType") + .WithMany("Contents") + .HasForeignKey("MediaTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "Owner") + .WithMany("Contents") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.SetNull); + + b.HasOne("TNO.Entities.Series", "Series") + .WithMany("Contents") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Source", "Source") + .WithMany("Contents") + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Contributor"); + + b.Navigation("License"); + + b.Navigation("MediaType"); + + b.Navigation("Owner"); + + b.Navigation("Series"); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("TNO.Entities.ContentAction", b => + { + b.HasOne("TNO.Entities.Action", "Action") + .WithMany("ContentsManyToMany") + .HasForeignKey("ActionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("ActionsManyToMany") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Action"); + + b.Navigation("Content"); + }); + + modelBuilder.Entity("TNO.Entities.ContentLabel", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("Labels") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + }); + + modelBuilder.Entity("TNO.Entities.ContentLink", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("Links") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Content", "Link") + .WithMany() + .HasForeignKey("LinkId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + + b.Navigation("Link"); + }); + + modelBuilder.Entity("TNO.Entities.ContentLog", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("Logs") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + }); + + modelBuilder.Entity("TNO.Entities.ContentTag", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("TagsManyToMany") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Tag", "Tag") + .WithMany("ContentsManyToMany") + .HasForeignKey("TagId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + + b.Navigation("Tag"); + }); + + modelBuilder.Entity("TNO.Entities.ContentTonePool", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("TonePoolsManyToMany") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.TonePool", "TonePool") + .WithMany("ContentsManyToMany") + .HasForeignKey("TonePoolId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + + b.Navigation("TonePool"); + }); + + modelBuilder.Entity("TNO.Entities.ContentTopic", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("TopicsManyToMany") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Topic", "Topic") + .WithMany("ContentsManyToMany") + .HasForeignKey("TopicId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + + b.Navigation("Topic"); + }); + + modelBuilder.Entity("TNO.Entities.ContentTypeAction", b => + { + b.HasOne("TNO.Entities.Action", "Action") + .WithMany("ContentTypes") + .HasForeignKey("ActionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Action"); + }); + + modelBuilder.Entity("TNO.Entities.Contributor", b => + { + b.HasOne("TNO.Entities.Source", "Source") + .WithMany("Contributors") + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("TNO.Entities.DataLocation", b => + { + b.HasOne("TNO.Entities.Connection", "Connection") + .WithMany("DataLocations") + .HasForeignKey("ConnectionId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Connection"); + }); + + modelBuilder.Entity("TNO.Entities.EarnedMedia", b => + { + b.HasOne("TNO.Entities.Source", "Source") + .WithMany("EarnedMedia") + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("TNO.Entities.EventSchedule", b => + { + b.HasOne("TNO.Entities.Folder", "Folder") + .WithMany("Events") + .HasForeignKey("FolderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Notification", "Notification") + .WithMany("Schedules") + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Report", "Report") + .WithMany("Events") + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Schedule", "Schedule") + .WithMany("Events") + .HasForeignKey("ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Folder"); + + b.Navigation("Notification"); + + b.Navigation("Report"); + + b.Navigation("Schedule"); + }); + + modelBuilder.Entity("TNO.Entities.FileReference", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("FileReferences") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + }); + + modelBuilder.Entity("TNO.Entities.Filter", b => + { + b.HasOne("TNO.Entities.User", "Owner") + .WithMany("Filters") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("TNO.Entities.Folder", b => + { + b.HasOne("TNO.Entities.Filter", "Filter") + .WithMany("Folders") + .HasForeignKey("FilterId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.User", "Owner") + .WithMany("Folders") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Filter"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("TNO.Entities.FolderContent", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("FoldersManyToMany") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Folder", "Folder") + .WithMany("ContentManyToMany") + .HasForeignKey("FolderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + + b.Navigation("Folder"); + }); + + modelBuilder.Entity("TNO.Entities.Ingest", b => + { + b.HasOne("TNO.Entities.Connection", "DestinationConnection") + .WithMany("DestinationIngests") + .HasForeignKey("DestinationConnectionId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("TNO.Entities.IngestType", "IngestType") + .WithMany("Ingests") + .HasForeignKey("IngestTypeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("TNO.Entities.MediaType", "MediaType") + .WithMany("Ingests") + .HasForeignKey("MediaTypeId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("TNO.Entities.Connection", "SourceConnection") + .WithMany("SourceIngests") + .HasForeignKey("SourceConnectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Source", "Source") + .WithMany("Ingests") + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("DestinationConnection"); + + b.Navigation("IngestType"); + + b.Navigation("MediaType"); + + b.Navigation("Source"); + + b.Navigation("SourceConnection"); + }); + + modelBuilder.Entity("TNO.Entities.IngestDataLocation", b => + { + b.HasOne("TNO.Entities.DataLocation", "DataLocation") + .WithMany("IngestsManyToMany") + .HasForeignKey("DataLocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Ingest", "Ingest") + .WithMany("DataLocationsManyToMany") + .HasForeignKey("IngestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DataLocation"); + + b.Navigation("Ingest"); + }); + + modelBuilder.Entity("TNO.Entities.IngestSchedule", b => + { + b.HasOne("TNO.Entities.Ingest", "Ingest") + .WithMany("SchedulesManyToMany") + .HasForeignKey("IngestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Schedule", "Schedule") + .WithMany("IngestsManyToMany") + .HasForeignKey("ScheduleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ingest"); + + b.Navigation("Schedule"); + }); + + modelBuilder.Entity("TNO.Entities.IngestState", b => + { + b.HasOne("TNO.Entities.Ingest", "Ingest") + .WithOne("State") + .HasForeignKey("TNO.Entities.IngestState", "IngestId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Ingest"); + }); + + modelBuilder.Entity("TNO.Entities.Minister", b => + { + b.HasOne("TNO.Entities.Organization", "Organization") + .WithMany("Ministers") + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Organization"); + }); + + modelBuilder.Entity("TNO.Entities.Notification", b => + { + b.HasOne("TNO.Entities.User", "Owner") + .WithMany("Notifications") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.NotificationTemplate", "Template") + .WithMany("Notifications") + .HasForeignKey("TemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + + b.Navigation("Template"); + }); + + modelBuilder.Entity("TNO.Entities.NotificationInstance", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("NotificationsManyToMany") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Notification", "Notification") + .WithMany("Instances") + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + + b.Navigation("Notification"); + }); + + modelBuilder.Entity("TNO.Entities.Organization", b => + { + b.HasOne("TNO.Entities.Organization", "Parent") + .WithMany("Children") + .HasForeignKey("ParentId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Parent"); + }); + + modelBuilder.Entity("TNO.Entities.Quote", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("Quotes") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + }); + + modelBuilder.Entity("TNO.Entities.Report", b => + { + b.HasOne("TNO.Entities.User", "Owner") + .WithMany("Reports") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.ReportTemplate", "Template") + .WithMany("Reports") + .HasForeignKey("TemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + + b.Navigation("Template"); + }); + + modelBuilder.Entity("TNO.Entities.ReportInstance", b => + { + b.HasOne("TNO.Entities.User", "Owner") + .WithMany("ReportInstances") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Report", "Report") + .WithMany("Instances") + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("TNO.Entities.ReportInstanceContent", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("ReportsManyToMany") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.ReportInstance", "Instance") + .WithMany("ContentManyToMany") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("TNO.Entities.ReportSection", b => + { + b.HasOne("TNO.Entities.Filter", "Filter") + .WithMany("ReportSections") + .HasForeignKey("FilterId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Folder", "Folder") + .WithMany("ReportSections") + .HasForeignKey("FolderId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Report", "LinkedReport") + .WithMany() + .HasForeignKey("LinkedReportId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Report", "Report") + .WithMany("Sections") + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Filter"); + + b.Navigation("Folder"); + + b.Navigation("LinkedReport"); + + b.Navigation("Report"); + }); + + modelBuilder.Entity("TNO.Entities.ReportSectionChartTemplate", b => + { + b.HasOne("TNO.Entities.ChartTemplate", "ChartTemplate") + .WithMany("ReportSectionsManyToMany") + .HasForeignKey("ChartTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.ReportSection", "ReportSection") + .WithMany("ChartTemplatesManyToMany") + .HasForeignKey("ReportSectionId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChartTemplate"); + + b.Navigation("ReportSection"); + }); + + modelBuilder.Entity("TNO.Entities.ReportTemplateChartTemplate", b => + { + b.HasOne("TNO.Entities.ChartTemplate", "ChartTemplate") + .WithMany("ReportTemplatesManyToMany") + .HasForeignKey("ChartTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.ReportTemplate", "ReportTemplate") + .WithMany("ChartTemplatesManyToMany") + .HasForeignKey("ReportTemplateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChartTemplate"); + + b.Navigation("ReportTemplate"); + }); + + modelBuilder.Entity("TNO.Entities.Schedule", b => + { + b.HasOne("TNO.Entities.User", "RequestedBy") + .WithMany() + .HasForeignKey("RequestedById") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("RequestedBy"); + }); + + modelBuilder.Entity("TNO.Entities.Series", b => + { + b.HasOne("TNO.Entities.Source", "Source") + .WithMany("Series") + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("TNO.Entities.SeriesMediaTypeSearchMapping", b => + { + b.HasOne("TNO.Entities.MediaType", "MediaType") + .WithMany("SeriesSearchMappingsManyToMany") + .HasForeignKey("MediaTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Series", "Series") + .WithMany("MediaTypeSearchMappingsManyToMany") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MediaType"); + + b.Navigation("Series"); + }); + + modelBuilder.Entity("TNO.Entities.Source", b => + { + b.HasOne("TNO.Entities.License", "License") + .WithMany("Sources") + .HasForeignKey("LicenseId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("TNO.Entities.MediaType", "MediaType") + .WithMany("Sources") + .HasForeignKey("MediaTypeId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("TNO.Entities.User", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("License"); + + b.Navigation("MediaType"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("TNO.Entities.SourceMediaTypeSearchMapping", b => + { + b.HasOne("TNO.Entities.MediaType", "MediaType") + .WithMany("SourceSearchMappingsManyToMany") + .HasForeignKey("MediaTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Source", "Source") + .WithMany("MediaTypeSearchMappingsManyToMany") + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MediaType"); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("TNO.Entities.SourceMetric", b => + { + b.HasOne("TNO.Entities.Metric", "Metric") + .WithMany("SourcesManyToMany") + .HasForeignKey("MetricId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.Source", "Source") + .WithMany("MetricsManyToMany") + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Metric"); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("TNO.Entities.TimeTracking", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("TimeTrackings") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("TimeTrackings") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.TonePool", b => + { + b.HasOne("TNO.Entities.User", "Owner") + .WithMany("TonePools") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("TNO.Entities.TopicScoreRule", b => + { + b.HasOne("TNO.Entities.Series", "Series") + .WithMany("ScoreRules") + .HasForeignKey("SeriesId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.Source", "Source") + .WithMany("ScoreRules") + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Series"); + + b.Navigation("Source"); + }); + + modelBuilder.Entity("TNO.Entities.UserAVOverview", b => + { + b.HasOne("TNO.Entities.AVOverviewTemplate", "Template") + .WithMany("SubscribersManyToMany") + .HasForeignKey("TemplateType") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("AVOverviewSubscriptionsManyToMany") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Template"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserAVOverviewInstance", b => + { + b.HasOne("TNO.Entities.AVOverviewInstance", "Instance") + .WithMany("UserInstances") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserColleague", b => + { + b.HasOne("TNO.Entities.User", "Colleague") + .WithMany() + .HasForeignKey("ColleagueId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("ColleaguesManyToMany") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Colleague"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserContentNotification", b => + { + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("UserNotifications") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("ContentNotifications") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Content"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserDistribution", b => + { + b.HasOne("TNO.Entities.User", "LinkedUser") + .WithMany() + .HasForeignKey("LinkedUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("Distribution") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("LinkedUser"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserMediaType", b => + { + b.HasOne("TNO.Entities.MediaType", "MediaType") + .WithMany("UsersManyToMany") + .HasForeignKey("MediaTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("MediaTypesManyToMany") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MediaType"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserNotification", b => + { + b.HasOne("TNO.Entities.Notification", "Notification") + .WithMany("SubscribersManyToMany") + .HasForeignKey("NotificationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("NotificationSubscriptionsManyToMany") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Notification"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserOrganization", b => + { + b.HasOne("TNO.Entities.Organization", "Organization") + .WithMany("UsersManyToMany") + .HasForeignKey("OrganizationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("OrganizationsManyToMany") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Organization"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserProduct", b => + { + b.HasOne("TNO.Entities.Product", "Product") + .WithMany("SubscribersManyToMany") + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("ProductSubscriptionsManyToMany") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserReport", b => + { + b.HasOne("TNO.Entities.Report", "Report") + .WithMany("SubscribersManyToMany") + .HasForeignKey("ReportId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("ReportSubscriptionsManyToMany") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Report"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserReportInstance", b => + { + b.HasOne("TNO.Entities.ReportInstance", "Instance") + .WithMany("UserInstances") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.UserSource", b => + { + b.HasOne("TNO.Entities.Source", "Source") + .WithMany("UsersManyToMany") + .HasForeignKey("SourceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("TNO.Entities.User", "User") + .WithMany("SourcesManyToMany") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Source"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TNO.Entities.WorkOrder", b => + { + b.HasOne("TNO.Entities.User", "Assigned") + .WithMany("WorkOrdersAssigned") + .HasForeignKey("AssignedId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("TNO.Entities.Content", "Content") + .WithMany("WorkOrders") + .HasForeignKey("ContentId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("TNO.Entities.User", "Requestor") + .WithMany("WorkOrderRequests") + .HasForeignKey("RequestorId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Assigned"); + + b.Navigation("Content"); + + b.Navigation("Requestor"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewInstance", b => + { + b.Navigation("Sections"); + + b.Navigation("UserInstances"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewSection", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewTemplate", b => + { + b.Navigation("Instances"); + + b.Navigation("Sections"); + + b.Navigation("SubscribersManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.AVOverviewTemplateSection", b => + { + b.Navigation("Items"); + }); + + modelBuilder.Entity("TNO.Entities.Action", b => + { + b.Navigation("ContentTypes"); + + b.Navigation("ContentsManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.ChartTemplate", b => + { + b.Navigation("ReportSectionsManyToMany"); + + b.Navigation("ReportTemplatesManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.Connection", b => + { + b.Navigation("DataLocations"); + + b.Navigation("DestinationIngests"); + + b.Navigation("SourceIngests"); + }); + + modelBuilder.Entity("TNO.Entities.Content", b => + { + b.Navigation("ActionsManyToMany"); + + b.Navigation("FileReferences"); + + b.Navigation("FoldersManyToMany"); + + b.Navigation("Labels"); + + b.Navigation("Links"); + + b.Navigation("Logs"); + + b.Navigation("NotificationsManyToMany"); + + b.Navigation("Quotes"); + + b.Navigation("ReportsManyToMany"); + + b.Navigation("TagsManyToMany"); + + b.Navigation("TimeTrackings"); + + b.Navigation("TonePoolsManyToMany"); + + b.Navigation("TopicsManyToMany"); + + b.Navigation("UserNotifications"); + + b.Navigation("WorkOrders"); + }); + + modelBuilder.Entity("TNO.Entities.Contributor", b => + { + b.Navigation("Contents"); + }); + + modelBuilder.Entity("TNO.Entities.DataLocation", b => + { + b.Navigation("IngestsManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.Filter", b => + { + b.Navigation("Folders"); + + b.Navigation("ReportSections"); + }); + + modelBuilder.Entity("TNO.Entities.Folder", b => + { + b.Navigation("ContentManyToMany"); + + b.Navigation("Events"); + + b.Navigation("ReportSections"); + }); + + modelBuilder.Entity("TNO.Entities.Ingest", b => + { + b.Navigation("DataLocationsManyToMany"); + + b.Navigation("SchedulesManyToMany"); + + b.Navigation("State"); + }); + + modelBuilder.Entity("TNO.Entities.IngestType", b => + { + b.Navigation("Contents"); + + b.Navigation("Ingests"); + }); + + modelBuilder.Entity("TNO.Entities.License", b => + { + b.Navigation("Contents"); + + b.Navigation("Sources"); + }); + + modelBuilder.Entity("TNO.Entities.MediaType", b => + { + b.Navigation("Contents"); + + b.Navigation("Ingests"); + + b.Navigation("SeriesSearchMappingsManyToMany"); + + b.Navigation("SourceSearchMappingsManyToMany"); + + b.Navigation("Sources"); + + b.Navigation("UsersManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.Metric", b => + { + b.Navigation("SourcesManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.Notification", b => + { + b.Navigation("Instances"); + + b.Navigation("Schedules"); + + b.Navigation("SubscribersManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.NotificationTemplate", b => + { + b.Navigation("Notifications"); + }); + + modelBuilder.Entity("TNO.Entities.Organization", b => + { + b.Navigation("Children"); + + b.Navigation("Ministers"); + + b.Navigation("UsersManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.Product", b => + { + b.Navigation("SubscribersManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.Report", b => + { + b.Navigation("Events"); + + b.Navigation("Instances"); + + b.Navigation("Sections"); + + b.Navigation("SubscribersManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.ReportInstance", b => + { + b.Navigation("ContentManyToMany"); + + b.Navigation("UserInstances"); + }); + + modelBuilder.Entity("TNO.Entities.ReportSection", b => + { + b.Navigation("ChartTemplatesManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.ReportTemplate", b => + { + b.Navigation("ChartTemplatesManyToMany"); + + b.Navigation("Reports"); + }); + + modelBuilder.Entity("TNO.Entities.Schedule", b => + { + b.Navigation("Events"); + + b.Navigation("IngestsManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.Series", b => + { + b.Navigation("Contents"); + + b.Navigation("MediaTypeSearchMappingsManyToMany"); + + b.Navigation("ScoreRules"); + }); + + modelBuilder.Entity("TNO.Entities.Source", b => + { + b.Navigation("Contents"); + + b.Navigation("Contributors"); + + b.Navigation("EarnedMedia"); + + b.Navigation("Ingests"); + + b.Navigation("MediaTypeSearchMappingsManyToMany"); + + b.Navigation("MetricsManyToMany"); + + b.Navigation("ScoreRules"); + + b.Navigation("Series"); + + b.Navigation("UsersManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.Tag", b => + { + b.Navigation("ContentsManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.TonePool", b => + { + b.Navigation("ContentsManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.Topic", b => + { + b.Navigation("ContentsManyToMany"); + }); + + modelBuilder.Entity("TNO.Entities.User", b => + { + b.Navigation("AVOverviewSubscriptionsManyToMany"); + + b.Navigation("ColleaguesManyToMany"); + + b.Navigation("ContentNotifications"); + + b.Navigation("Contents"); + + b.Navigation("Distribution"); + + b.Navigation("Filters"); + + b.Navigation("Folders"); + + b.Navigation("MediaTypesManyToMany"); + + b.Navigation("NotificationSubscriptionsManyToMany"); + + b.Navigation("Notifications"); + + b.Navigation("OrganizationsManyToMany"); + + b.Navigation("ProductSubscriptionsManyToMany"); + + b.Navigation("ReportInstances"); + + b.Navigation("ReportSubscriptionsManyToMany"); + + b.Navigation("Reports"); + + b.Navigation("SourcesManyToMany"); + + b.Navigation("TimeTrackings"); + + b.Navigation("TonePools"); + + b.Navigation("WorkOrderRequests"); + + b.Navigation("WorkOrdersAssigned"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/libs/net/dal/Migrations/20241230195906_1.3.14.cs b/libs/net/dal/Migrations/20241230195906_1.3.14.cs new file mode 100644 index 000000000..a875efabb --- /dev/null +++ b/libs/net/dal/Migrations/20241230195906_1.3.14.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using TNO.DAL; + +#nullable disable + +namespace TNO.DAL.Migrations +{ + /// + public partial class _1314 : SeedMigration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + PreUp(migrationBuilder); + + PostUp(migrationBuilder); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + PreDown(migrationBuilder); + + PostDown(migrationBuilder); + } + } +} diff --git a/libs/net/dal/Migrations/TNOContextModelSnapshot.cs b/libs/net/dal/Migrations/TNOContextModelSnapshot.cs index 685a5747b..2b1798eb5 100644 --- a/libs/net/dal/Migrations/TNOContextModelSnapshot.cs +++ b/libs/net/dal/Migrations/TNOContextModelSnapshot.cs @@ -569,12 +569,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("TNO.Entities.CBRAReportStaffSummary", b => { - b.Property("cbra_hours") - .HasColumnType("numeric"); + b.Property("CbraHours") + .IsRequired() + .HasColumnType("text") + .HasColumnName("cbra_hours"); - b.Property("staff") + b.Property("Staff") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasColumnName("staff"); b.ToTable((string)null); @@ -583,15 +586,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("TNO.Entities.CBRAReportTotalEntries", b => { - b.Property("dayofweek") + b.Property("DayOfWeek") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasColumnName("day_of_week"); - b.Property("totalcbra") - .HasColumnType("numeric"); + b.Property("TotalCbra") + .HasColumnType("numeric") + .HasColumnName("total_cbra"); - b.Property("totalcount") - .HasColumnType("numeric"); + b.Property("TotalCount") + .HasColumnType("numeric") + .HasColumnName("total_count"); b.ToTable((string)null); @@ -600,12 +606,14 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("TNO.Entities.CBRAReportTotalExcerpts", b => { - b.Property("category") + b.Property("Category") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasColumnName("category"); - b.Property("totals") - .HasColumnType("integer"); + b.Property("Totals") + .HasColumnType("integer") + .HasColumnName("totals"); b.ToTable((string)null); @@ -614,16 +622,19 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("TNO.Entities.CBRAReportTotalsByBroadcaster", b => { - b.Property("percentageoftotalrunningtime") - .HasColumnType("numeric"); + b.Property("PercentageOfTotalRunningTime") + .HasColumnType("numeric") + .HasColumnName("percentage_of_total_running_time"); - b.Property("sourcetype") + b.Property("SourceType") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasColumnName("source_type"); - b.Property("totalrunningtime") + b.Property("TotalRunningTime") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasColumnName("total_running_time"); b.ToTable((string)null); @@ -632,27 +643,33 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("TNO.Entities.CBRAReportTotalsByProgram", b => { - b.Property("mediatype") + b.Property("MediaType") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasColumnName("media_type"); - b.Property("percentageoftotalrunningtime") - .HasColumnType("numeric"); + b.Property("PercentageOfTotalRunningTime") + .HasColumnType("numeric") + .HasColumnName("percentage_of_total_running_time"); - b.Property("series") + b.Property("Series") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasColumnName("series"); - b.Property("sourcetype") + b.Property("SourceType") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasColumnName("source_type"); - b.Property("totalcount") - .HasColumnType("numeric"); + b.Property("TotalCount") + .HasColumnType("numeric") + .HasColumnName("total_count"); - b.Property("totalrunningtime") + b.Property("TotalRunningTime") .IsRequired() - .HasColumnType("text"); + .HasColumnType("text") + .HasColumnName("total_running_time"); b.ToTable((string)null); diff --git a/libs/net/entities/CBRAReportStaffSummary.cs b/libs/net/entities/CBRAReportStaffSummary.cs index 4797fd64d..7929ca0a2 100644 --- a/libs/net/entities/CBRAReportStaffSummary.cs +++ b/libs/net/entities/CBRAReportStaffSummary.cs @@ -13,5 +13,5 @@ public class CBRAReportStaffSummary public string Staff { get; set; } = ""; [Column("cbra_hours")] - public decimal CbraHours { get; set; } + public string CbraHours { get; set; } } diff --git a/libs/net/reports/CBRAReport.cs b/libs/net/reports/CBRAReport.cs index ad1cc91d1..caf965ec6 100644 --- a/libs/net/reports/CBRAReport.cs +++ b/libs/net/reports/CBRAReport.cs @@ -200,7 +200,7 @@ private int AddStaffSummary(int startRowIndex, DateTime from, DateTime to) cellB = row.CreateCell(1); cellB.CellStyle = valueStyle; - cellB.SetCellValue((double)timeTrack.CbraHours); + cellB.SetCellValue(timeTrack.CbraHours); } return startRowIndex; }