From 2441e35cffe5be7e7f13cbe451c4b82b874152e4 Mon Sep 17 00:00:00 2001 From: Nam Pham Date: Sun, 7 Aug 2022 14:37:20 +0900 Subject: [PATCH 1/7] Changed database provider to PostgresSQL --- src/Blogifier/appsettings.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Blogifier/appsettings.json b/src/Blogifier/appsettings.json index 3ff95ca99..d4226f762 100644 --- a/src/Blogifier/appsettings.json +++ b/src/Blogifier/appsettings.json @@ -8,10 +8,10 @@ }, "AllowedHosts": "*", "Blogifier": { - "DbProvider": "SQLite", - "ConnString": "Data Source=Blog.db", + "DbProvider": "Postgres", + "ConnString": "Host=db;Database=blog;Username=postgres;Password=mysecretpassword", "Salt": "SECRET-CHANGE-ME!", "DemoMode": false, "FileExtensions": "png,gif,jpeg,jpg,zip,7z,pdf,doc,docx,xls,xlsx,mp3,mp4,avi" } -} +} \ No newline at end of file From c874ed5e245ddc2f43c428086dedd7ac4767d87d Mon Sep 17 00:00:00 2001 From: Nam Pham Date: Sun, 7 Aug 2022 14:38:39 +0900 Subject: [PATCH 2/7] add dockerignore file --- .dockerignore | 287 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 287 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..e1c90b23c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,287 @@ + +# Created by https://www.gitignore.io/api/csharp + +### Csharp ### +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +**/bin/ +**/obj/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ +Properties/launchSettings.json + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/ +tools/Cake.CoreCLR +.vscode +tools +.dotnet +Dockerfile + +# .env file contains default environment variables for docker +.env +.git/ \ No newline at end of file From 1cba9cf46205d7ad6e6281b051c64266ad589fff Mon Sep 17 00:00:00 2001 From: Nam Pham Date: Sun, 7 Aug 2022 14:39:29 +0900 Subject: [PATCH 3/7] edit Dockerfile --- Dockerfile | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9302a36e6..4588b37fa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,27 @@ -FROM mcr.microsoft.com/dotnet/aspnet:6.0 as base +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build +WORKDIR /source -# Copy everything else and build -COPY ./ /opt/blogifier -WORKDIR /opt/blogifier +# copy csproj and restore as distinct layers +# Copy src/Blogifier/Blogifier.csproj file to /source/Blogifier/ +COPY src/Blogifier/*.csproj Blogifier/ +# Copy src/Blogifier.Admin/Blogifier.Admin.csproj file to /source/Blogifier.Admin/ +COPY src/Blogifier.Admin/*.csproj Blogifier.Admin/ +# Copy src/Blogifier.Core/Blogifier.Core.csproj file to /source/Blogifier.Core/ +COPY src/Blogifier.Core/*.csproj Blogifier.Core/ +# Copy src/Blogifier.Core/Blogifier.Core.csproj file to /source/Blogifier.Core/ +COPY src/Blogifier.Shared/*.csproj Blogifier.Shared/ +# restore +RUN dotnet restore Blogifier/Blogifier.csproj -RUN ["dotnet","publish","./src/Blogifier/Blogifier.csproj","-o","./outputs" ] +# copy everything else and build app +COPY src/Blogifier/. Blogifier/ +COPY src/Blogifier.Admin/. Blogifier.Admin/ +COPY src/Blogifier.Core/. Blogifier.Core/ +COPY src/Blogifier.Shared/. Blogifier.Shared/ +RUN dotnet publish Blogifier/Blogifier.csproj -c release -o /app --no-restore -FROM mcr.microsoft.com/dotnet/aspnet:6.0 as run -COPY --from=base /opt/blogifier/outputs /opt/blogifier/outputs -WORKDIR /opt/blogifier/outputs -ENTRYPOINT ["dotnet", "Blogifier.dll"] \ No newline at end of file +# final stage/image +FROM mcr.microsoft.com/dotnet/aspnet:6.0 +WORKDIR /app +COPY --from=build /app ./ +ENTRYPOINT [ "dotnet", "Blogifier.dll"] \ No newline at end of file From b413125d960746a1b19a13b11316d794170b57d8 Mon Sep 17 00:00:00 2001 From: Nam Pham Date: Sun, 7 Aug 2022 14:40:06 +0900 Subject: [PATCH 4/7] add docker-compose file --- docker-compose.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..d0e279239 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,16 @@ +version: '3.9' +services: + app: + build: . + ports: + - "8080:80" + depends_on: + - db + db: + image: postgres + environment: + - POSTGRES_PASSWORD=mysecretpassword + volumes: + - postgres-data:/var/lib/postgresql/data +volumes: + postgres-data: From e20d3b518e4abf0545d69319c510b2140c5ddb04 Mon Sep 17 00:00:00 2001 From: Nam Pham Date: Sun, 7 Aug 2022 14:45:16 +0900 Subject: [PATCH 5/7] Add get current date function for PostgresSQL --- src/Blogifier.Core/Data/AppDbContext.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Blogifier.Core/Data/AppDbContext.cs b/src/Blogifier.Core/Data/AppDbContext.cs index a9e0f4c5a..77a2bb75f 100644 --- a/src/Blogifier.Core/Data/AppDbContext.cs +++ b/src/Blogifier.Core/Data/AppDbContext.cs @@ -47,6 +47,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { sql = "DATE('now')"; break; + } else if(ext.GetType().ToString().StartsWith("Npgsql.EntityFrameworkCore.PostgreSQL")) + { + sql = "CURRENT_TIMESTAMP"; + break; } } } From f06abaa62fcd341ea4baccbca17965fbdcea3c05 Mon Sep 17 00:00:00 2001 From: Nam Pham Date: Sun, 7 Aug 2022 15:47:53 +0900 Subject: [PATCH 6/7] changed IncludeFeatured column datatype to integer --- src/Blogifier.Shared/Domain/Blog.cs | 50 +++++++++++++++-------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/src/Blogifier.Shared/Domain/Blog.cs b/src/Blogifier.Shared/Domain/Blog.cs index 35cc661b8..646da0610 100644 --- a/src/Blogifier.Shared/Domain/Blog.cs +++ b/src/Blogifier.Shared/Domain/Blog.cs @@ -1,36 +1,38 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; namespace Blogifier.Shared { - public class Blog - { - public int Id { get; set; } - [StringLength(160)] - public string Title { get; set; } - [StringLength(450)] - public string Description { get; set; } - [StringLength(160)] - public string Theme { get; set; } - public bool IncludeFeatured { get; set; } - public int ItemsPerPage { get; set; } - [StringLength(160)] - public string Cover { get; set; } - [StringLength(160)] - public string Logo { get; set; } - [StringLength(2000)] - public string HeaderScript { get; set; } - [StringLength(2000)] - public string FooterScript { get; set; } + public class Blog + { + public int Id { get; set; } + [StringLength(160)] + public string Title { get; set; } + [StringLength(450)] + public string Description { get; set; } + [StringLength(160)] + public string Theme { get; set; } + [Column(TypeName = "int")] + public bool IncludeFeatured { get; set; } + public int ItemsPerPage { get; set; } + [StringLength(160)] + public string Cover { get; set; } + [StringLength(160)] + public string Logo { get; set; } + [StringLength(2000)] + public string HeaderScript { get; set; } + [StringLength(2000)] + public string FooterScript { get; set; } public int AnalyticsListType { get; set; } public int AnalyticsPeriod { get; set; } - public DateTime DateCreated { get; set; } - public DateTime DateUpdated { get; set; } + public DateTime DateCreated { get; set; } + public DateTime DateUpdated { get; set; } - public List Posts { get; set; } - public List Authors { get; set; } - } + public List Posts { get; set; } + public List Authors { get; set; } + } } From 3e207ecd36c2fc9349035ca9729504862004e24b Mon Sep 17 00:00:00 2001 From: Nam Pham Date: Sun, 7 Aug 2022 15:56:39 +0900 Subject: [PATCH 7/7] re-migrate for PosgresSQL --- ...ner.cs => 20220807065538_Init.Designer.cs} | 184 ++++++++++-------- ...4234633_Init.cs => 20220807065538_Init.cs} | 173 ++++++++-------- .../Migrations/AppDbContextModelSnapshot.cs | 182 +++++++++-------- 3 files changed, 289 insertions(+), 250 deletions(-) rename src/Blogifier.Core/Data/Migrations/{20210404234633_Init.Designer.cs => 20220807065538_Init.Designer.cs} (66%) rename src/Blogifier.Core/Data/Migrations/{20210404234633_Init.cs => 20220807065538_Init.cs} (51%) diff --git a/src/Blogifier.Core/Data/Migrations/20210404234633_Init.Designer.cs b/src/Blogifier.Core/Data/Migrations/20220807065538_Init.Designer.cs similarity index 66% rename from src/Blogifier.Core/Data/Migrations/20210404234633_Init.Designer.cs rename to src/Blogifier.Core/Data/Migrations/20220807065538_Init.Designer.cs index 5220e37c2..c14cd40bf 100644 --- a/src/Blogifier.Core/Data/Migrations/20210404234633_Init.Designer.cs +++ b/src/Blogifier.Core/Data/Migrations/20220807065538_Init.Designer.cs @@ -5,61 +5,69 @@ using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable namespace Blogifier.Core.Data.Migrations { [DbContext(typeof(AppDbContext))] - [Migration("20210404234633_Init")] + [Migration("20220807065538_Init")] partial class Init { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "5.0.1"); + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("Blogifier.Shared.Author", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Avatar") .HasMaxLength(400) - .HasColumnType("TEXT"); + .HasColumnType("character varying(400)"); b.Property("Bio") .HasMaxLength(2000) - .HasColumnType("TEXT"); + .HasColumnType("character varying(2000)"); b.Property("BlogId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("DisplayName") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Email") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("IsAdmin") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("Password") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.HasKey("Id"); @@ -72,55 +80,57 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AnalyticsListType") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("AnalyticsPeriod") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Cover") .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("Description") .HasMaxLength(450) - .HasColumnType("TEXT"); + .HasColumnType("character varying(450)"); b.Property("FooterScript") .HasMaxLength(2000) - .HasColumnType("TEXT"); + .HasColumnType("character varying(2000)"); b.Property("HeaderScript") .HasMaxLength(2000) - .HasColumnType("TEXT"); + .HasColumnType("character varying(2000)"); - b.Property("IncludeFeatured") - .HasColumnType("INTEGER"); + b.Property("IncludeFeatured") + .HasColumnType("int"); b.Property("ItemsPerPage") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Logo") .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Theme") .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Title") .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.HasKey("Id"); @@ -131,24 +141,26 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Content") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("Description") .HasMaxLength(255) - .HasColumnType("TEXT"); + .HasColumnType("character varying(255)"); b.HasKey("Id"); @@ -159,54 +171,56 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("BlogId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("Enabled") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("FromEmail") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("FromName") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("Host") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Port") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("ToName") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("UserEmail") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("UserPassword") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.HasKey("Id"); @@ -219,21 +233,23 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("PostId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Success") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.HasKey("Id"); @@ -246,62 +262,64 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AuthorId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("BlogId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Content") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("Cover") .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("Description") .IsRequired() .HasMaxLength(450) - .HasColumnType("TEXT"); + .HasColumnType("character varying(450)"); b.Property("IsFeatured") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("PostType") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("PostViews") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Published") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("Rating") - .HasColumnType("REAL"); + .HasColumnType("double precision"); b.Property("Selected") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("Slug") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Title") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.HasKey("Id"); @@ -315,10 +333,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) modelBuilder.Entity("Blogifier.Shared.PostCategory", b => { b.Property("PostId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("CategoryId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.HasKey("PostId", "CategoryId"); @@ -331,35 +349,37 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("BlogId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Country") .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("Email") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Ip") .HasMaxLength(80) - .HasColumnType("TEXT"); + .HasColumnType("character varying(80)"); b.Property("Region") .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.HasKey("Id"); diff --git a/src/Blogifier.Core/Data/Migrations/20210404234633_Init.cs b/src/Blogifier.Core/Data/Migrations/20220807065538_Init.cs similarity index 51% rename from src/Blogifier.Core/Data/Migrations/20210404234633_Init.cs rename to src/Blogifier.Core/Data/Migrations/20220807065538_Init.cs index 0e46d99cb..6f71b5fea 100644 --- a/src/Blogifier.Core/Data/Migrations/20210404234633_Init.cs +++ b/src/Blogifier.Core/Data/Migrations/20220807065538_Init.cs @@ -1,5 +1,8 @@ using System; using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable namespace Blogifier.Core.Data.Migrations { @@ -11,21 +14,21 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "Blogs", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Title = table.Column(type: "TEXT", maxLength: 160, nullable: true), - Description = table.Column(type: "TEXT", maxLength: 450, nullable: true), - Theme = table.Column(type: "TEXT", maxLength: 160, nullable: true), - IncludeFeatured = table.Column(type: "INTEGER", nullable: false), - ItemsPerPage = table.Column(type: "INTEGER", nullable: false), - Cover = table.Column(type: "TEXT", maxLength: 160, nullable: true), - Logo = table.Column(type: "TEXT", maxLength: 160, nullable: true), - HeaderScript = table.Column(type: "TEXT", maxLength: 2000, nullable: true), - FooterScript = table.Column(type: "TEXT", maxLength: 2000, nullable: true), - AnalyticsListType = table.Column(type: "INTEGER", nullable: false), - AnalyticsPeriod = table.Column(type: "INTEGER", nullable: false), - DateCreated = table.Column(type: "TEXT", nullable: false), - DateUpdated = table.Column(type: "TEXT", nullable: false, defaultValueSql: "DATE('now')") + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Title = table.Column(type: "character varying(160)", maxLength: 160, nullable: true), + Description = table.Column(type: "character varying(450)", maxLength: 450, nullable: true), + Theme = table.Column(type: "character varying(160)", maxLength: 160, nullable: true), + IncludeFeatured = table.Column(type: "int", nullable: false), + ItemsPerPage = table.Column(type: "integer", nullable: false), + Cover = table.Column(type: "character varying(160)", maxLength: 160, nullable: true), + Logo = table.Column(type: "character varying(160)", maxLength: 160, nullable: true), + HeaderScript = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true), + FooterScript = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true), + AnalyticsListType = table.Column(type: "integer", nullable: false), + AnalyticsPeriod = table.Column(type: "integer", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateUpdated = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP") }, constraints: table => { @@ -36,12 +39,12 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "Categories", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Content = table.Column(type: "TEXT", maxLength: 120, nullable: false), - Description = table.Column(type: "TEXT", maxLength: 255, nullable: true), - DateCreated = table.Column(type: "TEXT", nullable: false), - DateUpdated = table.Column(type: "TEXT", nullable: false, defaultValueSql: "DATE('now')") + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Content = table.Column(type: "character varying(120)", maxLength: 120, nullable: false), + Description = table.Column(type: "character varying(255)", maxLength: 255, nullable: true), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateUpdated = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP") }, constraints: table => { @@ -52,17 +55,17 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "Authors", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Email = table.Column(type: "TEXT", maxLength: 160, nullable: false), - Password = table.Column(type: "TEXT", maxLength: 160, nullable: false), - DisplayName = table.Column(type: "TEXT", maxLength: 160, nullable: false), - Bio = table.Column(type: "TEXT", maxLength: 2000, nullable: true), - Avatar = table.Column(type: "TEXT", maxLength: 400, nullable: true), - IsAdmin = table.Column(type: "INTEGER", nullable: false), - DateCreated = table.Column(type: "TEXT", nullable: false), - DateUpdated = table.Column(type: "TEXT", nullable: false, defaultValueSql: "DATE('now')"), - BlogId = table.Column(type: "INTEGER", nullable: true) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Email = table.Column(type: "character varying(160)", maxLength: 160, nullable: false), + Password = table.Column(type: "character varying(160)", maxLength: 160, nullable: false), + DisplayName = table.Column(type: "character varying(160)", maxLength: 160, nullable: false), + Bio = table.Column(type: "character varying(2000)", maxLength: 2000, nullable: true), + Avatar = table.Column(type: "character varying(400)", maxLength: 400, nullable: true), + IsAdmin = table.Column(type: "boolean", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateUpdated = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + BlogId = table.Column(type: "integer", nullable: true) }, constraints: table => { @@ -71,27 +74,26 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "FK_Authors_Blogs_BlogId", column: x => x.BlogId, principalTable: "Blogs", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "MailSettings", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Host = table.Column(type: "TEXT", maxLength: 160, nullable: false), - Port = table.Column(type: "INTEGER", nullable: false), - UserEmail = table.Column(type: "TEXT", maxLength: 120, nullable: false), - UserPassword = table.Column(type: "TEXT", maxLength: 120, nullable: false), - FromName = table.Column(type: "TEXT", maxLength: 120, nullable: false), - FromEmail = table.Column(type: "TEXT", maxLength: 120, nullable: false), - ToName = table.Column(type: "TEXT", maxLength: 120, nullable: false), - Enabled = table.Column(type: "INTEGER", nullable: false), - DateCreated = table.Column(type: "TEXT", nullable: false), - DateUpdated = table.Column(type: "TEXT", nullable: false, defaultValueSql: "DATE('now')"), - BlogId = table.Column(type: "INTEGER", nullable: true) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Host = table.Column(type: "character varying(160)", maxLength: 160, nullable: false), + Port = table.Column(type: "integer", nullable: false), + UserEmail = table.Column(type: "character varying(120)", maxLength: 120, nullable: false), + UserPassword = table.Column(type: "character varying(120)", maxLength: 120, nullable: false), + FromName = table.Column(type: "character varying(120)", maxLength: 120, nullable: false), + FromEmail = table.Column(type: "character varying(120)", maxLength: 120, nullable: false), + ToName = table.Column(type: "character varying(120)", maxLength: 120, nullable: false), + Enabled = table.Column(type: "boolean", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateUpdated = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + BlogId = table.Column(type: "integer", nullable: true) }, constraints: table => { @@ -100,23 +102,22 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "FK_MailSettings_Blogs_BlogId", column: x => x.BlogId, principalTable: "Blogs", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Subscribers", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Email = table.Column(type: "TEXT", maxLength: 160, nullable: false), - Ip = table.Column(type: "TEXT", maxLength: 80, nullable: true), - Country = table.Column(type: "TEXT", maxLength: 120, nullable: true), - Region = table.Column(type: "TEXT", maxLength: 120, nullable: true), - DateCreated = table.Column(type: "TEXT", nullable: false), - DateUpdated = table.Column(type: "TEXT", nullable: false, defaultValueSql: "DATE('now')"), - BlogId = table.Column(type: "INTEGER", nullable: true) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Email = table.Column(type: "character varying(160)", maxLength: 160, nullable: false), + Ip = table.Column(type: "character varying(80)", maxLength: 80, nullable: true), + Country = table.Column(type: "character varying(120)", maxLength: 120, nullable: true), + Region = table.Column(type: "character varying(120)", maxLength: 120, nullable: true), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateUpdated = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + BlogId = table.Column(type: "integer", nullable: true) }, constraints: table => { @@ -125,31 +126,30 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "FK_Subscribers_Blogs_BlogId", column: x => x.BlogId, principalTable: "Blogs", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Posts", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - AuthorId = table.Column(type: "INTEGER", nullable: false), - PostType = table.Column(type: "INTEGER", nullable: false), - Title = table.Column(type: "TEXT", maxLength: 160, nullable: false), - Slug = table.Column(type: "TEXT", maxLength: 160, nullable: false), - Description = table.Column(type: "TEXT", maxLength: 450, nullable: false), - Content = table.Column(type: "TEXT", nullable: false), - Cover = table.Column(type: "TEXT", maxLength: 160, nullable: true), - PostViews = table.Column(type: "INTEGER", nullable: false), - Rating = table.Column(type: "REAL", nullable: false), - IsFeatured = table.Column(type: "INTEGER", nullable: false), - Selected = table.Column(type: "INTEGER", nullable: false), - Published = table.Column(type: "TEXT", nullable: false), - DateCreated = table.Column(type: "TEXT", nullable: false), - DateUpdated = table.Column(type: "TEXT", nullable: false, defaultValueSql: "DATE('now')"), - BlogId = table.Column(type: "INTEGER", nullable: true) + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + AuthorId = table.Column(type: "integer", nullable: false), + PostType = table.Column(type: "integer", nullable: false), + Title = table.Column(type: "character varying(160)", maxLength: 160, nullable: false), + Slug = table.Column(type: "character varying(160)", maxLength: 160, nullable: false), + Description = table.Column(type: "character varying(450)", maxLength: 450, nullable: false), + Content = table.Column(type: "text", nullable: false), + Cover = table.Column(type: "character varying(160)", maxLength: 160, nullable: true), + PostViews = table.Column(type: "integer", nullable: false), + Rating = table.Column(type: "double precision", nullable: false), + IsFeatured = table.Column(type: "boolean", nullable: false), + Selected = table.Column(type: "boolean", nullable: false), + Published = table.Column(type: "timestamp with time zone", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateUpdated = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP"), + BlogId = table.Column(type: "integer", nullable: true) }, constraints: table => { @@ -164,20 +164,19 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "FK_Posts_Blogs_BlogId", column: x => x.BlogId, principalTable: "Blogs", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); + principalColumn: "Id"); }); migrationBuilder.CreateTable( name: "Newsletters", columns: table => new { - Id = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - PostId = table.Column(type: "INTEGER", nullable: false), - Success = table.Column(type: "INTEGER", nullable: false), - DateCreated = table.Column(type: "TEXT", nullable: false), - DateUpdated = table.Column(type: "TEXT", nullable: false, defaultValueSql: "DATE('now')") + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + PostId = table.Column(type: "integer", nullable: false), + Success = table.Column(type: "boolean", nullable: false), + DateCreated = table.Column(type: "timestamp with time zone", nullable: false), + DateUpdated = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "CURRENT_TIMESTAMP") }, constraints: table => { @@ -194,8 +193,8 @@ protected override void Up(MigrationBuilder migrationBuilder) name: "PostCategories", columns: table => new { - PostId = table.Column(type: "INTEGER", nullable: false), - CategoryId = table.Column(type: "INTEGER", nullable: false) + PostId = table.Column(type: "integer", nullable: false), + CategoryId = table.Column(type: "integer", nullable: false) }, constraints: table => { diff --git a/src/Blogifier.Core/Data/Migrations/AppDbContextModelSnapshot.cs b/src/Blogifier.Core/Data/Migrations/AppDbContextModelSnapshot.cs index 1c56d30ec..63781603d 100644 --- a/src/Blogifier.Core/Data/Migrations/AppDbContextModelSnapshot.cs +++ b/src/Blogifier.Core/Data/Migrations/AppDbContextModelSnapshot.cs @@ -4,6 +4,9 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable namespace Blogifier.Core.Data.Migrations { @@ -14,50 +17,55 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "5.0.1"); + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("Blogifier.Shared.Author", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Avatar") .HasMaxLength(400) - .HasColumnType("TEXT"); + .HasColumnType("character varying(400)"); b.Property("Bio") .HasMaxLength(2000) - .HasColumnType("TEXT"); + .HasColumnType("character varying(2000)"); b.Property("BlogId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("DisplayName") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Email") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("IsAdmin") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("Password") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.HasKey("Id"); @@ -70,55 +78,57 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AnalyticsListType") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("AnalyticsPeriod") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Cover") .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("Description") .HasMaxLength(450) - .HasColumnType("TEXT"); + .HasColumnType("character varying(450)"); b.Property("FooterScript") .HasMaxLength(2000) - .HasColumnType("TEXT"); + .HasColumnType("character varying(2000)"); b.Property("HeaderScript") .HasMaxLength(2000) - .HasColumnType("TEXT"); + .HasColumnType("character varying(2000)"); - b.Property("IncludeFeatured") - .HasColumnType("INTEGER"); + b.Property("IncludeFeatured") + .HasColumnType("int"); b.Property("ItemsPerPage") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Logo") .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Theme") .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Title") .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.HasKey("Id"); @@ -129,24 +139,26 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("Content") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("Description") .HasMaxLength(255) - .HasColumnType("TEXT"); + .HasColumnType("character varying(255)"); b.HasKey("Id"); @@ -157,54 +169,56 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("BlogId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("Enabled") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("FromEmail") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("FromName") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("Host") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Port") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("ToName") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("UserEmail") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("UserPassword") .IsRequired() .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.HasKey("Id"); @@ -217,21 +231,23 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("PostId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Success") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.HasKey("Id"); @@ -244,62 +260,64 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AuthorId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("BlogId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Content") .IsRequired() - .HasColumnType("TEXT"); + .HasColumnType("text"); b.Property("Cover") .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("Description") .IsRequired() .HasMaxLength(450) - .HasColumnType("TEXT"); + .HasColumnType("character varying(450)"); b.Property("IsFeatured") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("PostType") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("PostViews") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Published") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("Rating") - .HasColumnType("REAL"); + .HasColumnType("double precision"); b.Property("Selected") - .HasColumnType("INTEGER"); + .HasColumnType("boolean"); b.Property("Slug") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Title") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.HasKey("Id"); @@ -313,10 +331,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("Blogifier.Shared.PostCategory", b => { b.Property("PostId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("CategoryId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.HasKey("PostId", "CategoryId"); @@ -329,35 +347,37 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasColumnType("INTEGER"); + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("BlogId") - .HasColumnType("INTEGER"); + .HasColumnType("integer"); b.Property("Country") .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.Property("DateCreated") - .HasColumnType("TEXT"); + .HasColumnType("timestamp with time zone"); b.Property("DateUpdated") .ValueGeneratedOnAdd() - .HasColumnType("TEXT") - .HasDefaultValueSql("DATE('now')"); + .HasColumnType("timestamp with time zone") + .HasDefaultValueSql("CURRENT_TIMESTAMP"); b.Property("Email") .IsRequired() .HasMaxLength(160) - .HasColumnType("TEXT"); + .HasColumnType("character varying(160)"); b.Property("Ip") .HasMaxLength(80) - .HasColumnType("TEXT"); + .HasColumnType("character varying(80)"); b.Property("Region") .HasMaxLength(120) - .HasColumnType("TEXT"); + .HasColumnType("character varying(120)"); b.HasKey("Id");