using System; using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Migrations; using NetTopologySuite.Geometries; using NodaTime; using Point = NetTopologySuite.Geometries.Point; #nullable disable namespace DysonNetwork.Sphere.Migrations { /// public partial class AddActionLogs : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:postgis", ",,"); migrationBuilder.AddColumn( name: "location", table: "auth_challenges", type: "geometry", nullable: true); migrationBuilder.CreateTable( name: "action_logs", columns: table => new { id = table.Column(type: "uuid", nullable: false), action = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: false), meta = table.Column>(type: "jsonb", nullable: false), user_agent = table.Column(type: "character varying(512)", maxLength: 512, nullable: true), ip_address = table.Column(type: "character varying(128)", maxLength: 128, nullable: true), location = table.Column(type: "geometry", nullable: true), account_id = table.Column(type: "uuid", nullable: false), session_id = table.Column(type: "uuid", nullable: true), 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_action_logs", x => x.id); table.ForeignKey( name: "fk_action_logs_accounts_account_id", column: x => x.account_id, principalTable: "accounts", principalColumn: "id", onDelete: ReferentialAction.Cascade); table.ForeignKey( name: "fk_action_logs_auth_sessions_session_id", column: x => x.session_id, principalTable: "auth_sessions", principalColumn: "id"); }); migrationBuilder.CreateIndex( name: "ix_action_logs_account_id", table: "action_logs", column: "account_id"); migrationBuilder.CreateIndex( name: "ix_action_logs_session_id", table: "action_logs", column: "session_id"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( name: "action_logs"); migrationBuilder.DropColumn( name: "location", table: "auth_challenges"); migrationBuilder.AlterDatabase() .OldAnnotation("Npgsql:PostgresExtension:postgis", ",,"); } } }