using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace FileShare_EFCore.Migrations.SQLite { /// public partial class AddFileLibrary : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "managed-library-root", columns: table => new { id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), path = table.Column(type: "TEXT", maxLength: 1024, nullable: false), displayname = table.Column(name: "display-name", type: "TEXT", maxLength: 200, nullable: false), isenabled = table.Column(name: "is-enabled", type: "INTEGER", nullable: false), isavailable = table.Column(name: "is-available", type: "INTEGER", nullable: false, defaultValue: true), scanintervalminutes = table.Column(name: "scan-interval-minutes", type: "INTEGER", nullable: false), lastscanstartedat = table.Column(name: "last-scan-started-at", type: "TEXT", nullable: true), lastscancompletedat = table.Column(name: "last-scan-completed-at", type: "TEXT", nullable: true), lastscanerror = table.Column(name: "last-scan-error", type: "TEXT", maxLength: 2000, nullable: true), createdat = table.Column(name: "created-at", type: "TEXT", nullable: false), updatedat = table.Column(name: "updated-at", type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("pk-managed-library-root", x => x.id); }, comment: "文件库根目录"); migrationBuilder.CreateTable( name: "managed-file-record", columns: table => new { id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), libraryrootid = table.Column(name: "library-root-id", type: "INTEGER", nullable: false), filename = table.Column(name: "file-name", type: "TEXT", maxLength: 260, nullable: false), relativepath = table.Column(name: "relative-path", type: "TEXT", maxLength: 1024, nullable: false), absolutepath = table.Column(name: "absolute-path", type: "TEXT", maxLength: 2048, nullable: false), extension = table.Column(type: "TEXT", maxLength: 32, nullable: false), sizebytes = table.Column(name: "size-bytes", type: "INTEGER", nullable: false), lastwritetimeutc = table.Column(name: "last-write-time-utc", type: "TEXT", nullable: false), mediatype = table.Column(name: "media-type", type: "TEXT", maxLength: 20, nullable: false), contenttype = table.Column(name: "content-type", type: "TEXT", maxLength: 100, nullable: false), exists = table.Column(type: "INTEGER", nullable: false), lastseenat = table.Column(name: "last-seen-at", type: "TEXT", nullable: false), createdat = table.Column(name: "created-at", type: "TEXT", nullable: false), updatedat = table.Column(name: "updated-at", type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("pk-managed-file-record", x => x.id); table.ForeignKey( name: "FK_managed-file-record_managed-library-root_library-root-id", column: x => x.libraryrootid, principalTable: "managed-library-root", principalColumn: "id", onDelete: ReferentialAction.Cascade); }, comment: "文件库文件记录"); migrationBuilder.CreateIndex( name: "idx-managed-file-record-absolute-path", table: "managed-file-record", column: "absolute-path", unique: true); migrationBuilder.CreateIndex( name: "idx-managed-file-record-media-type-exists", table: "managed-file-record", columns: new[] { "media-type", "exists" }); migrationBuilder.CreateIndex( name: "idx-managed-file-record-root-id", table: "managed-file-record", column: "library-root-id"); migrationBuilder.CreateIndex( name: "idx-managed-library-root-path", table: "managed-library-root", column: "path", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "managed-file-record"); migrationBuilder.DropTable( name: "managed-library-root"); } } }