using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace TimetableDesigner.API.Services.Authentication.Database.Migrations { /// public partial class Initial : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Accounts", columns: table => new { Id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityAlwaysColumn), Email = table.Column(type: "character varying(320)", maxLength: 320, nullable: false), Password = table.Column(type: "bytea", maxLength: 1000, nullable: false), PasswordSaltLeft = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), PasswordSaltRight = table.Column(type: "character varying(20)", maxLength: 20, nullable: false), xmin = table.Column(type: "xid", rowVersion: true, nullable: false) }, constraints: table => { table.PrimaryKey("PK_Accounts", x => x.Id); }); migrationBuilder.CreateTable( name: "RefreshTokens", columns: table => new { Token = table.Column(type: "uuid", nullable: false), AccountId = table.Column(type: "bigint", nullable: false), ExpirationDate = table.Column(type: "timestamp with time zone", nullable: false), IsExtendable = table.Column(type: "boolean", nullable: false), xmin = table.Column(type: "xid", rowVersion: true, nullable: false) }, constraints: table => { table.PrimaryKey("PK_RefreshTokens", x => x.Token); table.ForeignKey( name: "FK_RefreshTokens_Accounts_AccountId", column: x => x.AccountId, principalTable: "Accounts", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "IX_Accounts_Id", table: "Accounts", column: "Id", unique: true); migrationBuilder.CreateIndex( name: "IX_RefreshTokens_AccountId", table: "RefreshTokens", column: "AccountId"); migrationBuilder.CreateIndex( name: "IX_RefreshTokens_Token", table: "RefreshTokens", column: "Token", unique: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "RefreshTokens"); migrationBuilder.DropTable( name: "Accounts"); } } }