2022-05-13 06:49:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
|
|
|
|
|
|
#nullable disable
|
|
|
|
|
|
|
|
|
|
namespace RegexBot.Data.Migrations
|
|
|
|
|
{
|
2022-06-10 23:09:18 +00:00
|
|
|
|
public partial class InitialMigration : Migration
|
2022-05-13 06:49:55 +00:00
|
|
|
|
{
|
|
|
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.CreateTable(
|
2022-07-21 03:37:31 +00:00
|
|
|
|
name: "cache_users",
|
2022-05-13 06:49:55 +00:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
user_id = table.Column<long>(type: "bigint", nullable: false),
|
|
|
|
|
u_last_update_time = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
|
|
|
|
username = table.Column<string>(type: "text", nullable: false),
|
|
|
|
|
discriminator = table.Column<string>(type: "character(4)", fixedLength: true, maxLength: 4, nullable: false),
|
|
|
|
|
avatar_url = table.Column<string>(type: "text", nullable: true)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2022-07-21 03:37:31 +00:00
|
|
|
|
table.PrimaryKey("pk_cache_users", x => x.user_id);
|
2022-05-13 06:49:55 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
2022-07-21 03:37:31 +00:00
|
|
|
|
name: "cache_guildmessages",
|
2022-05-13 06:49:55 +00:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
message_id = table.Column<long>(type: "bigint", nullable: false),
|
|
|
|
|
author_id = table.Column<long>(type: "bigint", nullable: false),
|
|
|
|
|
guild_id = table.Column<long>(type: "bigint", nullable: false),
|
|
|
|
|
channel_id = table.Column<long>(type: "bigint", nullable: false),
|
|
|
|
|
created_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
|
|
|
|
edited_at = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: true),
|
|
|
|
|
attachment_names = table.Column<List<string>>(type: "text[]", nullable: false),
|
|
|
|
|
content = table.Column<string>(type: "text", nullable: false)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2022-07-21 03:37:31 +00:00
|
|
|
|
table.PrimaryKey("pk_cache_guildmessages", x => x.message_id);
|
2022-05-13 06:49:55 +00:00
|
|
|
|
table.ForeignKey(
|
2022-07-21 03:37:31 +00:00
|
|
|
|
name: "fk_cache_guildmessages_cache_users_author_id",
|
2022-05-13 06:49:55 +00:00
|
|
|
|
column: x => x.author_id,
|
2022-07-21 03:37:31 +00:00
|
|
|
|
principalTable: "cache_users",
|
2022-05-13 06:49:55 +00:00
|
|
|
|
principalColumn: "user_id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateTable(
|
2022-07-21 03:37:31 +00:00
|
|
|
|
name: "cache_usersinguild",
|
2022-05-13 06:49:55 +00:00
|
|
|
|
columns: table => new
|
|
|
|
|
{
|
|
|
|
|
user_id = table.Column<long>(type: "bigint", nullable: false),
|
|
|
|
|
guild_id = table.Column<long>(type: "bigint", nullable: false),
|
|
|
|
|
gu_last_update_time = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false),
|
2022-06-10 23:09:18 +00:00
|
|
|
|
first_seen_time = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
2022-05-13 06:49:55 +00:00
|
|
|
|
nickname = table.Column<string>(type: "text", nullable: true)
|
|
|
|
|
},
|
|
|
|
|
constraints: table =>
|
|
|
|
|
{
|
2022-07-21 03:37:31 +00:00
|
|
|
|
table.PrimaryKey("pk_cache_usersinguild", x => new { x.user_id, x.guild_id });
|
2022-05-13 06:49:55 +00:00
|
|
|
|
table.ForeignKey(
|
2022-07-21 03:37:31 +00:00
|
|
|
|
name: "fk_cache_usersinguild_cache_users_user_id",
|
2022-05-13 06:49:55 +00:00
|
|
|
|
column: x => x.user_id,
|
2022-07-21 03:37:31 +00:00
|
|
|
|
principalTable: "cache_users",
|
2022-05-13 06:49:55 +00:00
|
|
|
|
principalColumn: "user_id",
|
|
|
|
|
onDelete: ReferentialAction.Cascade);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
migrationBuilder.CreateIndex(
|
2022-07-21 03:37:31 +00:00
|
|
|
|
name: "ix_cache_guildmessages_author_id",
|
|
|
|
|
table: "cache_guildmessages",
|
2022-05-13 06:49:55 +00:00
|
|
|
|
column: "author_id");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
|
|
|
{
|
|
|
|
|
migrationBuilder.DropTable(
|
2022-07-21 03:37:31 +00:00
|
|
|
|
name: "cache_guildmessages");
|
2022-05-13 06:49:55 +00:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2022-07-21 03:37:31 +00:00
|
|
|
|
name: "cache_usersinguild");
|
2022-05-13 06:49:55 +00:00
|
|
|
|
|
|
|
|
|
migrationBuilder.DropTable(
|
2022-07-21 03:37:31 +00:00
|
|
|
|
name: "cache_users");
|
2022-05-13 06:49:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|