GDPR stuff update (#18300)
This commit is contained in:
committed by
GitHub
parent
86f33a8fa2
commit
e0c4884995
1770
Content.Server.Database/Migrations/Postgres/20230725193102_AdminNotesImprovementsForeignKeys.Designer.cs
generated
Normal file
1770
Content.Server.Database/Migrations/Postgres/20230725193102_AdminNotesImprovementsForeignKeys.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,90 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Content.Server.Database.Migrations.Postgres
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AdminNotesImprovementsForeignKeys : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_messages_player_player_user_id",
|
||||||
|
table: "admin_messages");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_notes_player_player_user_id",
|
||||||
|
table: "admin_notes");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_watchlists_player_player_user_id",
|
||||||
|
table: "admin_watchlists");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_messages_player_player_user_id",
|
||||||
|
table: "admin_messages",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_notes_player_player_user_id",
|
||||||
|
table: "admin_notes",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_watchlists_player_player_user_id",
|
||||||
|
table: "admin_watchlists",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_messages_player_player_user_id",
|
||||||
|
table: "admin_messages");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_notes_player_player_user_id",
|
||||||
|
table: "admin_notes");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_watchlists_player_player_user_id",
|
||||||
|
table: "admin_watchlists");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_messages_player_player_user_id",
|
||||||
|
table: "admin_messages",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_notes_player_player_user_id",
|
||||||
|
table: "admin_notes",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_watchlists_player_player_user_id",
|
||||||
|
table: "admin_watchlists",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
@@ -317,10 +317,6 @@ namespace Content.Server.Database.Migrations.Postgres
|
|||||||
.HasColumnType("character varying(4096)")
|
.HasColumnType("character varying(4096)")
|
||||||
.HasColumnName("message");
|
.HasColumnName("message");
|
||||||
|
|
||||||
b.Property<int>("Severity")
|
|
||||||
.HasColumnType("integer")
|
|
||||||
.HasColumnName("severity");
|
|
||||||
|
|
||||||
b.Property<Guid?>("PlayerUserId")
|
b.Property<Guid?>("PlayerUserId")
|
||||||
.HasColumnType("uuid")
|
.HasColumnType("uuid")
|
||||||
.HasColumnName("player_user_id");
|
.HasColumnName("player_user_id");
|
||||||
@@ -337,6 +333,10 @@ namespace Content.Server.Database.Migrations.Postgres
|
|||||||
.HasColumnType("boolean")
|
.HasColumnType("boolean")
|
||||||
.HasColumnName("secret");
|
.HasColumnName("secret");
|
||||||
|
|
||||||
|
b.Property<int>("Severity")
|
||||||
|
.HasColumnType("integer")
|
||||||
|
.HasColumnName("severity");
|
||||||
|
|
||||||
b.HasKey("Id")
|
b.HasKey("Id")
|
||||||
.HasName("PK_admin_notes");
|
.HasName("PK_admin_notes");
|
||||||
|
|
||||||
@@ -1364,7 +1364,7 @@ namespace Content.Server.Database.Migrations.Postgres
|
|||||||
.WithMany("AdminMessagesReceived")
|
.WithMany("AdminMessagesReceived")
|
||||||
.HasForeignKey("PlayerUserId")
|
.HasForeignKey("PlayerUserId")
|
||||||
.HasPrincipalKey("UserId")
|
.HasPrincipalKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.SetNull)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.HasConstraintName("FK_admin_messages_player_player_user_id");
|
.HasConstraintName("FK_admin_messages_player_player_user_id");
|
||||||
|
|
||||||
b.HasOne("Content.Server.Database.Round", "Round")
|
b.HasOne("Content.Server.Database.Round", "Round")
|
||||||
@@ -1410,7 +1410,7 @@ namespace Content.Server.Database.Migrations.Postgres
|
|||||||
.WithMany("AdminNotesReceived")
|
.WithMany("AdminNotesReceived")
|
||||||
.HasForeignKey("PlayerUserId")
|
.HasForeignKey("PlayerUserId")
|
||||||
.HasPrincipalKey("UserId")
|
.HasPrincipalKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.SetNull)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.HasConstraintName("FK_admin_notes_player_player_user_id");
|
.HasConstraintName("FK_admin_notes_player_player_user_id");
|
||||||
|
|
||||||
b.HasOne("Content.Server.Database.Round", "Round")
|
b.HasOne("Content.Server.Database.Round", "Round")
|
||||||
@@ -1468,7 +1468,7 @@ namespace Content.Server.Database.Migrations.Postgres
|
|||||||
.WithMany("AdminWatchlistsReceived")
|
.WithMany("AdminWatchlistsReceived")
|
||||||
.HasForeignKey("PlayerUserId")
|
.HasForeignKey("PlayerUserId")
|
||||||
.HasPrincipalKey("UserId")
|
.HasPrincipalKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.SetNull)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.HasConstraintName("FK_admin_watchlists_player_player_user_id");
|
.HasConstraintName("FK_admin_watchlists_player_player_user_id");
|
||||||
|
|
||||||
b.HasOne("Content.Server.Database.Round", "Round")
|
b.HasOne("Content.Server.Database.Round", "Round")
|
||||||
|
|||||||
1698
Content.Server.Database/Migrations/Sqlite/20230725193058_AdminNotesImprovementsForeignKeys.Designer.cs
generated
Normal file
1698
Content.Server.Database/Migrations/Sqlite/20230725193058_AdminNotesImprovementsForeignKeys.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,90 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Content.Server.Database.Migrations.Sqlite
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AdminNotesImprovementsForeignKeys : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_messages_player_player_user_id",
|
||||||
|
table: "admin_messages");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_notes_player_player_user_id",
|
||||||
|
table: "admin_notes");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_watchlists_player_player_user_id",
|
||||||
|
table: "admin_watchlists");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_messages_player_player_user_id",
|
||||||
|
table: "admin_messages",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_notes_player_player_user_id",
|
||||||
|
table: "admin_notes",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_watchlists_player_player_user_id",
|
||||||
|
table: "admin_watchlists",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_messages_player_player_user_id",
|
||||||
|
table: "admin_messages");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_notes_player_player_user_id",
|
||||||
|
table: "admin_notes");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_admin_watchlists_player_player_user_id",
|
||||||
|
table: "admin_watchlists");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_messages_player_player_user_id",
|
||||||
|
table: "admin_messages",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_notes_player_player_user_id",
|
||||||
|
table: "admin_notes",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_admin_watchlists_player_player_user_id",
|
||||||
|
table: "admin_watchlists",
|
||||||
|
column: "player_user_id",
|
||||||
|
principalTable: "player",
|
||||||
|
principalColumn: "user_id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// <auto-generated />
|
// <auto-generated />
|
||||||
using System;
|
using System;
|
||||||
using Content.Server.Database;
|
using Content.Server.Database;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -295,10 +295,6 @@ namespace Content.Server.Database.Migrations.Sqlite
|
|||||||
.HasColumnType("TEXT")
|
.HasColumnType("TEXT")
|
||||||
.HasColumnName("message");
|
.HasColumnName("message");
|
||||||
|
|
||||||
b.Property<int>("Severity")
|
|
||||||
.HasColumnType("INTEGER")
|
|
||||||
.HasColumnName("severity");
|
|
||||||
|
|
||||||
b.Property<Guid?>("PlayerUserId")
|
b.Property<Guid?>("PlayerUserId")
|
||||||
.HasColumnType("TEXT")
|
.HasColumnType("TEXT")
|
||||||
.HasColumnName("player_user_id");
|
.HasColumnName("player_user_id");
|
||||||
@@ -315,6 +311,10 @@ namespace Content.Server.Database.Migrations.Sqlite
|
|||||||
.HasColumnType("INTEGER")
|
.HasColumnType("INTEGER")
|
||||||
.HasColumnName("secret");
|
.HasColumnName("secret");
|
||||||
|
|
||||||
|
b.Property<int>("Severity")
|
||||||
|
.HasColumnType("INTEGER")
|
||||||
|
.HasColumnName("severity");
|
||||||
|
|
||||||
b.HasKey("Id")
|
b.HasKey("Id")
|
||||||
.HasName("PK_admin_notes");
|
.HasName("PK_admin_notes");
|
||||||
|
|
||||||
@@ -1292,7 +1292,7 @@ namespace Content.Server.Database.Migrations.Sqlite
|
|||||||
.WithMany("AdminMessagesReceived")
|
.WithMany("AdminMessagesReceived")
|
||||||
.HasForeignKey("PlayerUserId")
|
.HasForeignKey("PlayerUserId")
|
||||||
.HasPrincipalKey("UserId")
|
.HasPrincipalKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.SetNull)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.HasConstraintName("FK_admin_messages_player_player_user_id");
|
.HasConstraintName("FK_admin_messages_player_player_user_id");
|
||||||
|
|
||||||
b.HasOne("Content.Server.Database.Round", "Round")
|
b.HasOne("Content.Server.Database.Round", "Round")
|
||||||
@@ -1338,7 +1338,7 @@ namespace Content.Server.Database.Migrations.Sqlite
|
|||||||
.WithMany("AdminNotesReceived")
|
.WithMany("AdminNotesReceived")
|
||||||
.HasForeignKey("PlayerUserId")
|
.HasForeignKey("PlayerUserId")
|
||||||
.HasPrincipalKey("UserId")
|
.HasPrincipalKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.SetNull)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.HasConstraintName("FK_admin_notes_player_player_user_id");
|
.HasConstraintName("FK_admin_notes_player_player_user_id");
|
||||||
|
|
||||||
b.HasOne("Content.Server.Database.Round", "Round")
|
b.HasOne("Content.Server.Database.Round", "Round")
|
||||||
@@ -1396,7 +1396,7 @@ namespace Content.Server.Database.Migrations.Sqlite
|
|||||||
.WithMany("AdminWatchlistsReceived")
|
.WithMany("AdminWatchlistsReceived")
|
||||||
.HasForeignKey("PlayerUserId")
|
.HasForeignKey("PlayerUserId")
|
||||||
.HasPrincipalKey("UserId")
|
.HasPrincipalKey("UserId")
|
||||||
.OnDelete(DeleteBehavior.SetNull)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.HasConstraintName("FK_admin_watchlists_player_player_user_id");
|
.HasConstraintName("FK_admin_watchlists_player_player_user_id");
|
||||||
|
|
||||||
b.HasOne("Content.Server.Database.Round", "Round")
|
b.HasOne("Content.Server.Database.Round", "Round")
|
||||||
|
|||||||
@@ -162,13 +162,15 @@ namespace Content.Server.Database
|
|||||||
modelBuilder.Entity<ConnectionLog>()
|
modelBuilder.Entity<ConnectionLog>()
|
||||||
.HasIndex(p => p.UserId);
|
.HasIndex(p => p.UserId);
|
||||||
|
|
||||||
// SetNull is necessary here so you can safely delete admins (GDPR right to erasure) while keeping the notes intact
|
// SetNull is necessary for created by/edited by-s here,
|
||||||
|
// so you can safely delete admins (GDPR right to erasure) while keeping the notes intact
|
||||||
|
|
||||||
modelBuilder.Entity<AdminNote>()
|
modelBuilder.Entity<AdminNote>()
|
||||||
.HasOne(note => note.Player)
|
.HasOne(note => note.Player)
|
||||||
.WithMany(player => player.AdminNotesReceived)
|
.WithMany(player => player.AdminNotesReceived)
|
||||||
.HasForeignKey(note => note.PlayerUserId)
|
.HasForeignKey(note => note.PlayerUserId)
|
||||||
.HasPrincipalKey(player => player.UserId)
|
.HasPrincipalKey(player => player.UserId)
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
modelBuilder.Entity<AdminNote>()
|
modelBuilder.Entity<AdminNote>()
|
||||||
.HasOne(version => version.CreatedBy)
|
.HasOne(version => version.CreatedBy)
|
||||||
@@ -196,7 +198,7 @@ namespace Content.Server.Database
|
|||||||
.WithMany(player => player.AdminWatchlistsReceived)
|
.WithMany(player => player.AdminWatchlistsReceived)
|
||||||
.HasForeignKey(note => note.PlayerUserId)
|
.HasForeignKey(note => note.PlayerUserId)
|
||||||
.HasPrincipalKey(player => player.UserId)
|
.HasPrincipalKey(player => player.UserId)
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
modelBuilder.Entity<AdminWatchlist>()
|
modelBuilder.Entity<AdminWatchlist>()
|
||||||
.HasOne(version => version.CreatedBy)
|
.HasOne(version => version.CreatedBy)
|
||||||
@@ -224,7 +226,7 @@ namespace Content.Server.Database
|
|||||||
.WithMany(player => player.AdminMessagesReceived)
|
.WithMany(player => player.AdminMessagesReceived)
|
||||||
.HasForeignKey(note => note.PlayerUserId)
|
.HasForeignKey(note => note.PlayerUserId)
|
||||||
.HasPrincipalKey(player => player.UserId)
|
.HasPrincipalKey(player => player.UserId)
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
modelBuilder.Entity<AdminMessage>()
|
modelBuilder.Entity<AdminMessage>()
|
||||||
.HasOne(version => version.CreatedBy)
|
.HasOne(version => version.CreatedBy)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import os
|
|||||||
import psycopg2
|
import psycopg2
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
LATEST_DB_MIGRATION = "20230402214647_BanAutoDelete"
|
LATEST_DB_MIGRATION = "20230725193102_AdminNotesImprovementsForeignKeys"
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
@@ -33,7 +33,9 @@ def main():
|
|||||||
|
|
||||||
dump_admin(cur, user_id, arg_output)
|
dump_admin(cur, user_id, arg_output)
|
||||||
dump_admin_log(cur, user_id, arg_output)
|
dump_admin_log(cur, user_id, arg_output)
|
||||||
|
dump_admin_messages(cur, user_id, arg_output)
|
||||||
dump_admin_notes(cur, user_id, arg_output)
|
dump_admin_notes(cur, user_id, arg_output)
|
||||||
|
dump_admin_watchlists(cur, user_id, arg_output)
|
||||||
dump_connection_log(cur, user_id, arg_output)
|
dump_connection_log(cur, user_id, arg_output)
|
||||||
dump_play_time(cur, user_id, arg_output)
|
dump_play_time(cur, user_id, arg_output)
|
||||||
dump_player(cur, user_id, arg_output)
|
dump_player(cur, user_id, arg_output)
|
||||||
@@ -291,7 +293,7 @@ FROM (
|
|||||||
FROM
|
FROM
|
||||||
server_ban
|
server_ban
|
||||||
WHERE
|
WHERE
|
||||||
user_id = %s
|
player_user_id = %s
|
||||||
) as data
|
) as data
|
||||||
""", (user_id,))
|
""", (user_id,))
|
||||||
|
|
||||||
@@ -339,7 +341,7 @@ FROM (
|
|||||||
FROM
|
FROM
|
||||||
server_role_ban
|
server_role_ban
|
||||||
WHERE
|
WHERE
|
||||||
user_id = %s
|
player_user_id = %s
|
||||||
) as data
|
) as data
|
||||||
""", (user_id,))
|
""", (user_id,))
|
||||||
|
|
||||||
@@ -393,6 +395,50 @@ FROM (
|
|||||||
f.write(json_data)
|
f.write(json_data)
|
||||||
|
|
||||||
|
|
||||||
|
def dump_admin_messages(cur: "psycopg2.cursor", user_id: str, outdir: str):
|
||||||
|
print("Dumping admin_messages...")
|
||||||
|
|
||||||
|
cur.execute("""
|
||||||
|
SELECT
|
||||||
|
COALESCE(json_agg(to_json(data)), '[]') #>> '{}'
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
admin_messages
|
||||||
|
WHERE
|
||||||
|
player_user_id = %s
|
||||||
|
) as data
|
||||||
|
""", (user_id,))
|
||||||
|
|
||||||
|
json_data = cur.fetchall()[0][0]
|
||||||
|
|
||||||
|
with open(os.path.join(outdir, "admin_messages.json"), "w", encoding="utf-8") as f:
|
||||||
|
f.write(json_data)
|
||||||
|
|
||||||
|
|
||||||
|
def dump_admin_watchlists(cur: "psycopg2.cursor", user_id: str, outdir: str):
|
||||||
|
print("Dumping admin_watchlists...")
|
||||||
|
|
||||||
|
cur.execute("""
|
||||||
|
SELECT
|
||||||
|
COALESCE(json_agg(to_json(data)), '[]') #>> '{}'
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
admin_watchlists
|
||||||
|
WHERE
|
||||||
|
player_user_id = %s
|
||||||
|
) as data
|
||||||
|
""", (user_id,))
|
||||||
|
|
||||||
|
json_data = cur.fetchall()[0][0]
|
||||||
|
|
||||||
|
with open(os.path.join(outdir, "admin_watchlists.json"), "w", encoding="utf-8") as f:
|
||||||
|
f.write(json_data)
|
||||||
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
# "I'm surprised you managed to write this entire Python file without spamming the word 'sus' everywhere." - Remie
|
# "I'm surprised you managed to write this entire Python file without spamming the word 'sus' everywhere." - Remie
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import os
|
|||||||
import psycopg2
|
import psycopg2
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
LATEST_DB_MIGRATION = "20230402214647_BanAutoDelete"
|
LATEST_DB_MIGRATION = "20230725193102_AdminNotesImprovementsForeignKeys"
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
|||||||
Reference in New Issue
Block a user