add some APIs

This commit is contained in:
2023-07-13 12:10:30 +08:00
parent 32464cb494
commit 8b759c94ec
34 changed files with 1211 additions and 1889 deletions

View File

@ -1,141 +0,0 @@
// <auto-generated />
using System;
using Blahblah.FlowerStory.Server.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
[DbContext(typeof(FlowerDatabase))]
[Migration("20230522090224_InitialCreateDb")]
partial class InitialCreateDb
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.5");
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("fid");
b.Property<int>("CategoryId")
.HasColumnType("INTEGER")
.HasColumnName("categoryid");
b.Property<decimal?>("Cost")
.HasColumnType("real")
.HasColumnName("cost");
b.Property<DateTimeOffset>("DateBuy")
.HasColumnType("numeric")
.HasColumnName("datebuy");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<byte[]>("Photo")
.HasColumnType("BLOB")
.HasColumnName("photo");
b.Property<string>("Purchase")
.HasColumnType("TEXT")
.HasColumnName("purchase");
b.HasKey("Id");
b.ToTable("flowers");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.RecordItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("rid");
b.Property<int?>("ByUserId")
.HasColumnType("INTEGER")
.HasColumnName("byuid");
b.Property<string>("ByUserName")
.HasColumnType("TEXT")
.HasColumnName("byname");
b.Property<DateTimeOffset>("Date")
.HasColumnType("numeric")
.HasColumnName("date");
b.Property<int>("EventId")
.HasColumnType("INTEGER")
.HasColumnName("eid");
b.Property<byte[]>("Photo")
.HasColumnType("BLOB")
.HasColumnName("photo");
b.HasKey("Id");
b.ToTable("records");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.UserItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<DateTimeOffset?>("ActiveDate")
.HasColumnType("numeric")
.HasColumnName("activedate");
b.Property<string>("Email")
.HasColumnType("TEXT")
.HasColumnName("email");
b.Property<int>("Level")
.HasColumnType("INTEGER")
.HasColumnName("level");
b.Property<string>("Mobile")
.HasColumnType("TEXT")
.HasColumnName("mobile");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("password");
b.Property<DateTimeOffset>("RegisterDate")
.HasColumnType("numeric")
.HasColumnName("regdate");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("id");
b.HasKey("Id");
b.ToTable("users");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,83 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
/// <inheritdoc />
public partial class InitialCreateDb : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "flowers",
columns: table => new
{
fid = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
categoryid = table.Column<int>(type: "INTEGER", nullable: false),
name = table.Column<string>(type: "TEXT", nullable: false),
datebuy = table.Column<DateTimeOffset>(type: "numeric", nullable: false),
cost = table.Column<decimal>(type: "real", nullable: true),
purchase = table.Column<string>(type: "TEXT", nullable: true),
photo = table.Column<byte[]>(type: "BLOB", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_flowers", x => x.fid);
});
migrationBuilder.CreateTable(
name: "records",
columns: table => new
{
rid = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
eid = table.Column<int>(type: "INTEGER", nullable: false),
date = table.Column<DateTimeOffset>(type: "numeric", nullable: false),
byuid = table.Column<int>(type: "INTEGER", nullable: true),
byname = table.Column<string>(type: "TEXT", nullable: true),
photo = table.Column<byte[]>(type: "BLOB", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_records", x => x.rid);
});
migrationBuilder.CreateTable(
name: "users",
columns: table => new
{
uid = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
id = table.Column<string>(type: "TEXT", nullable: false),
password = table.Column<string>(type: "TEXT", nullable: false),
level = table.Column<int>(type: "INTEGER", nullable: false),
regdate = table.Column<DateTimeOffset>(type: "numeric", nullable: false),
activedate = table.Column<DateTimeOffset>(type: "numeric", nullable: true),
name = table.Column<string>(type: "TEXT", nullable: false),
email = table.Column<string>(type: "TEXT", nullable: true),
mobile = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_users", x => x.uid);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "flowers");
migrationBuilder.DropTable(
name: "records");
migrationBuilder.DropTable(
name: "users");
}
}
}

View File

@ -1,141 +0,0 @@
// <auto-generated />
using System;
using Blahblah.FlowerStory.Server.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
[DbContext(typeof(FlowerDatabase))]
[Migration("20230522143925_ChangeDateColumnType")]
partial class ChangeDateColumnType
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.5");
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("fid");
b.Property<int>("CategoryId")
.HasColumnType("INTEGER")
.HasColumnName("categoryid");
b.Property<decimal?>("Cost")
.HasColumnType("real")
.HasColumnName("cost");
b.Property<long>("DateBuyUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("datebuy");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<byte[]>("Photo")
.HasColumnType("BLOB")
.HasColumnName("photo");
b.Property<string>("Purchase")
.HasColumnType("TEXT")
.HasColumnName("purchase");
b.HasKey("Id");
b.ToTable("flowers");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.RecordItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("rid");
b.Property<int?>("ByUserId")
.HasColumnType("INTEGER")
.HasColumnName("byuid");
b.Property<string>("ByUserName")
.HasColumnType("TEXT")
.HasColumnName("byname");
b.Property<long>("DateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("date");
b.Property<int>("EventId")
.HasColumnType("INTEGER")
.HasColumnName("eid");
b.Property<byte[]>("Photo")
.HasColumnType("BLOB")
.HasColumnName("photo");
b.HasKey("Id");
b.ToTable("records");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.UserItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<long?>("ActiveDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("activedate");
b.Property<string>("Email")
.HasColumnType("TEXT")
.HasColumnName("email");
b.Property<int>("Level")
.HasColumnType("INTEGER")
.HasColumnName("level");
b.Property<string>("Mobile")
.HasColumnType("TEXT")
.HasColumnName("mobile");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("password");
b.Property<long>("RegisterDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("regdate");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("id");
b.HasKey("Id");
b.ToTable("users");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,85 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
/// <inheritdoc />
public partial class ChangeDateColumnType : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<long>(
name: "regdate",
table: "users",
type: "INTEGER",
nullable: false,
oldClrType: typeof(DateTimeOffset),
oldType: "numeric");
migrationBuilder.AlterColumn<long>(
name: "activedate",
table: "users",
type: "INTEGER",
nullable: true,
oldClrType: typeof(DateTimeOffset),
oldType: "numeric",
oldNullable: true);
migrationBuilder.AlterColumn<long>(
name: "date",
table: "records",
type: "INTEGER",
nullable: false,
oldClrType: typeof(DateTimeOffset),
oldType: "numeric");
migrationBuilder.AlterColumn<long>(
name: "datebuy",
table: "flowers",
type: "INTEGER",
nullable: false,
oldClrType: typeof(DateTimeOffset),
oldType: "numeric");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "regdate",
table: "users",
type: "numeric",
nullable: false,
oldClrType: typeof(long),
oldType: "INTEGER");
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "activedate",
table: "users",
type: "numeric",
nullable: true,
oldClrType: typeof(long),
oldType: "INTEGER",
oldNullable: true);
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "date",
table: "records",
type: "numeric",
nullable: false,
oldClrType: typeof(long),
oldType: "INTEGER");
migrationBuilder.AlterColumn<DateTimeOffset>(
name: "datebuy",
table: "flowers",
type: "numeric",
nullable: false,
oldClrType: typeof(long),
oldType: "INTEGER");
}
}
}

View File

@ -1,191 +0,0 @@
// <auto-generated />
using System;
using Blahblah.FlowerStory.Server.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
[DbContext(typeof(FlowerDatabase))]
[Migration("20230523031232_AddTokens")]
partial class AddTokens
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.5");
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("fid");
b.Property<int>("CategoryId")
.HasColumnType("INTEGER")
.HasColumnName("categoryid");
b.Property<decimal?>("Cost")
.HasColumnType("real")
.HasColumnName("cost");
b.Property<long>("DateBuyUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("datebuy")
.HasAnnotation("Relational:JsonPropertyName", "dateBuy");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<byte[]>("Photo")
.HasColumnType("BLOB")
.HasColumnName("photo");
b.Property<string>("Purchase")
.HasColumnType("TEXT")
.HasColumnName("purchase");
b.HasKey("Id");
b.ToTable("flowers");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.RecordItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("rid");
b.Property<int?>("ByUserId")
.HasColumnType("INTEGER")
.HasColumnName("byuid");
b.Property<string>("ByUserName")
.HasColumnType("TEXT")
.HasColumnName("byname");
b.Property<long>("DateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("date")
.HasAnnotation("Relational:JsonPropertyName", "date");
b.Property<int>("EventId")
.HasColumnType("INTEGER")
.HasColumnName("eid");
b.Property<byte[]>("Photo")
.HasColumnType("BLOB")
.HasColumnName("photo");
b.HasKey("Id");
b.ToTable("records");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.TokenItem", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT")
.HasColumnName("tid");
b.Property<long>("ActiveDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("activedate");
b.Property<string>("ClientAgent")
.HasColumnType("TEXT")
.HasColumnName("clientagent");
b.Property<string>("ClientApp")
.HasColumnType("TEXT")
.HasColumnName("clientapp");
b.Property<string>("DeviceId")
.HasColumnType("TEXT")
.HasColumnName("deviceid");
b.Property<long>("ExpireDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("expiredate");
b.Property<int>("ExpireSeconds")
.HasColumnType("INTEGER")
.HasColumnName("expiresecs");
b.Property<long>("LogonDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("logondate");
b.Property<int>("UserId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<string>("VerifyCode")
.HasColumnType("TEXT")
.HasColumnName("verifycode");
b.HasKey("Id");
b.ToTable("tokens");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.UserItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<long?>("ActiveDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("activedate");
b.Property<string>("Email")
.HasColumnType("TEXT")
.HasColumnName("email");
b.Property<int>("Level")
.HasColumnType("INTEGER")
.HasColumnName("level");
b.Property<string>("Mobile")
.HasColumnType("TEXT")
.HasColumnName("mobile");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("password");
b.Property<long>("RegisterDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("regdate")
.HasAnnotation("Relational:JsonPropertyName", "registerDate");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("id");
b.HasKey("Id");
b.ToTable("users");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,41 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
/// <inheritdoc />
public partial class AddTokens : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "tokens",
columns: table => new
{
tid = table.Column<string>(type: "TEXT", nullable: false),
uid = table.Column<int>(type: "INTEGER", nullable: false),
logondate = table.Column<long>(type: "INTEGER", nullable: false),
activedate = table.Column<long>(type: "INTEGER", nullable: false),
expiredate = table.Column<long>(type: "INTEGER", nullable: false),
expiresecs = table.Column<int>(type: "INTEGER", nullable: false),
verifycode = table.Column<string>(type: "TEXT", nullable: true),
clientapp = table.Column<string>(type: "TEXT", nullable: true),
deviceid = table.Column<string>(type: "TEXT", nullable: true),
clientagent = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_tokens", x => x.tid);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "tokens");
}
}
}

View File

@ -1,202 +0,0 @@
// <auto-generated />
using System;
using Blahblah.FlowerStory.Server.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
[DbContext(typeof(FlowerDatabase))]
[Migration("20230524062207_AddOwner")]
partial class AddOwner
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.5");
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("fid");
b.Property<int>("CategoryId")
.HasColumnType("INTEGER")
.HasColumnName("categoryid");
b.Property<decimal?>("Cost")
.HasColumnType("real")
.HasColumnName("cost");
b.Property<long>("DateBuyUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("datebuy")
.HasAnnotation("Relational:JsonPropertyName", "dateBuy");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<int>("OwnerId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<byte[]>("Photo")
.HasColumnType("BLOB")
.HasColumnName("photo");
b.Property<string>("Purchase")
.HasColumnType("TEXT")
.HasColumnName("purchase");
b.HasKey("Id");
b.ToTable("flowers");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.RecordItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("rid");
b.Property<int?>("ByUserId")
.HasColumnType("INTEGER")
.HasColumnName("byuid");
b.Property<string>("ByUserName")
.HasColumnType("TEXT")
.HasColumnName("byname");
b.Property<long>("DateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("date")
.HasAnnotation("Relational:JsonPropertyName", "date");
b.Property<int>("EventId")
.HasColumnType("INTEGER")
.HasColumnName("eid");
b.Property<int>("OwnerId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<byte[]>("Photo")
.HasColumnType("BLOB")
.HasColumnName("photo");
b.HasKey("Id");
b.ToTable("records");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.TokenItem", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT")
.HasColumnName("tid");
b.Property<long>("ActiveDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("activedate")
.HasAnnotation("Relational:JsonPropertyName", "activeDate");
b.Property<string>("ClientAgent")
.HasColumnType("TEXT")
.HasColumnName("clientagent");
b.Property<string>("ClientApp")
.HasColumnType("TEXT")
.HasColumnName("clientapp");
b.Property<string>("DeviceId")
.HasColumnType("TEXT")
.HasColumnName("deviceid");
b.Property<long>("ExpireDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("expiredate")
.HasAnnotation("Relational:JsonPropertyName", "expireDate");
b.Property<int>("ExpireSeconds")
.HasColumnType("INTEGER")
.HasColumnName("expiresecs");
b.Property<long>("LogonDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("logondate")
.HasAnnotation("Relational:JsonPropertyName", "logonDate");
b.Property<int>("UserId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<string>("VerifyCode")
.HasColumnType("TEXT")
.HasColumnName("verifycode");
b.HasKey("Id");
b.ToTable("tokens");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.UserItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<long?>("ActiveDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("activedate");
b.Property<string>("Email")
.HasColumnType("TEXT")
.HasColumnName("email");
b.Property<int>("Level")
.HasColumnType("INTEGER")
.HasColumnName("level");
b.Property<string>("Mobile")
.HasColumnType("TEXT")
.HasColumnName("mobile");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("password");
b.Property<long>("RegisterDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("regdate")
.HasAnnotation("Relational:JsonPropertyName", "registerDate");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("id");
b.HasKey("Id");
b.ToTable("users");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,40 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
/// <inheritdoc />
public partial class AddOwner : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "uid",
table: "records",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "uid",
table: "flowers",
type: "INTEGER",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "uid",
table: "records");
migrationBuilder.DropColumn(
name: "uid",
table: "flowers");
}
}
}

View File

@ -1,214 +0,0 @@
// <auto-generated />
using System;
using Blahblah.FlowerStory.Server.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
[DbContext(typeof(FlowerDatabase))]
[Migration("20230525004719_AddAvatarMemo")]
partial class AddAvatarMemo
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.5");
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("fid");
b.Property<int>("CategoryId")
.HasColumnType("INTEGER")
.HasColumnName("categoryid");
b.Property<decimal?>("Cost")
.HasColumnType("real")
.HasColumnName("cost");
b.Property<long>("DateBuyUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("datebuy")
.HasAnnotation("Relational:JsonPropertyName", "dateBuy");
b.Property<string>("Memo")
.HasColumnType("TEXT")
.HasColumnName("memo");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<int>("OwnerId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<byte[]>("Photo")
.HasColumnType("BLOB")
.HasColumnName("photo");
b.Property<string>("Purchase")
.HasColumnType("TEXT")
.HasColumnName("purchase");
b.HasKey("Id");
b.ToTable("flowers");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.RecordItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("rid");
b.Property<int?>("ByUserId")
.HasColumnType("INTEGER")
.HasColumnName("byuid");
b.Property<string>("ByUserName")
.HasColumnType("TEXT")
.HasColumnName("byname");
b.Property<long>("DateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("date")
.HasAnnotation("Relational:JsonPropertyName", "date");
b.Property<int>("EventId")
.HasColumnType("INTEGER")
.HasColumnName("eid");
b.Property<string>("Memo")
.HasColumnType("TEXT")
.HasColumnName("memo");
b.Property<int>("OwnerId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<byte[]>("Photo")
.HasColumnType("BLOB")
.HasColumnName("photo");
b.HasKey("Id");
b.ToTable("records");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.TokenItem", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT")
.HasColumnName("tid");
b.Property<long>("ActiveDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("activedate")
.HasAnnotation("Relational:JsonPropertyName", "activeDate");
b.Property<string>("ClientAgent")
.HasColumnType("TEXT")
.HasColumnName("clientagent");
b.Property<string>("ClientApp")
.HasColumnType("TEXT")
.HasColumnName("clientapp");
b.Property<string>("DeviceId")
.HasColumnType("TEXT")
.HasColumnName("deviceid");
b.Property<long>("ExpireDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("expiredate")
.HasAnnotation("Relational:JsonPropertyName", "expireDate");
b.Property<int>("ExpireSeconds")
.HasColumnType("INTEGER")
.HasColumnName("expiresecs");
b.Property<long>("LogonDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("logondate")
.HasAnnotation("Relational:JsonPropertyName", "logonDate");
b.Property<int>("UserId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<string>("VerifyCode")
.HasColumnType("TEXT")
.HasColumnName("verifycode");
b.HasKey("Id");
b.ToTable("tokens");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.UserItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<long?>("ActiveDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("activedate");
b.Property<byte[]>("Avatar")
.HasColumnType("BLOB")
.HasColumnName("avatar");
b.Property<string>("Email")
.HasColumnType("TEXT")
.HasColumnName("email");
b.Property<int>("Level")
.HasColumnType("INTEGER")
.HasColumnName("level");
b.Property<string>("Mobile")
.HasColumnType("TEXT")
.HasColumnName("mobile");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("password");
b.Property<long>("RegisterDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("regdate")
.HasAnnotation("Relational:JsonPropertyName", "registerDate");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("id");
b.HasKey("Id");
b.ToTable("users");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,48 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
/// <inheritdoc />
public partial class AddAvatarMemo : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<byte[]>(
name: "avatar",
table: "users",
type: "BLOB",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "memo",
table: "records",
type: "TEXT",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "memo",
table: "flowers",
type: "TEXT",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "avatar",
table: "users");
migrationBuilder.DropColumn(
name: "memo",
table: "records");
migrationBuilder.DropColumn(
name: "memo",
table: "flowers");
}
}
}

View File

@ -1,300 +0,0 @@
// <auto-generated />
using System;
using Blahblah.FlowerStory.Server.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
[DbContext(typeof(FlowerDatabase))]
[Migration("20230525082941_AddPhotos")]
partial class AddPhotos
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.5");
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("fid");
b.Property<int>("CategoryId")
.HasColumnType("INTEGER")
.HasColumnName("categoryid");
b.Property<decimal?>("Cost")
.HasColumnType("real")
.HasColumnName("cost");
b.Property<long>("DateBuyUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("datebuy")
.HasAnnotation("Relational:JsonPropertyName", "dateBuy");
b.Property<string>("Memo")
.HasColumnType("TEXT")
.HasColumnName("memo");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<int>("OwnerId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<string>("Purchase")
.HasColumnType("TEXT")
.HasColumnName("purchase");
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("flowers");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.PhotoItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("pid");
b.Property<long>("DateUploadUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("dateupload")
.HasAnnotation("Relational:JsonPropertyName", "dateUpload");
b.Property<string>("FileName")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("filename");
b.Property<string>("FileType")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("filetype");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("path");
b.Property<int>("RecordId")
.HasColumnType("INTEGER")
.HasColumnName("rid");
b.HasKey("Id");
b.HasIndex("RecordId");
b.ToTable("photos");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.RecordItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("rid");
b.Property<int?>("ByUserId")
.HasColumnType("INTEGER")
.HasColumnName("byuid");
b.Property<string>("ByUserName")
.HasColumnType("TEXT")
.HasColumnName("byname");
b.Property<long>("DateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("date")
.HasAnnotation("Relational:JsonPropertyName", "date");
b.Property<int>("EventId")
.HasColumnType("INTEGER")
.HasColumnName("eid");
b.Property<int>("FlowerId")
.HasColumnType("INTEGER")
.HasColumnName("fid");
b.Property<string>("Memo")
.HasColumnType("TEXT")
.HasColumnName("memo");
b.Property<int>("OwnerId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.HasKey("Id");
b.HasIndex("FlowerId");
b.HasIndex("OwnerId");
b.ToTable("records");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.TokenItem", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT")
.HasColumnName("tid");
b.Property<long>("ActiveDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("activedate")
.HasAnnotation("Relational:JsonPropertyName", "activeDate");
b.Property<string>("ClientAgent")
.HasColumnType("TEXT")
.HasColumnName("clientagent");
b.Property<string>("ClientApp")
.HasColumnType("TEXT")
.HasColumnName("clientapp");
b.Property<string>("DeviceId")
.HasColumnType("TEXT")
.HasColumnName("deviceid");
b.Property<long>("ExpireDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("expiredate")
.HasAnnotation("Relational:JsonPropertyName", "expireDate");
b.Property<int>("ExpireSeconds")
.HasColumnType("INTEGER")
.HasColumnName("expiresecs");
b.Property<long>("LogonDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("logondate")
.HasAnnotation("Relational:JsonPropertyName", "logonDate");
b.Property<int>("UserId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<string>("VerifyCode")
.HasColumnType("TEXT")
.HasColumnName("verifycode");
b.HasKey("Id");
b.ToTable("tokens");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.UserItem", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<long?>("ActiveDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("activedate");
b.Property<byte[]>("Avatar")
.HasColumnType("BLOB")
.HasColumnName("avatar");
b.Property<string>("Email")
.HasColumnType("TEXT")
.HasColumnName("email");
b.Property<int>("Level")
.HasColumnType("INTEGER")
.HasColumnName("level");
b.Property<string>("Mobile")
.HasColumnType("TEXT")
.HasColumnName("mobile");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("name");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("password");
b.Property<long>("RegisterDateUnixTime")
.HasColumnType("INTEGER")
.HasColumnName("regdate")
.HasAnnotation("Relational:JsonPropertyName", "registerDate");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("id");
b.HasKey("Id");
b.ToTable("users");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", b =>
{
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.UserItem", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Owner");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.PhotoItem", b =>
{
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.RecordItem", "Record")
.WithMany("Photo")
.HasForeignKey("RecordId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Record");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.RecordItem", b =>
{
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", "Flower")
.WithMany()
.HasForeignKey("FlowerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.UserItem", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Flower");
b.Navigation("Owner");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.RecordItem", b =>
{
b.Navigation("Photo");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,143 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
/// <inheritdoc />
public partial class AddPhotos : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "photo",
table: "records");
migrationBuilder.DropColumn(
name: "photo",
table: "flowers");
migrationBuilder.AddColumn<int>(
name: "fid",
table: "records",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "photos",
columns: table => new
{
pid = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
rid = table.Column<int>(type: "INTEGER", nullable: false),
filetype = table.Column<string>(type: "TEXT", nullable: false),
filename = table.Column<string>(type: "TEXT", nullable: false),
path = table.Column<string>(type: "TEXT", nullable: false),
dateupload = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_photos", x => x.pid);
table.ForeignKey(
name: "FK_photos_records_rid",
column: x => x.rid,
principalTable: "records",
principalColumn: "rid",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_records_fid",
table: "records",
column: "fid");
migrationBuilder.CreateIndex(
name: "IX_records_uid",
table: "records",
column: "uid");
migrationBuilder.CreateIndex(
name: "IX_flowers_uid",
table: "flowers",
column: "uid");
migrationBuilder.CreateIndex(
name: "IX_photos_rid",
table: "photos",
column: "rid");
migrationBuilder.AddForeignKey(
name: "FK_flowers_users_uid",
table: "flowers",
column: "uid",
principalTable: "users",
principalColumn: "uid",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_records_flowers_fid",
table: "records",
column: "fid",
principalTable: "flowers",
principalColumn: "fid",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_records_users_uid",
table: "records",
column: "uid",
principalTable: "users",
principalColumn: "uid",
onDelete: ReferentialAction.Cascade);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_flowers_users_uid",
table: "flowers");
migrationBuilder.DropForeignKey(
name: "FK_records_flowers_fid",
table: "records");
migrationBuilder.DropForeignKey(
name: "FK_records_users_uid",
table: "records");
migrationBuilder.DropTable(
name: "photos");
migrationBuilder.DropIndex(
name: "IX_records_fid",
table: "records");
migrationBuilder.DropIndex(
name: "IX_records_uid",
table: "records");
migrationBuilder.DropIndex(
name: "IX_flowers_uid",
table: "flowers");
migrationBuilder.DropColumn(
name: "fid",
table: "records");
migrationBuilder.AddColumn<byte[]>(
name: "photo",
table: "records",
type: "BLOB",
nullable: true);
migrationBuilder.AddColumn<byte[]>(
name: "photo",
table: "flowers",
type: "BLOB",
nullable: true);
}
}
}

View File

@ -1,58 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
/// <inheritdoc />
public partial class AddLatitudeLongitude : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<double>(
name: "latitude",
table: "records",
type: "REAL",
nullable: true);
migrationBuilder.AddColumn<double>(
name: "longitude",
table: "records",
type: "REAL",
nullable: true);
migrationBuilder.AddColumn<double>(
name: "latitude",
table: "flowers",
type: "REAL",
nullable: true);
migrationBuilder.AddColumn<double>(
name: "longitude",
table: "flowers",
type: "REAL",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "latitude",
table: "records");
migrationBuilder.DropColumn(
name: "longitude",
table: "records");
migrationBuilder.DropColumn(
name: "latitude",
table: "flowers");
migrationBuilder.DropColumn(
name: "longitude",
table: "flowers");
}
}
}

View File

@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Blahblah.FlowerStory.Server.Migrations
{
[DbContext(typeof(FlowerDatabase))]
[Migration("20230705083734_Add-Latitude-Longitude")]
partial class AddLatitudeLongitude
[Migration("20230712091736_InitialDb")]
partial class InitialDb
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -40,11 +40,11 @@ namespace Blahblah.FlowerStory.Server.Migrations
.HasColumnName("datebuy")
.HasAnnotation("Relational:JsonPropertyName", "dateBuy");
b.Property<double?>("LastLatitude")
b.Property<double?>("Latitude")
.HasColumnType("REAL")
.HasColumnName("latitude");
b.Property<double?>("LastLongitude")
b.Property<double?>("Longitude")
.HasColumnType("REAL")
.HasColumnName("longitude");
@ -94,7 +94,7 @@ namespace Blahblah.FlowerStory.Server.Migrations
.HasColumnType("TEXT")
.HasColumnName("filetype");
b.Property<int>("FlowerId")
b.Property<int?>("FlowerId")
.HasColumnType("INTEGER")
.HasColumnName("fid");
@ -103,7 +103,7 @@ namespace Blahblah.FlowerStory.Server.Migrations
.HasColumnType("TEXT")
.HasColumnName("path");
b.Property<int>("RecordId")
b.Property<int?>("RecordId")
.HasColumnType("INTEGER")
.HasColumnName("rid");
@ -286,15 +286,11 @@ namespace Blahblah.FlowerStory.Server.Migrations
{
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", "Flower")
.WithMany("Photos")
.HasForeignKey("FlowerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("FlowerId");
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.RecordItem", "Record")
.WithMany("Photos")
.HasForeignKey("RecordId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("RecordId");
b.Navigation("Flower");

View File

@ -0,0 +1,187 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Blahblah.FlowerStory.Server.Migrations
{
/// <inheritdoc />
public partial class InitialDb : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "tokens",
columns: table => new
{
tid = table.Column<string>(type: "TEXT", nullable: false),
uid = table.Column<int>(type: "INTEGER", nullable: false),
logondate = table.Column<long>(type: "INTEGER", nullable: false),
activedate = table.Column<long>(type: "INTEGER", nullable: false),
expiredate = table.Column<long>(type: "INTEGER", nullable: false),
expiresecs = table.Column<int>(type: "INTEGER", nullable: false),
verifycode = table.Column<string>(type: "TEXT", nullable: true),
clientapp = table.Column<string>(type: "TEXT", nullable: true),
deviceid = table.Column<string>(type: "TEXT", nullable: true),
clientagent = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_tokens", x => x.tid);
});
migrationBuilder.CreateTable(
name: "users",
columns: table => new
{
uid = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
id = table.Column<string>(type: "TEXT", nullable: false),
password = table.Column<string>(type: "TEXT", nullable: false),
level = table.Column<int>(type: "INTEGER", nullable: false),
regdate = table.Column<long>(type: "INTEGER", nullable: false),
activedate = table.Column<long>(type: "INTEGER", nullable: true),
name = table.Column<string>(type: "TEXT", nullable: false),
email = table.Column<string>(type: "TEXT", nullable: true),
mobile = table.Column<string>(type: "TEXT", nullable: true),
avatar = table.Column<byte[]>(type: "BLOB", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_users", x => x.uid);
});
migrationBuilder.CreateTable(
name: "flowers",
columns: table => new
{
fid = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
uid = table.Column<int>(type: "INTEGER", nullable: false),
categoryid = table.Column<int>(type: "INTEGER", nullable: false),
name = table.Column<string>(type: "TEXT", nullable: false),
datebuy = table.Column<long>(type: "INTEGER", nullable: false),
cost = table.Column<decimal>(type: "real", nullable: true),
purchase = table.Column<string>(type: "TEXT", nullable: true),
memo = table.Column<string>(type: "TEXT", nullable: true),
latitude = table.Column<double>(type: "REAL", nullable: true),
longitude = table.Column<double>(type: "REAL", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_flowers", x => x.fid);
table.ForeignKey(
name: "FK_flowers_users_uid",
column: x => x.uid,
principalTable: "users",
principalColumn: "uid",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "records",
columns: table => new
{
rid = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
uid = table.Column<int>(type: "INTEGER", nullable: false),
fid = table.Column<int>(type: "INTEGER", nullable: false),
eid = table.Column<int>(type: "INTEGER", nullable: false),
date = table.Column<long>(type: "INTEGER", nullable: false),
byuid = table.Column<int>(type: "INTEGER", nullable: true),
byname = table.Column<string>(type: "TEXT", nullable: true),
memo = table.Column<string>(type: "TEXT", nullable: true),
latitude = table.Column<double>(type: "REAL", nullable: true),
longitude = table.Column<double>(type: "REAL", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_records", x => x.rid);
table.ForeignKey(
name: "FK_records_flowers_fid",
column: x => x.fid,
principalTable: "flowers",
principalColumn: "fid",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_records_users_uid",
column: x => x.uid,
principalTable: "users",
principalColumn: "uid",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "photos",
columns: table => new
{
pid = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
fid = table.Column<int>(type: "INTEGER", nullable: true),
rid = table.Column<int>(type: "INTEGER", nullable: true),
filetype = table.Column<string>(type: "TEXT", nullable: false),
filename = table.Column<string>(type: "TEXT", nullable: false),
path = table.Column<string>(type: "TEXT", nullable: false),
dateupload = table.Column<long>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_photos", x => x.pid);
table.ForeignKey(
name: "FK_photos_flowers_fid",
column: x => x.fid,
principalTable: "flowers",
principalColumn: "fid");
table.ForeignKey(
name: "FK_photos_records_rid",
column: x => x.rid,
principalTable: "records",
principalColumn: "rid");
});
migrationBuilder.CreateIndex(
name: "IX_flowers_uid",
table: "flowers",
column: "uid");
migrationBuilder.CreateIndex(
name: "IX_photos_fid",
table: "photos",
column: "fid");
migrationBuilder.CreateIndex(
name: "IX_photos_rid",
table: "photos",
column: "rid");
migrationBuilder.CreateIndex(
name: "IX_records_fid",
table: "records",
column: "fid");
migrationBuilder.CreateIndex(
name: "IX_records_uid",
table: "records",
column: "uid");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "photos");
migrationBuilder.DropTable(
name: "tokens");
migrationBuilder.DropTable(
name: "records");
migrationBuilder.DropTable(
name: "flowers");
migrationBuilder.DropTable(
name: "users");
}
}
}

View File

@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Blahblah.FlowerStory.Server.Migrations
{
[DbContext(typeof(FlowerDatabase))]
[Migration("20230525091254_AddPhotosFlowerForeignKey")]
partial class AddPhotosFlowerForeignKey
[Migration("20230712093151_AddPhotoOwnerKey")]
partial class AddPhotoOwnerKey
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -40,6 +40,14 @@ namespace Blahblah.FlowerStory.Server.Migrations
.HasColumnName("datebuy")
.HasAnnotation("Relational:JsonPropertyName", "dateBuy");
b.Property<double?>("Latitude")
.HasColumnType("REAL")
.HasColumnName("latitude");
b.Property<double?>("Longitude")
.HasColumnType("REAL")
.HasColumnName("longitude");
b.Property<string>("Memo")
.HasColumnType("TEXT")
.HasColumnName("memo");
@ -86,16 +94,20 @@ namespace Blahblah.FlowerStory.Server.Migrations
.HasColumnType("TEXT")
.HasColumnName("filetype");
b.Property<int>("FlowerId")
b.Property<int?>("FlowerId")
.HasColumnType("INTEGER")
.HasColumnName("fid");
b.Property<int>("OwnerId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("path");
b.Property<int>("RecordId")
b.Property<int?>("RecordId")
.HasColumnType("INTEGER")
.HasColumnName("rid");
@ -103,6 +115,8 @@ namespace Blahblah.FlowerStory.Server.Migrations
b.HasIndex("FlowerId");
b.HasIndex("OwnerId");
b.HasIndex("RecordId");
b.ToTable("photos");
@ -136,6 +150,14 @@ namespace Blahblah.FlowerStory.Server.Migrations
.HasColumnType("INTEGER")
.HasColumnName("fid");
b.Property<double?>("Latitude")
.HasColumnType("REAL")
.HasColumnName("latitude");
b.Property<double?>("Longitude")
.HasColumnType("REAL")
.HasColumnName("longitude");
b.Property<string>("Memo")
.HasColumnType("TEXT")
.HasColumnName("memo");
@ -270,18 +292,22 @@ namespace Blahblah.FlowerStory.Server.Migrations
{
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", "Flower")
.WithMany("Photos")
.HasForeignKey("FlowerId")
.HasForeignKey("FlowerId");
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.UserItem", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.RecordItem", "Record")
.WithMany("Photos")
.HasForeignKey("RecordId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("RecordId");
b.Navigation("Flower");
b.Navigation("Owner");
b.Navigation("Record");
});

View File

@ -5,29 +5,29 @@
namespace Blahblah.FlowerStory.Server.Migrations
{
/// <inheritdoc />
public partial class AddPhotosFlowerForeignKey : Migration
public partial class AddPhotoOwnerKey : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "fid",
name: "uid",
table: "photos",
type: "INTEGER",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_photos_fid",
name: "IX_photos_uid",
table: "photos",
column: "fid");
column: "uid");
migrationBuilder.AddForeignKey(
name: "FK_photos_flowers_fid",
name: "FK_photos_users_uid",
table: "photos",
column: "fid",
principalTable: "flowers",
principalColumn: "fid",
column: "uid",
principalTable: "users",
principalColumn: "uid",
onDelete: ReferentialAction.Cascade);
}
@ -35,15 +35,15 @@ namespace Blahblah.FlowerStory.Server.Migrations
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_photos_flowers_fid",
name: "FK_photos_users_uid",
table: "photos");
migrationBuilder.DropIndex(
name: "IX_photos_fid",
name: "IX_photos_uid",
table: "photos");
migrationBuilder.DropColumn(
name: "fid",
name: "uid",
table: "photos");
}
}

View File

@ -37,11 +37,11 @@ namespace Blahblah.FlowerStory.Server.Migrations
.HasColumnName("datebuy")
.HasAnnotation("Relational:JsonPropertyName", "dateBuy");
b.Property<double?>("LastLatitude")
b.Property<double?>("Latitude")
.HasColumnType("REAL")
.HasColumnName("latitude");
b.Property<double?>("LastLongitude")
b.Property<double?>("Longitude")
.HasColumnType("REAL")
.HasColumnName("longitude");
@ -66,7 +66,7 @@ namespace Blahblah.FlowerStory.Server.Migrations
b.HasIndex("OwnerId");
b.ToTable("flowers", (string)null);
b.ToTable("flowers");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.PhotoItem", b =>
@ -91,16 +91,20 @@ namespace Blahblah.FlowerStory.Server.Migrations
.HasColumnType("TEXT")
.HasColumnName("filetype");
b.Property<int>("FlowerId")
b.Property<int?>("FlowerId")
.HasColumnType("INTEGER")
.HasColumnName("fid");
b.Property<int>("OwnerId")
.HasColumnType("INTEGER")
.HasColumnName("uid");
b.Property<string>("Path")
.IsRequired()
.HasColumnType("TEXT")
.HasColumnName("path");
b.Property<int>("RecordId")
b.Property<int?>("RecordId")
.HasColumnType("INTEGER")
.HasColumnName("rid");
@ -108,9 +112,11 @@ namespace Blahblah.FlowerStory.Server.Migrations
b.HasIndex("FlowerId");
b.HasIndex("OwnerId");
b.HasIndex("RecordId");
b.ToTable("photos", (string)null);
b.ToTable("photos");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.RecordItem", b =>
@ -163,7 +169,7 @@ namespace Blahblah.FlowerStory.Server.Migrations
b.HasIndex("OwnerId");
b.ToTable("records", (string)null);
b.ToTable("records");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.TokenItem", b =>
@ -213,7 +219,7 @@ namespace Blahblah.FlowerStory.Server.Migrations
b.HasKey("Id");
b.ToTable("tokens", (string)null);
b.ToTable("tokens");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.UserItem", b =>
@ -265,7 +271,7 @@ namespace Blahblah.FlowerStory.Server.Migrations
b.HasKey("Id");
b.ToTable("users", (string)null);
b.ToTable("users");
});
modelBuilder.Entity("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", b =>
@ -283,18 +289,22 @@ namespace Blahblah.FlowerStory.Server.Migrations
{
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.FlowerItem", "Flower")
.WithMany("Photos")
.HasForeignKey("FlowerId")
.HasForeignKey("FlowerId");
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.UserItem", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Blahblah.FlowerStory.Server.Data.Model.RecordItem", "Record")
.WithMany("Photos")
.HasForeignKey("RecordId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("RecordId");
b.Navigation("Flower");
b.Navigation("Owner");
b.Navigation("Record");
});