52 lines
1.6 KiB
C#
52 lines
1.6 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace DatabaseImplement.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddCategories : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Category",
|
|
table: "Products",
|
|
type: "text",
|
|
nullable: false,
|
|
oldClrType: typeof(int),
|
|
oldType: "integer");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "Categories",
|
|
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_Categories", x => x.Id);
|
|
});
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Categories");
|
|
|
|
migrationBuilder.AlterColumn<int>(
|
|
name: "Category",
|
|
table: "Products",
|
|
type: "integer",
|
|
nullable: false,
|
|
oldClrType: typeof(string),
|
|
oldType: "text");
|
|
}
|
|
}
|
|
}
|