85 lines
3.5 KiB
C#
85 lines
3.5 KiB
C#
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
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddActionLogs : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterDatabase()
|
|
.Annotation("Npgsql:PostgresExtension:postgis", ",,");
|
|
|
|
migrationBuilder.AddColumn<Point>(
|
|
name: "location",
|
|
table: "auth_challenges",
|
|
type: "geometry",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "action_logs",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
action = table.Column<string>(type: "character varying(4096)", maxLength: 4096, nullable: false),
|
|
meta = table.Column<Dictionary<string, object>>(type: "jsonb", nullable: false),
|
|
user_agent = table.Column<string>(type: "character varying(512)", maxLength: 512, nullable: true),
|
|
ip_address = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
|
location = table.Column<Point>(type: "geometry", nullable: true),
|
|
account_id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
session_id = table.Column<Guid>(type: "uuid", nullable: true),
|
|
created_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
updated_at = table.Column<Instant>(type: "timestamp with time zone", nullable: false),
|
|
deleted_at = table.Column<Instant>(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");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "action_logs");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "location",
|
|
table: "auth_challenges");
|
|
|
|
migrationBuilder.AlterDatabase()
|
|
.OldAnnotation("Npgsql:PostgresExtension:postgis", ",,");
|
|
}
|
|
}
|
|
}
|