using System;
using System.Collections.Generic;
using DysonNetwork.Shared.Models;
using Microsoft.EntityFrameworkCore.Migrations;
using NodaTime;
#nullable disable
namespace DysonNetwork.Sphere.Migrations
{
///
public partial class MergeFediverseDataClass : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_posts_publishers_publisher_id",
table: "posts");
migrationBuilder.DropTable(
name: "fediverse_activities");
migrationBuilder.DropTable(
name: "fediverse_reactions");
migrationBuilder.DropTable(
name: "fediverse_contents");
migrationBuilder.RenameColumn(
name: "meta",
table: "posts",
newName: "metadata");
migrationBuilder.AlterColumn(
name: "publisher_id",
table: "posts",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddColumn(
name: "actor_id",
table: "posts",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn(
name: "boost_count",
table: "posts",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn(
name: "content_type",
table: "posts",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn(
name: "fediverse_type",
table: "posts",
type: "integer",
nullable: true);
migrationBuilder.AddColumn(
name: "fediverse_uri",
table: "posts",
type: "character varying(8192)",
maxLength: 8192,
nullable: true);
migrationBuilder.AddColumn(
name: "language",
table: "posts",
type: "character varying(2048)",
maxLength: 2048,
nullable: true);
migrationBuilder.AddColumn(
name: "like_count",
table: "posts",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn>(
name: "mentions",
table: "posts",
type: "jsonb",
nullable: true);
migrationBuilder.AddColumn(
name: "replies_count",
table: "posts",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AlterColumn(
name: "account_id",
table: "post_reactions",
type: "uuid",
nullable: true,
oldClrType: typeof(Guid),
oldType: "uuid");
migrationBuilder.AddColumn(
name: "actor_id",
table: "post_reactions",
type: "uuid",
nullable: true);
migrationBuilder.AddColumn(
name: "fediverse_uri",
table: "post_reactions",
type: "character varying(2048)",
maxLength: 2048,
nullable: true);
migrationBuilder.AddColumn(
name: "is_local",
table: "post_reactions",
type: "boolean",
nullable: false,
defaultValue: false);
migrationBuilder.CreateIndex(
name: "ix_posts_actor_id",
table: "posts",
column: "actor_id");
migrationBuilder.CreateIndex(
name: "ix_post_reactions_actor_id",
table: "post_reactions",
column: "actor_id");
migrationBuilder.AddForeignKey(
name: "fk_post_reactions_fediverse_actors_actor_id",
table: "post_reactions",
column: "actor_id",
principalTable: "fediverse_actors",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_posts_fediverse_actors_actor_id",
table: "posts",
column: "actor_id",
principalTable: "fediverse_actors",
principalColumn: "id");
migrationBuilder.AddForeignKey(
name: "fk_posts_publishers_publisher_id",
table: "posts",
column: "publisher_id",
principalTable: "publishers",
principalColumn: "id");
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "fk_post_reactions_fediverse_actors_actor_id",
table: "post_reactions");
migrationBuilder.DropForeignKey(
name: "fk_posts_fediverse_actors_actor_id",
table: "posts");
migrationBuilder.DropForeignKey(
name: "fk_posts_publishers_publisher_id",
table: "posts");
migrationBuilder.DropIndex(
name: "ix_posts_actor_id",
table: "posts");
migrationBuilder.DropIndex(
name: "ix_post_reactions_actor_id",
table: "post_reactions");
migrationBuilder.DropColumn(
name: "actor_id",
table: "posts");
migrationBuilder.DropColumn(
name: "boost_count",
table: "posts");
migrationBuilder.DropColumn(
name: "content_type",
table: "posts");
migrationBuilder.DropColumn(
name: "fediverse_type",
table: "posts");
migrationBuilder.DropColumn(
name: "fediverse_uri",
table: "posts");
migrationBuilder.DropColumn(
name: "language",
table: "posts");
migrationBuilder.DropColumn(
name: "like_count",
table: "posts");
migrationBuilder.DropColumn(
name: "mentions",
table: "posts");
migrationBuilder.DropColumn(
name: "replies_count",
table: "posts");
migrationBuilder.DropColumn(
name: "actor_id",
table: "post_reactions");
migrationBuilder.DropColumn(
name: "fediverse_uri",
table: "post_reactions");
migrationBuilder.DropColumn(
name: "is_local",
table: "post_reactions");
migrationBuilder.RenameColumn(
name: "metadata",
table: "posts",
newName: "meta");
migrationBuilder.AlterColumn(
name: "publisher_id",
table: "posts",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.AlterColumn(
name: "account_id",
table: "post_reactions",
type: "uuid",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
oldClrType: typeof(Guid),
oldType: "uuid",
oldNullable: true);
migrationBuilder.CreateTable(
name: "fediverse_contents",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false),
actor_id = table.Column(type: "uuid", nullable: false),
instance_id = table.Column(type: "uuid", nullable: false),
announced_content_uri = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
boost_count = table.Column(type: "integer", nullable: false),
content = table.Column(type: "text", nullable: true),
content_html = table.Column(type: "text", nullable: true),
created_at = table.Column(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column(type: "timestamp with time zone", nullable: true),
edited_at = table.Column(type: "timestamp with time zone", nullable: true),
in_reply_to = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
is_sensitive = table.Column(type: "boolean", nullable: false),
language = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
like_count = table.Column(type: "integer", nullable: false),
local_post_id = table.Column(type: "uuid", nullable: true),
metadata = table.Column>(type: "jsonb", nullable: true),
published_at = table.Column(type: "timestamp with time zone", nullable: true),
reply_count = table.Column(type: "integer", nullable: false),
summary = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true),
title = table.Column(type: "character varying(1024)", maxLength: 1024, nullable: true),
type = table.Column(type: "integer", nullable: false),
updated_at = table.Column(type: "timestamp with time zone", nullable: false),
uri = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_fediverse_contents", x => x.id);
table.ForeignKey(
name: "fk_fediverse_contents_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_contents_fediverse_instances_instance_id",
column: x => x.instance_id,
principalTable: "fediverse_instances",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "fediverse_activities",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false),
actor_id = table.Column(type: "uuid", nullable: false),
content_id = table.Column(type: "uuid", nullable: true),
target_actor_id = table.Column(type: "uuid", nullable: true),
created_at = table.Column(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column(type: "timestamp with time zone", nullable: true),
error_message = table.Column(type: "character varying(4096)", maxLength: 4096, nullable: true),
is_local = table.Column(type: "boolean", nullable: false),
local_account_id = table.Column(type: "uuid", nullable: true),
local_post_id = table.Column(type: "uuid", nullable: true),
object_uri = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
published_at = table.Column(type: "timestamp with time zone", nullable: true),
raw_data = table.Column>(type: "jsonb", nullable: true),
status = table.Column(type: "integer", nullable: false),
target_uri = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: true),
type = table.Column(type: "integer", nullable: false),
updated_at = table.Column(type: "timestamp with time zone", nullable: false),
uri = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_fediverse_activities", x => x.id);
table.ForeignKey(
name: "fk_fediverse_activities_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_activities_fediverse_actors_target_actor_id",
column: x => x.target_actor_id,
principalTable: "fediverse_actors",
principalColumn: "id");
table.ForeignKey(
name: "fk_fediverse_activities_fediverse_contents_content_id",
column: x => x.content_id,
principalTable: "fediverse_contents",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "fediverse_reactions",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false),
actor_id = table.Column(type: "uuid", nullable: false),
content_id = table.Column(type: "uuid", nullable: false),
created_at = table.Column(type: "timestamp with time zone", nullable: false),
deleted_at = table.Column(type: "timestamp with time zone", nullable: true),
emoji = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
is_local = table.Column(type: "boolean", nullable: false),
local_account_id = table.Column(type: "uuid", nullable: true),
local_reaction_id = table.Column(type: "uuid", nullable: true),
type = table.Column(type: "integer", nullable: false),
updated_at = table.Column(type: "timestamp with time zone", nullable: false),
uri = table.Column(type: "character varying(2048)", maxLength: 2048, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("pk_fediverse_reactions", x => x.id);
table.ForeignKey(
name: "fk_fediverse_reactions_fediverse_actors_actor_id",
column: x => x.actor_id,
principalTable: "fediverse_actors",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "fk_fediverse_reactions_fediverse_contents_content_id",
column: x => x.content_id,
principalTable: "fediverse_contents",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "ix_fediverse_activities_actor_id",
table: "fediverse_activities",
column: "actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_activities_content_id",
table: "fediverse_activities",
column: "content_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_activities_target_actor_id",
table: "fediverse_activities",
column: "target_actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_contents_actor_id",
table: "fediverse_contents",
column: "actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_contents_instance_id",
table: "fediverse_contents",
column: "instance_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_contents_uri",
table: "fediverse_contents",
column: "uri",
unique: true);
migrationBuilder.CreateIndex(
name: "ix_fediverse_reactions_actor_id",
table: "fediverse_reactions",
column: "actor_id");
migrationBuilder.CreateIndex(
name: "ix_fediverse_reactions_content_id",
table: "fediverse_reactions",
column: "content_id");
migrationBuilder.AddForeignKey(
name: "fk_posts_publishers_publisher_id",
table: "posts",
column: "publisher_id",
principalTable: "publishers",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
}
}
}