using System.Collections.Generic; using Microsoft.EntityFrameworkCore.Migrations; #nullable disable namespace Commerce.Domain.Migrations { /// public partial class MultiLanguageSupport : Migration { /// 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\");"); } /// protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.AlterDatabase() .Annotation("Npgsql:PostgresExtension:hstore", ",,"); migrationBuilder.AlterColumn>( name: "TechnicalDetails", table: "Products", type: "hstore", nullable: false, oldClrType: typeof(Dictionary), oldType: "jsonb"); migrationBuilder.AlterColumn( name: "Name", table: "Products", type: "text", nullable: false, oldClrType: typeof(Dictionary), oldType: "jsonb"); migrationBuilder.AlterColumn( name: "Description", table: "Products", type: "text", nullable: false, oldClrType: typeof(Dictionary), oldType: "jsonb"); migrationBuilder.AlterColumn( name: "Name", table: "Categories", type: "text", nullable: false, oldClrType: typeof(Dictionary), oldType: "jsonb"); migrationBuilder.AlterColumn( name: "Description", table: "Categories", type: "text", nullable: false, oldClrType: typeof(Dictionary), oldType: "jsonb"); } } }