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

View File

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

View File

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

View File

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

View File

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

View File

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