using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Svrnty.Sample.Data.Migrations
{
///
public partial class InitialCreate : Migration
{
///
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.EnsureSchema(
name: "agent");
migrationBuilder.CreateTable(
name: "conversations",
schema: "agent",
columns: table => new
{
id = table.Column(type: "uuid", nullable: false),
messages = table.Column(type: "jsonb", nullable: false, defaultValue: "[]"),
created_at = table.Column(type: "timestamp with time zone", nullable: false),
updated_at = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_conversations", x => x.id);
});
migrationBuilder.CreateTable(
name: "customers",
schema: "agent",
columns: table => new
{
id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
name = table.Column(type: "character varying(200)", maxLength: 200, nullable: false),
email = table.Column(type: "character varying(200)", maxLength: 200, nullable: true),
state = table.Column(type: "character varying(100)", maxLength: 100, nullable: true),
tier = table.Column(type: "character varying(50)", maxLength: 50, nullable: true),
created_at = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_customers", x => x.id);
});
migrationBuilder.CreateTable(
name: "revenue",
schema: "agent",
columns: table => new
{
id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
month = table.Column(type: "character varying(50)", maxLength: 50, nullable: false),
amount = table.Column(type: "numeric(18,2)", precision: 18, scale: 2, nullable: false),
year = table.Column(type: "integer", nullable: false),
created_at = table.Column(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_revenue", x => x.id);
});
migrationBuilder.CreateIndex(
name: "idx_conversations_created",
schema: "agent",
table: "conversations",
column: "created_at");
migrationBuilder.CreateIndex(
name: "idx_conversations_updated",
schema: "agent",
table: "conversations",
column: "updated_at");
migrationBuilder.CreateIndex(
name: "idx_customers_state",
schema: "agent",
table: "customers",
column: "state");
migrationBuilder.CreateIndex(
name: "idx_customers_state_tier",
schema: "agent",
table: "customers",
columns: new[] { "state", "tier" });
migrationBuilder.CreateIndex(
name: "idx_customers_tier",
schema: "agent",
table: "customers",
column: "tier");
migrationBuilder.CreateIndex(
name: "idx_revenue_month",
schema: "agent",
table: "revenue",
columns: new[] { "month", "year" },
unique: true);
}
///
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "conversations",
schema: "agent");
migrationBuilder.DropTable(
name: "customers",
schema: "agent");
migrationBuilder.DropTable(
name: "revenue",
schema: "agent");
}
}
}