using System; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace SimpleWiki.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "users", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), FullName = table.Column(type: "TEXT", maxLength: 100, nullable: false), Email = table.Column(type: "TEXT", maxLength: 256, nullable: false), PasswordHash = table.Column(type: "TEXT", maxLength: 512, nullable: false), Role = table.Column(type: "TEXT", maxLength: 16, nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false) }, constraints: table => { table.PrimaryKey("PK_users", x => x.Id); }); migrationBuilder.CreateTable( name: "articles", columns: table => new { Id = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), Title = table.Column(type: "TEXT", maxLength: 150, nullable: false), Slug = table.Column(type: "TEXT", maxLength: 180, nullable: false), Summary = table.Column(type: "TEXT", maxLength: 400, nullable: false), MarkdownContent = table.Column(type: "TEXT", maxLength: 20000, nullable: false), CreatedAt = table.Column(type: "TEXT", nullable: false), UpdatedAt = table.Column(type: "TEXT", nullable: true), AuthorId = table.Column(type: "INTEGER", nullable: false) }, constraints: table => { table.PrimaryKey("PK_articles", x => x.Id); table.ForeignKey( name: "FK_articles_users_AuthorId", column: x => x.AuthorId, principalTable: "users", principalColumn: "Id", onDelete: ReferentialAction.Restrict); }); migrationBuilder.CreateIndex( name: "IX_articles_AuthorId", table: "articles", column: "AuthorId"); migrationBuilder.CreateIndex( name: "IX_articles_Slug", table: "articles", column: "Slug", unique: true); migrationBuilder.CreateIndex( name: "IX_articles_Title", table: "articles", column: "Title"); migrationBuilder.CreateIndex( name: "IX_users_Email", table: "users", column: "Email", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "articles"); migrationBuilder.DropTable( name: "users"); } } }