diff --git a/shared/migrations/InkForge.Sqlite/Migrations/20240207000000_Initial.Designer.cs b/shared/migrations/InkForge.Sqlite/Migrations/20240207000000_Initial.Designer.cs new file mode 100644 index 0000000..ccba16e --- /dev/null +++ b/shared/migrations/InkForge.Sqlite/Migrations/20240207000000_Initial.Designer.cs @@ -0,0 +1,172 @@ +// +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("20240207000000_Initial")] + partial class Initial + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.1"); + + modelBuilder.Entity("InkForge.Data.Blob", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("Content") + .IsRequired() + .HasColumnType("BLOB"); + + b.HasKey("Id"); + + b.ToTable("Blobs"); + }); + + modelBuilder.Entity("InkForge.Data.Infrastructure.NoteEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Notes"); + }); + + modelBuilder.Entity("InkForge.Data.Infrastructure.NoteVersionEntity", b => + { + b.Property("Version") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("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("ParentId") + .HasColumnType("INTEGER"); + + b1.Property("ContentId") + .IsRequired() + .HasColumnType("TEXT"); + + b1.Property("Created") + .HasColumnType("TEXT"); + + b1.Property("Deleted") + .HasColumnType("TEXT"); + + b1.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b1.Property("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("NoteVersionEntityVersion") + .HasColumnType("INTEGER"); + + b1.Property("ContentId") + .IsRequired() + .HasColumnType("TEXT"); + + b1.Property("Created") + .HasColumnType("TEXT"); + + b1.Property("Deleted") + .HasColumnType("TEXT"); + + b1.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b1.Property("ParentId") + .HasColumnType("INTEGER"); + + b1.Property("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 + } + } +} diff --git a/shared/migrations/InkForge.Sqlite/Migrations/20240207000000_Initial.cs b/shared/migrations/InkForge.Sqlite/Migrations/20240207000000_Initial.cs new file mode 100644 index 0000000..34601ad --- /dev/null +++ b/shared/migrations/InkForge.Sqlite/Migrations/20240207000000_Initial.cs @@ -0,0 +1,114 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace InkForge.Sqlite.Migrations +{ + /// + public partial class Initial : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Blobs", + columns: table => new + { + Id = table.Column(type: "TEXT", nullable: false), + Content = table.Column(type: "BLOB", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Blobs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Notes", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Value_Created = table.Column(type: "TEXT", nullable: false), + Value_Name = table.Column(type: "TEXT", nullable: false), + Value_Updated = table.Column(type: "TEXT", nullable: false), + Value_Deleted = table.Column(type: "TEXT", nullable: true), + Value_ContentId = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Notes", x => x.Id); + table.ForeignKey( + name: "FK_Notes_Blobs_Value_ContentId", + column: x => x.Value_ContentId, + principalTable: "Blobs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "NoteVersions", + columns: table => new + { + Version = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Value_Created = table.Column(type: "TEXT", nullable: false), + Value_ParentId = table.Column(type: "INTEGER", nullable: true), + Value_Name = table.Column(type: "TEXT", nullable: false), + Value_Updated = table.Column(type: "TEXT", nullable: false), + Value_Deleted = table.Column(type: "TEXT", nullable: true), + Value_ContentId = table.Column(type: "TEXT", nullable: false), + Id = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_NoteVersions", x => x.Version); + table.ForeignKey( + name: "FK_NoteVersions_Blobs_Value_ContentId", + column: x => x.Value_ContentId, + principalTable: "Blobs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_NoteVersions_Notes_Value_ParentId", + column: x => x.Value_ParentId, + principalTable: "Notes", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Notes_Value_ContentId", + table: "Notes", + column: "Value_ContentId"); + + migrationBuilder.CreateIndex( + name: "IX_NoteVersions_Id_Version", + table: "NoteVersions", + columns: new[] { "Id", "Version" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_NoteVersions_Value_ContentId", + table: "NoteVersions", + column: "Value_ContentId"); + + migrationBuilder.CreateIndex( + name: "IX_NoteVersions_Value_ParentId", + table: "NoteVersions", + column: "Value_ParentId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "NoteVersions"); + + migrationBuilder.DropTable( + name: "Notes"); + + migrationBuilder.DropTable( + name: "Blobs"); + } + } +} diff --git a/shared/migrations/InkForge.Sqlite/Migrations/NoteDbContextModelSnapshot.cs b/shared/migrations/InkForge.Sqlite/Migrations/NoteDbContextModelSnapshot.cs new file mode 100644 index 0000000..c1f8a65 --- /dev/null +++ b/shared/migrations/InkForge.Sqlite/Migrations/NoteDbContextModelSnapshot.cs @@ -0,0 +1,169 @@ +// +using System; +using InkForge.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace InkForge.Sqlite.Migrations +{ + [DbContext(typeof(NoteDbContext))] + partial class NoteDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.1"); + + modelBuilder.Entity("InkForge.Data.Blob", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("Content") + .IsRequired() + .HasColumnType("BLOB"); + + b.HasKey("Id"); + + b.ToTable("Blobs"); + }); + + modelBuilder.Entity("InkForge.Data.Infrastructure.NoteEntity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Notes"); + }); + + modelBuilder.Entity("InkForge.Data.Infrastructure.NoteVersionEntity", b => + { + b.Property("Version") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("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("ParentId") + .HasColumnType("INTEGER"); + + b1.Property("ContentId") + .IsRequired() + .HasColumnType("TEXT"); + + b1.Property("Created") + .HasColumnType("TEXT"); + + b1.Property("Deleted") + .HasColumnType("TEXT"); + + b1.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b1.Property("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("NoteVersionEntityVersion") + .HasColumnType("INTEGER"); + + b1.Property("ContentId") + .IsRequired() + .HasColumnType("TEXT"); + + b1.Property("Created") + .HasColumnType("TEXT"); + + b1.Property("Deleted") + .HasColumnType("TEXT"); + + b1.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b1.Property("ParentId") + .HasColumnType("INTEGER"); + + b1.Property("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 + } + } +}