Switch back to sqlite

This commit is contained in:
Jeff Leung 2022-01-04 12:06:43 -08:00
parent 94c7c7ac1b
commit a53fbb2064
6 changed files with 41 additions and 67 deletions

View File

@ -2,7 +2,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TwilioSMSReceiver.Data; using TwilioSMSReceiver.Data;
@ -12,31 +11,25 @@ using TwilioSMSReceiver.Data;
namespace TwilioSMSReceiver.Data.Migrations namespace TwilioSMSReceiver.Data.Migrations
{ {
[DbContext(typeof(SMSDbCtx))] [DbContext(typeof(SMSDbCtx))]
[Migration("20211231074942_InitialMigration")] [Migration("20220104193753_InitialMigration")]
partial class InitialMigration partial class InitialMigration
{ {
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder.HasAnnotation("ProductVersion", "6.0.1");
.HasAnnotation("ProductVersion", "6.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("TwilioSMSReceiver.Data.Models.MMSModel", b => modelBuilder.Entity("TwilioSMSReceiver.Data.Models.MMSModel", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("OriginalMMSData") b.Property<string>("OriginalMMSData")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<int>("SMSModelId") b.Property<int>("SMSModelId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.HasKey("Id"); b.HasKey("Id");
@ -49,12 +42,10 @@ namespace TwilioSMSReceiver.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("WebHookUri") b.Property<string>("WebHookUri")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@ -65,26 +56,24 @@ namespace TwilioSMSReceiver.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<bool>("IsForwardedYet") b.Property<bool>("IsForwardedYet")
.HasColumnType("bit"); .HasColumnType("INTEGER");
b.Property<string>("MessageContents") b.Property<string>("MessageContents")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<string>("ReceivedNumber") b.Property<string>("ReceivedNumber")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<string>("SenderNumber") b.Property<string>("SenderNumber")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<DateTime>("TimeReceived") b.Property<DateTime>("TimeReceived")
.HasColumnType("datetime2"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");

View File

@ -13,9 +13,9 @@ namespace TwilioSMSReceiver.Data.Migrations
name: "MSTeamsWebHooks", name: "MSTeamsWebHooks",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Sqlite:Autoincrement", true),
WebHookUri = table.Column<string>(type: "nvarchar(max)", nullable: true) WebHookUri = table.Column<string>(type: "TEXT", nullable: true)
}, },
constraints: table => constraints: table =>
{ {
@ -26,13 +26,13 @@ namespace TwilioSMSReceiver.Data.Migrations
name: "SMSMessages", name: "SMSMessages",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Sqlite:Autoincrement", true),
ReceivedNumber = table.Column<string>(type: "nvarchar(max)", nullable: false), ReceivedNumber = table.Column<string>(type: "TEXT", nullable: false),
SenderNumber = table.Column<string>(type: "nvarchar(max)", nullable: false), SenderNumber = table.Column<string>(type: "TEXT", nullable: false),
TimeReceived = table.Column<DateTime>(type: "datetime2", nullable: false), TimeReceived = table.Column<DateTime>(type: "TEXT", nullable: false),
MessageContents = table.Column<string>(type: "nvarchar(max)", nullable: true), MessageContents = table.Column<string>(type: "TEXT", nullable: true),
IsForwardedYet = table.Column<bool>(type: "bit", nullable: false) IsForwardedYet = table.Column<bool>(type: "INTEGER", nullable: false)
}, },
constraints: table => constraints: table =>
{ {
@ -43,10 +43,10 @@ namespace TwilioSMSReceiver.Data.Migrations
name: "MMSMessages", name: "MMSMessages",
columns: table => new columns: table => new
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("Sqlite:Autoincrement", true),
SMSModelId = table.Column<int>(type: "int", nullable: false), SMSModelId = table.Column<int>(type: "INTEGER", nullable: false),
OriginalMMSData = table.Column<string>(type: "nvarchar(max)", nullable: true) OriginalMMSData = table.Column<string>(type: "TEXT", nullable: true)
}, },
constraints: table => constraints: table =>
{ {

View File

@ -2,7 +2,6 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TwilioSMSReceiver.Data; using TwilioSMSReceiver.Data;
@ -16,25 +15,19 @@ namespace TwilioSMSReceiver.Data.Migrations
protected override void BuildModel(ModelBuilder modelBuilder) protected override void BuildModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder.HasAnnotation("ProductVersion", "6.0.1");
.HasAnnotation("ProductVersion", "6.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("TwilioSMSReceiver.Data.Models.MMSModel", b => modelBuilder.Entity("TwilioSMSReceiver.Data.Models.MMSModel", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("OriginalMMSData") b.Property<string>("OriginalMMSData")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<int>("SMSModelId") b.Property<int>("SMSModelId")
.HasColumnType("int"); .HasColumnType("INTEGER");
b.HasKey("Id"); b.HasKey("Id");
@ -47,12 +40,10 @@ namespace TwilioSMSReceiver.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("WebHookUri") b.Property<string>("WebHookUri")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");
@ -63,26 +54,24 @@ namespace TwilioSMSReceiver.Data.Migrations
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("INTEGER");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<bool>("IsForwardedYet") b.Property<bool>("IsForwardedYet")
.HasColumnType("bit"); .HasColumnType("INTEGER");
b.Property<string>("MessageContents") b.Property<string>("MessageContents")
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<string>("ReceivedNumber") b.Property<string>("ReceivedNumber")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<string>("SenderNumber") b.Property<string>("SenderNumber")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("TEXT");
b.Property<DateTime>("TimeReceived") b.Property<DateTime>("TimeReceived")
.HasColumnType("datetime2"); .HasColumnType("TEXT");
b.HasKey("Id"); b.HasKey("Id");

View File

@ -11,8 +11,4 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project> </Project>

View File

@ -15,7 +15,7 @@ builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(); builder.Services.AddSwaggerGen();
builder.Services.AddDbContext<SMSDbCtx>(options => { builder.Services.AddDbContext<SMSDbCtx>(options => {
options.UseSqlServer(builder.Configuration.GetConnectionString("SmsDBCtx")); options.UseSqlite(builder.Configuration.GetConnectionString("SmsDBCtx"));
}); });
builder.Services.RegisterSMSExtensions(); builder.Services.RegisterSMSExtensions();
builder.Services.AddLogging(); builder.Services.AddLogging();

View File

@ -6,7 +6,7 @@
} }
}, },
"ConnectionStrings": { "ConnectionStrings": {
"SmsDbCtx": "Server=(localdb)\\mssqllocaldb;Database=SMSDB;Trusted_Connection=True;" "SmsDbCtx": "Data Source=smsdatabase.sqlite"
}, },
"AllowedHosts": "*" "AllowedHosts": "*"
} }