using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace WordVersioning.Api.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Documents", columns: table => new { Id = table.Column(type: "uuid", nullable: false), FileName = table.Column(type: "character varying(512)", maxLength: 512, nullable: false), AddInSignature = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), TemplateId = table.Column(type: "uuid", nullable: true), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Documents", x => x.Id); }); migrationBuilder.CreateTable( name: "DocumentVersions", columns: table => new { Id = table.Column(type: "uuid", nullable: false), DocumentId = table.Column(type: "uuid", nullable: false), VersionNumber = table.Column(type: "integer", nullable: false), ObjectKey = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: false), ContentHash = table.Column(type: "character varying(64)", maxLength: 64, nullable: false), CreatedByUserId = table.Column(type: "text", nullable: false), CreatedAt = table.Column(type: "timestamp with time zone", nullable: false), FieldsSnapshotJson = table.Column(type: "text", nullable: true) }, constraints: table => { table.PrimaryKey("PK_DocumentVersions", x => x.Id); table.ForeignKey( name: "FK_DocumentVersions_Documents_DocumentId", column: x => x.DocumentId, principalTable: "Documents", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_DocumentVersions_DocumentId_VersionNumber", table: "DocumentVersions", columns: new[] { "DocumentId", "VersionNumber" }, unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "DocumentVersions"); migrationBuilder.DropTable( name: "Documents"); } } }