using Microsoft.EntityFrameworkCore.Migrations;

using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;

#nullable disable

namespace GeoRitmMover.Mover.Data.Migrations;

/// <inheritdoc />
public partial class Initialize : Migration
{
	/// <inheritdoc />
	protected override void Up(MigrationBuilder migrationBuilder)
	{
		_ = migrationBuilder.CreateTable(
			name: "Assets",
			columns: table => new
			{
				Id = table.Column<Guid>(type: "uuid", nullable: false),
				From = table.Column<long>(type: "bigint", nullable: false),
				To = table.Column<Guid>(type: "uuid", nullable: false)
			},
			constraints: table =>
			{
				_ = table.PrimaryKey("PK_Assets", x => x.Id);
			});

		_ = migrationBuilder.CreateTable(
			name: "Counters",
			columns: table => new
			{
				Id = table.Column<Guid>(type: "uuid", nullable: false),
				Name = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false)
			},
			constraints: table =>
			{
				_ = table.PrimaryKey("PK_Counters", x => x.Id);
			});

		_ = migrationBuilder.CreateTable(
			name: "Groups",
			columns: table => new
			{
				Id = table.Column<Guid>(type: "uuid", nullable: false),
				From = table.Column<long>(type: "bigint", nullable: false),
				To = table.Column<Guid>(type: "uuid", nullable: false)
			},
			constraints: table =>
			{
				_ = table.PrimaryKey("PK_Groups", x => x.Id);
			});

		_ = migrationBuilder.CreateTable(
			name: "object_groups",
			columns: table => new
			{
				id = table.Column<int>(type: "integer", nullable: false)
					.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
				name = table.Column<string>(type: "text", nullable: false)
			},
			constraints: table =>
			{
				_ = table.PrimaryKey("PK_object_groups", x => x.id);
			});

		_ = migrationBuilder.CreateIndex(
			name: "IX_Assets_From",
			table: "Assets",
			column: "From",
			unique: true);

		_ = migrationBuilder.CreateIndex(
			name: "IX_Assets_To",
			table: "Assets",
			column: "To",
			unique: true);

		_ = migrationBuilder.CreateIndex(
			name: "IX_Counters_Name",
			table: "Counters",
			column: "Name",
			unique: true);

		_ = migrationBuilder.CreateIndex(
			name: "IX_Groups_From",
			table: "Groups",
			column: "From",
			unique: true);

		_ = migrationBuilder.CreateIndex(
			name: "IX_Groups_To",
			table: "Groups",
			column: "To",
			unique: true);
	}

	/// <inheritdoc />
	protected override void Down(MigrationBuilder migrationBuilder)
	{
		_ = migrationBuilder.DropTable(
			name: "Assets");

		_ = migrationBuilder.DropTable(
			name: "Counters");

		_ = migrationBuilder.DropTable(
			name: "Groups");

		_ = migrationBuilder.DropTable(
			name: "object_groups");
	}
}
