using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace WatchIt.Database.Migrations { /// public partial class Migration1 : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "AccountProfilePictures", columns: table => new { Id = table.Column(type: "uuid", nullable: false), Image = table.Column(type: "bytea", maxLength: -1, nullable: false), MimeType = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), UploadDate = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()") }, constraints: table => { table.PrimaryKey("PK_AccountProfilePictures", x => x.Id); }); migrationBuilder.CreateTable( name: "Accounts", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Username = table.Column(type: "character varying(50)", maxLength: 50, nullable: false), Email = table.Column(type: "character varying(320)", maxLength: 320, nullable: false), Description = table.Column(type: "character varying(1000)", maxLength: 1000, nullable: false), AccountProfilePictureId = table.Column(type: "uuid", nullable: false), Password = table.Column(type: "bytea", maxLength: 1000, nullable: false), LeftSalt = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), RightSalt = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), IsAdmin = table.Column(type: "boolean", nullable: false), CreationDate = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"), LastActive = table.Column(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()") }, constraints: table => { table.PrimaryKey("PK_Accounts", x => x.Id); table.ForeignKey( name: "FK_Accounts_AccountProfilePictures_AccountProfilePictureId", column: x => x.AccountProfilePictureId, principalTable: "AccountProfilePictures", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_AccountProfilePictures_Id", table: "AccountProfilePictures", column: "Id", unique: true); migrationBuilder.CreateIndex( name: "IX_Accounts_AccountProfilePictureId", table: "Accounts", column: "AccountProfilePictureId", unique: true); migrationBuilder.CreateIndex( name: "IX_Accounts_Id", table: "Accounts", column: "Id", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Accounts"); migrationBuilder.DropTable( name: "AccountProfilePictures"); } } }