using System; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; #nullable disable namespace AAIntegration.SimmonsBank.API.Migrations { /// public partial class InitialCreate : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Accounts", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Name = table.Column(type: "text", nullable: false), Balance = table.Column(type: "numeric", nullable: false), ExternalAccountNumber = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Accounts", x => x.Id); }); migrationBuilder.CreateTable( name: "Users", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), ApiKey = table.Column(type: "text", nullable: false), SimmonsBankUsername = table.Column(type: "text", nullable: false), SimmonsBankPassword = table.Column(type: "text", nullable: false), MFAKey = table.Column(type: "text", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Users", x => x.Id); }); migrationBuilder.CreateTable( name: "Transactions", columns: table => new { Id = table.Column(type: "integer", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), Date = table.Column(type: "timestamp with time zone", nullable: false), CreatedOn = table.Column(type: "timestamp with time zone", nullable: false), UpdatedOn = table.Column(type: "timestamp with time zone", nullable: false), ExternalId = table.Column(type: "text", nullable: false), Description = table.Column(type: "text", nullable: false), DebitAccountId = table.Column(type: "integer", nullable: true), CreditAccountId = table.Column(type: "integer", nullable: true), Amount = table.Column(type: "numeric", nullable: false), IsPending = table.Column(type: "boolean", nullable: false) }, constraints: table => { table.PrimaryKey("PK_Transactions", x => x.Id); table.ForeignKey( name: "FK_Transactions_Accounts_CreditAccountId", column: x => x.CreditAccountId, principalTable: "Accounts", principalColumn: "Id"); table.ForeignKey( name: "FK_Transactions_Accounts_DebitAccountId", column: x => x.DebitAccountId, principalTable: "Accounts", principalColumn: "Id"); }); migrationBuilder.CreateIndex( name: "IX_Transactions_CreditAccountId", table: "Transactions", column: "CreditAccountId"); migrationBuilder.CreateIndex( name: "IX_Transactions_DebitAccountId", table: "Transactions", column: "DebitAccountId"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "Transactions"); migrationBuilder.DropTable( name: "Users"); migrationBuilder.DropTable( name: "Accounts"); } } }