Workspace Metadata Rows

This commit is contained in:
Jöran Malek 2024-02-16 02:24:25 +01:00
parent e9c6e14965
commit a62b5a1f29
8 changed files with 324 additions and 7 deletions

View file

@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace InkForge.Sqlite.Migrations
{
[DbContext(typeof(NoteDbContext))]
[Migration("20240207000000_Initial")]
partial class Initial
[Migration("20240207000000__01_Initial")]
partial class _01_Initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)

View file

@ -6,7 +6,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace InkForge.Sqlite.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
public partial class _01_Initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)

View file

@ -0,0 +1,207 @@
// <auto-generated />
using System;
using InkForge.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace InkForge.Sqlite.Migrations
{
[DbContext(typeof(NoteDbContext))]
[Migration("20240214000000__02_Metadata")]
partial class _02_Metadata
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
modelBuilder.Entity("InkForge.Data.Blob", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<byte[]>("Content")
.IsRequired()
.HasColumnType("BLOB");
b.HasKey("Id");
b.ToTable("Blobs");
});
modelBuilder.Entity("InkForge.Data.Infrastructure.MetadataEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Metadata");
});
modelBuilder.Entity("InkForge.Data.Infrastructure.MetadataVersionEntity", b =>
{
b.Property<int?>("Version")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Version");
b.HasIndex("Id", "Version")
.IsUnique();
b.ToTable("MetadataHistory");
});
modelBuilder.Entity("InkForge.Data.Infrastructure.NoteEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.HasKey("Id");
b.ToTable("Notes");
});
modelBuilder.Entity("InkForge.Data.Infrastructure.NoteVersionEntity", b =>
{
b.Property<int?>("Version")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<int>("Id")
.HasColumnType("INTEGER");
b.HasKey("Version");
b.HasIndex("Id", "Version")
.IsUnique();
b.ToTable("NoteVersions");
});
modelBuilder.Entity("InkForge.Data.Infrastructure.NoteEntity", b =>
{
b.OwnsOne("InkForge.Data.Domain.Note", "Value", b1 =>
{
b1.Property<int>("ParentId")
.HasColumnType("INTEGER");
b1.Property<string>("ContentId")
.IsRequired()
.HasColumnType("TEXT");
b1.Property<DateTimeOffset>("Created")
.HasColumnType("TEXT");
b1.Property<DateTimeOffset?>("Deleted")
.HasColumnType("TEXT");
b1.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b1.Property<DateTimeOffset>("Updated")
.HasColumnType("TEXT");
b1.HasKey("ParentId");
b1.HasIndex("ContentId");
b1.ToTable("Notes");
b1.HasOne("InkForge.Data.Blob", "Content")
.WithMany()
.HasForeignKey("ContentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b1.WithOwner("Parent")
.HasForeignKey("ParentId");
b1.Navigation("Content");
b1.Navigation("Parent");
});
b.Navigation("Value")
.IsRequired();
});
modelBuilder.Entity("InkForge.Data.Infrastructure.NoteVersionEntity", b =>
{
b.OwnsOne("InkForge.Data.Domain.Note", "Value", b1 =>
{
b1.Property<int>("NoteVersionEntityVersion")
.HasColumnType("INTEGER");
b1.Property<string>("ContentId")
.IsRequired()
.HasColumnType("TEXT");
b1.Property<DateTimeOffset>("Created")
.HasColumnType("TEXT");
b1.Property<DateTimeOffset?>("Deleted")
.HasColumnType("TEXT");
b1.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");
b1.Property<int?>("ParentId")
.HasColumnType("INTEGER");
b1.Property<DateTimeOffset>("Updated")
.HasColumnType("TEXT");
b1.HasKey("NoteVersionEntityVersion");
b1.HasIndex("ContentId");
b1.HasIndex("ParentId");
b1.ToTable("NoteVersions");
b1.HasOne("InkForge.Data.Blob", "Content")
.WithMany()
.HasForeignKey("ContentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b1.WithOwner()
.HasForeignKey("NoteVersionEntityVersion");
b1.HasOne("InkForge.Data.Infrastructure.NoteEntity", "Parent")
.WithMany()
.HasForeignKey("ParentId");
b1.Navigation("Content");
b1.Navigation("Parent");
});
b.Navigation("Value")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View file

@ -0,0 +1,56 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace InkForge.Sqlite.Migrations
{
/// <inheritdoc />
public partial class _02_Metadata : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Metadata",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", nullable: false),
Value = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Metadata", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MetadataHistory",
columns: table => new
{
Version = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Value = table.Column<string>(type: "TEXT", nullable: false),
Id = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_MetadataHistory", x => x.Version);
});
migrationBuilder.CreateIndex(
name: "IX_MetadataHistory_Id_Version",
table: "MetadataHistory",
columns: new[] { "Id", "Version" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Metadata");
migrationBuilder.DropTable(
name: "MetadataHistory");
}
}
}

View file

@ -15,7 +15,7 @@ namespace InkForge.Sqlite.Migrations
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.1");
modelBuilder.HasAnnotation("ProductVersion", "8.0.2");
modelBuilder.Entity("InkForge.Data.Blob", b =>
{
@ -31,9 +31,44 @@ namespace InkForge.Sqlite.Migrations
b.ToTable("Blobs");
});
modelBuilder.Entity("InkForge.Data.Infrastructure.MetadataEntity", b =>
{
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Metadata");
});
modelBuilder.Entity("InkForge.Data.Infrastructure.MetadataVersionEntity", b =>
{
b.Property<int?>("Version")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Id")
.HasColumnType("TEXT");
b.Property<string>("Value")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Version");
b.HasIndex("Id", "Version")
.IsUnique();
b.ToTable("MetadataHistory");
});
modelBuilder.Entity("InkForge.Data.Infrastructure.NoteEntity", b =>
{
b.Property<int?>("Id")
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");