74 lines
2.9 KiB
C#
74 lines
2.9 KiB
C#
using System.Collections.Generic;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Commerce.Domain.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class MultiLanguageSupport : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterDatabase()
|
|
.OldAnnotation("Npgsql:PostgresExtension:hstore", ",,");
|
|
|
|
// Use Sql for all column type changes to include the USING clause
|
|
migrationBuilder.Sql("ALTER TABLE \"Products\" ALTER COLUMN \"TechnicalDetails\" TYPE jsonb USING \"TechnicalDetails\"::jsonb;");
|
|
migrationBuilder.Sql("ALTER TABLE \"Products\" ALTER COLUMN \"Name\" TYPE jsonb USING jsonb_build_object('en', \"Name\");");
|
|
migrationBuilder.Sql("ALTER TABLE \"Products\" ALTER COLUMN \"Description\" TYPE jsonb USING jsonb_build_object('en', \"Description\");");
|
|
|
|
migrationBuilder.Sql("ALTER TABLE \"Categories\" ALTER COLUMN \"Name\" TYPE jsonb USING jsonb_build_object('en', \"Name\");");
|
|
migrationBuilder.Sql("ALTER TABLE \"Categories\" ALTER COLUMN \"Description\" TYPE jsonb USING jsonb_build_object('en', \"Description\");");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterDatabase()
|
|
.Annotation("Npgsql:PostgresExtension:hstore", ",,");
|
|
|
|
migrationBuilder.AlterColumn<Dictionary<string, string>>(
|
|
name: "TechnicalDetails",
|
|
table: "Products",
|
|
type: "hstore",
|
|
nullable: false,
|
|
oldClrType: typeof(Dictionary<string, string>),
|
|
oldType: "jsonb");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Name",
|
|
table: "Products",
|
|
type: "text",
|
|
nullable: false,
|
|
oldClrType: typeof(Dictionary<string, string>),
|
|
oldType: "jsonb");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Description",
|
|
table: "Products",
|
|
type: "text",
|
|
nullable: false,
|
|
oldClrType: typeof(Dictionary<string, string>),
|
|
oldType: "jsonb");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Name",
|
|
table: "Categories",
|
|
type: "text",
|
|
nullable: false,
|
|
oldClrType: typeof(Dictionary<string, string>),
|
|
oldType: "jsonb");
|
|
|
|
migrationBuilder.AlterColumn<string>(
|
|
name: "Description",
|
|
table: "Categories",
|
|
type: "text",
|
|
nullable: false,
|
|
oldClrType: typeof(Dictionary<string, string>),
|
|
oldType: "jsonb");
|
|
}
|
|
}
|
|
}
|