using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Migrations; using NodaTime; #nullable disable namespace DysonNetwork.Sphere.Migrations { /// public partial class AddAuthSession : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "auth_challenges", columns: table => new { id = table.Column(type: "uuid", nullable: false), expired_at = table.Column(type: "timestamp with time zone", nullable: true), step_remain = table.Column(type: "integer", nullable: false), step_total = table.Column(type: "integer", nullable: false), blacklist_factors = table.Column>(type: "jsonb", nullable: false), audiences = table.Column>(type: "jsonb", nullable: false), scopes = table.Column>(type: "jsonb", nullable: false), ip_address = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), user_agent = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), device_id = table.Column(type: "character varying(256)", maxLength: 256, nullable: true), nonce = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: true), account_id = table.Column(type: "bigint", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), deleted_at = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("pk_auth_challenges", x => x.id); table.ForeignKey( name: "fk_auth_challenges_accounts_account_id", column: x => x.account_id, principalTable: "accounts", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( name: "auth_sessions", columns: table => new { id = table.Column(type: "uuid", nullable: false), last_granted_at = table.Column(type: "timestamp with time zone", nullable: true), expired_at = table.Column(type: "timestamp with time zone", nullable: true), account_id = table.Column(type: "bigint", nullable: false), challenge_id = table.Column(type: "uuid", nullable: false), created_at = table.Column(type: "timestamp with time zone", nullable: false), updated_at = table.Column(type: "timestamp with time zone", nullable: false), deleted_at = table.Column(type: "timestamp with time zone", nullable: true) }, constraints: table => { table.PrimaryKey("pk_auth_sessions", x => x.id); table.ForeignKey( name: "fk_auth_sessions_accounts_account_id", column: x => x.account_id, principalTable: "accounts", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_auth_sessions_auth_challenges_challenge_id", column: x => x.challenge_id, principalTable: "auth_challenges", principalColumn: "id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateIndex( name: "ix_auth_challenges_account_id", table: "auth_challenges", column: "account_id"); migrationBuilder.CreateIndex( name: "ix_auth_sessions_account_id", table: "auth_sessions", column: "account_id"); migrationBuilder.CreateIndex( name: "ix_auth_sessions_challenge_id", table: "auth_sessions", column: "challenge_id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "auth_sessions"); migrationBuilder.DropTable( name: "auth_challenges"); } } }