public void Up(MigrationBuilder migrationBuilder)
        {
            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_4_5", "Fixed", "6ServiceMunicipality.sql"));

            migrationBuilder.DropForeignKey(
                name: "FK_Service_ServiceCoverageType_ServiceCoverageTypeId",
                schema: "public",
                table: "ServiceVersioned");

            migrationBuilder.DropTable(
                name: "ServiceCoverageTypeName",
                schema: "public");

            migrationBuilder.DropTable(
                name: "ServiceMunicipality",
                schema: "public");

            migrationBuilder.DropTable(
                name: "ServiceCoverageType",
                schema: "public");

            migrationBuilder.DropIndex(
                name: "IX_Ser_ServiceCoverageTypeId",
                schema: "public",
                table: "ServiceVersioned");

            migrationBuilder.DropColumn(
                name: "ServiceCoverageTypeId",
                schema: "public",
                table: "ServiceVersioned");
        }
Beispiel #2
0
        public void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn <Guid>(
                name: "OrganizationId",
                schema: "public",
                table: "ServiceVersioned",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.CreateIndex(
                name: "IX_SerVer_OrganizationId",
                schema: "public",
                table: "ServiceVersioned",
                column: "OrganizationId");

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_6", "2ServiceResponsibleOrganization.sql"));

            migrationBuilder.AddForeignKey(
                name: "FK_ServiceVersioned_Organization_OrganizationId",
                schema: "public",
                table: "ServiceVersioned",
                column: "OrganizationId",
                principalSchema: "public",
                principalTable: "Organization",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
        public void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "PostOfficeBoxName",
                schema: "public",
                columns: table => new
            {
                Id             = table.Column <Guid>(nullable: false),
                AddressId      = table.Column <Guid>(nullable: false),
                Created        = table.Column <DateTime>(nullable: false),
                CreatedBy      = table.Column <string>(nullable: true),
                LocalizationId = table.Column <Guid>(nullable: false),
                Modified       = table.Column <DateTime>(nullable: false),
                ModifiedBy     = table.Column <string>(nullable: true),
                Text           = table.Column <string>(maxLength: 100, nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_PostOfficeBoxName", x => x.Id);
                table.ForeignKey(
                    name: "FK_PostOfficeBoxName_Address_AddressId",
                    column: x => x.AddressId,
                    principalSchema: "public",
                    principalTable: "Address",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_PostOfficeBoxName_Language_LocalizationId",
                    column: x => x.LocalizationId,
                    principalSchema: "public",
                    principalTable: "Language",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_PosOffBoxNam_AddressId",
                schema: "public",
                table: "PostOfficeBoxName",
                column: "AddressId");

            migrationBuilder.CreateIndex(
                name: "IX_PosOffBoxNam_Id",
                schema: "public",
                table: "PostOfficeBoxName",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_PosOffBoxNam_LocalizationId",
                schema: "public",
                table: "PostOfficeBoxName",
                column: "LocalizationId");

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_4_5", "Fixed", "1PostOfficeBoxName.sql"));

            migrationBuilder.DropColumn(
                name: "PostOfficeBox",
                schema: "public",
                table: "Address");
        }
        public void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn <int>(
                name: "OrderNumber",
                schema: "public",
                table: "ServiceChannelServiceHours",
                nullable: true);

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_5", "4ServiceHoursOrder.sql"));
        }
Beispiel #5
0
        public void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.Sql(@"DELETE FROM ""UserOrganization"" WHERE (""OrganizationId"" IS NULL) OR (""OrganizationId"" = '00000000-0000-0000-0000-000000000000') OR (""OrganizationId"" NOT IN (SELECT ""Id"" FROM ""Organization""))");

            migrationBuilder.DropForeignKey(
                name: "FK_UserOrganization_Organization_OrganizationId",
                schema: "public",
                table: "UserOrganization");

            migrationBuilder.DropColumn(
                name: "RelationId",
                schema: "public",
                table: "UserOrganization");

            migrationBuilder.DropColumn(
                name: "UserName",
                schema: "public",
                table: "UserOrganization");

            migrationBuilder.AlterColumn <Guid>(
                name: "OrganizationId",
                schema: "public",
                table: "UserOrganization",
                nullable: false,
                oldClrType: typeof(Guid),
                oldNullable: true);

            migrationBuilder.AddColumn <bool>(
                name: "IsMain",
                schema: "public",
                table: "UserOrganization",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn <Guid>(
                name: "RoleId",
                schema: "public",
                table: "UserOrganization",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.AddForeignKey(
                name: "FK_UserOrganization_Organization_OrganizationId",
                schema: "public",
                table: "UserOrganization",
                column: "OrganizationId",
                principalSchema: "public",
                principalTable: "Organization",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_5_5", "FK_ServiceServiceChannel.sql"));
        }
        public void Up(MigrationBuilder migrationBuilder)
        {
            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_4_5", "Fixed", "7ServiceLocationChannelServiceAreas.sql"));

            migrationBuilder.DropTable(
                name: "ServiceLocationChannelServiceArea",
                schema: "public");

            migrationBuilder.DropColumn(
                name: "ServiceAreaRestricted",
                schema: "public",
                table: "ServiceLocationChannel");
        }
        public void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ServiceWebPage",
                schema: "public",
                columns: table => new
            {
                ServiceVersionedId = table.Column <Guid>(nullable: false),
                WebPageId          = table.Column <Guid>(nullable: false),
                Created            = table.Column <DateTime>(nullable: false),
                CreatedBy          = table.Column <string>(nullable: true),
                Modified           = table.Column <DateTime>(nullable: false),
                ModifiedBy         = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceWebPage", x => new { x.ServiceVersionedId, x.WebPageId });
                table.ForeignKey(
                    name: "FK_ServiceWebPage_ServiceVersioned_ServiceVersionedId",
                    column: x => x.ServiceVersionedId,
                    principalSchema: "public",
                    principalTable: "ServiceVersioned",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_ServiceWebPage_WebPage_WebPageId",
                    column: x => x.WebPageId,
                    principalSchema: "public",
                    principalTable: "WebPage",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_5", "3ServiceVoucher.sql"));

            migrationBuilder.CreateIndex(
                name: "IX_ServiceWebPage_ServiceVersionedId",
                schema: "public",
                table: "ServiceWebPage",
                column: "ServiceVersionedId");

            migrationBuilder.CreateIndex(
                name: "IX_ServiceWebPage_WebPageId",
                schema: "public",
                table: "ServiceWebPage",
                column: "WebPageId");
        }
        public void Up(MigrationBuilder migrationBuilder)
        {
            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_5", "1ServiceServiceChannelChanges.sql"));

            migrationBuilder.CreateIndex(
                name: "IX_ServiceServiceChannel_ServiceId",
                schema: "public",
                table: "ServiceServiceChannel",
                column: "ServiceId");

            migrationBuilder.AddForeignKey(
                name: "FK_ServiceServiceChannel_Service_ServiceId",
                schema: "public",
                table: "ServiceServiceChannel",
                column: "ServiceId",
                principalSchema: "public",
                principalTable: "Service",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
Beispiel #9
0
        public void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropPrimaryKey(
                name: "PK_DailyOpeningTime",
                schema: "public",
                table: "DailyOpeningTime");

            migrationBuilder.DropIndex(
                name: "IX_DaiOpeTim_OpeningHourId_DayFrom_IsExtra",
                schema: "public",
                table: "DailyOpeningTime");

            migrationBuilder.AddColumn <int>(
                name: "Order",
                schema: "public",
                table: "DailyOpeningTime",
                nullable: false,
                defaultValue: 0);

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_7", "3OpenningHoursPKchange.sql"));

            migrationBuilder.DropColumn(
                name: "IsExtra",
                schema: "public",
                table: "DailyOpeningTime");

            migrationBuilder.AddPrimaryKey(
                name: "PK_DailyOpeningTime",
                schema: "public",
                table: "DailyOpeningTime",
                columns: new[] { "OpeningHourId", "DayFrom", "Order" });

            migrationBuilder.CreateIndex(
                name: "IX_DaiOpeTim_OpeningHourId_DayFrom_Order",
                schema: "public",
                table: "DailyOpeningTime",
                columns: new[] { "OpeningHourId", "DayFrom", "Order" });
        }
Beispiel #10
0
 public void Up(MigrationBuilder migrationBuilder)
 {
     dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_5", "5KeywordMaxLengthRule.sql"));
 }
Beispiel #11
0
        public void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "ServiceHours",
                schema: "public",
                columns: table => new
            {
                Id                = table.Column <Guid>(nullable: false),
                Created           = table.Column <DateTime>(nullable: false),
                CreatedBy         = table.Column <string>(nullable: true),
                IsClosed          = table.Column <bool>(nullable: false),
                LastOperationId   = table.Column <string>(nullable: true),
                Modified          = table.Column <DateTime>(nullable: false),
                ModifiedBy        = table.Column <string>(nullable: true),
                OpeningHoursFrom  = table.Column <DateTime>(nullable: true),
                OpeningHoursTo    = table.Column <DateTime>(nullable: true),
                OrderNumber       = table.Column <int>(nullable: true),
                ServiceHourTypeId = table.Column <Guid>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceHours", x => x.Id);
                table.ForeignKey(
                    name: "FK_ServiceHours_ServiceHourType_ServiceHourTypeId",
                    column: x => x.ServiceHourTypeId,
                    principalSchema: "public",
                    principalTable: "ServiceHourType",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_7", "2ServiceHours.sql"));

            migrationBuilder.DropForeignKey(
                name: "FK_DailyOpeningTime_ServiceChannelServiceHours_OpeningHourId",
                schema: "public",
                table: "DailyOpeningTime");

            migrationBuilder.DropForeignKey(
                name: "FK_ServiceChannelServiceHours_ServiceHourType_ServiceHourTypeId",
                schema: "public",
                table: "ServiceChannelServiceHours");

            migrationBuilder.DropForeignKey(
                name: "FK_ServiceHoursAdditionalInformation_ServiceChannelServiceHours_ServiceChannelServiceHoursId",
                schema: "public",
                table: "ServiceHoursAdditionalInformation");

            migrationBuilder.DropPrimaryKey(
                name: "PK_ServiceChannelServiceHours",
                schema: "public",
                table: "ServiceChannelServiceHours");

            migrationBuilder.DropIndex(
                name: "IX_SerChaSerHou_Id",
                schema: "public",
                table: "ServiceChannelServiceHours");

            migrationBuilder.DropColumn(
                name: "ServiceHourTypeId",
                schema: "public",
                table: "ServiceChannelServiceHours");

            migrationBuilder.DropColumn(
                name: "IsClosed",
                schema: "public",
                table: "ServiceChannelServiceHours");

            migrationBuilder.DropColumn(
                name: "OpeningHoursFrom",
                schema: "public",
                table: "ServiceChannelServiceHours");

            migrationBuilder.DropColumn(
                name: "OpeningHoursTo",
                schema: "public",
                table: "ServiceChannelServiceHours");

            migrationBuilder.DropColumn(
                name: "OrderNumber",
                schema: "public",
                table: "ServiceChannelServiceHours");

            migrationBuilder.RenameColumn(
                name: "ServiceChannelServiceHoursId",
                schema: "public",
                table: "ServiceHoursAdditionalInformation",
                newName: "ServiceHoursId");

            migrationBuilder.RenameIndex(
                name: "IX_SerHouAddInf_ServiceChannelServiceHoursId",
                schema: "public",
                table: "ServiceHoursAdditionalInformation",
                newName: "IX_SerHouAddInf_ServiceHoursId");

            migrationBuilder.RenameColumn(
                name: "Id",
                schema: "public",
                table: "ServiceChannelServiceHours",
                newName: "ServiceHoursId");

            migrationBuilder.AddPrimaryKey(
                name: "PK_ServiceChannelServiceHours",
                schema: "public",
                table: "ServiceChannelServiceHours",
                columns: new[] { "ServiceChannelVersionedId", "ServiceHoursId" });

            migrationBuilder.CreateTable(
                name: "ServiceServiceChannelAddress",
                schema: "public",
                columns: table => new
            {
                ServiceId        = table.Column <Guid>(nullable: false),
                ServiceChannelId = table.Column <Guid>(nullable: false),
                AddressId        = table.Column <Guid>(nullable: false),
                CharacterId      = table.Column <Guid>(nullable: false),
                Created          = table.Column <DateTime>(nullable: false),
                CreatedBy        = table.Column <string>(nullable: true),
                LastOperationId  = table.Column <string>(nullable: true),
                Modified         = table.Column <DateTime>(nullable: false),
                ModifiedBy       = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceServiceChannelAddress", x => new { x.ServiceId, x.ServiceChannelId, x.AddressId });
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelAddress_Address_AddressId",
                    column: x => x.AddressId,
                    principalSchema: "public",
                    principalTable: "Address",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelAddress_AddressCharacter_CharacterId",
                    column: x => x.CharacterId,
                    principalSchema: "public",
                    principalTable: "AddressCharacter",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelAddress_ServiceChannel_ServiceChannelId",
                    column: x => x.ServiceChannelId,
                    principalSchema: "public",
                    principalTable: "ServiceChannel",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelAddress_Service_ServiceId",
                    column: x => x.ServiceId,
                    principalSchema: "public",
                    principalTable: "Service",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ServiceServiceChannelEmail",
                schema: "public",
                columns: table => new
            {
                ServiceId        = table.Column <Guid>(nullable: false),
                ServiceChannelId = table.Column <Guid>(nullable: false),
                EmailId          = table.Column <Guid>(nullable: false),
                Created          = table.Column <DateTime>(nullable: false),
                CreatedBy        = table.Column <string>(nullable: true),
                LastOperationId  = table.Column <string>(nullable: true),
                Modified         = table.Column <DateTime>(nullable: false),
                ModifiedBy       = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceServiceChannelEmail", x => new { x.ServiceId, x.ServiceChannelId, x.EmailId });
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelEmail_Email_EmailId",
                    column: x => x.EmailId,
                    principalSchema: "public",
                    principalTable: "Email",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelEmail_ServiceChannel_ServiceChannelId",
                    column: x => x.ServiceChannelId,
                    principalSchema: "public",
                    principalTable: "ServiceChannel",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelEmail_Service_ServiceId",
                    column: x => x.ServiceId,
                    principalSchema: "public",
                    principalTable: "Service",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ServiceServiceChannelPhone",
                schema: "public",
                columns: table => new
            {
                ServiceId        = table.Column <Guid>(nullable: false),
                ServiceChannelId = table.Column <Guid>(nullable: false),
                PhoneId          = table.Column <Guid>(nullable: false),
                Created          = table.Column <DateTime>(nullable: false),
                CreatedBy        = table.Column <string>(nullable: true),
                LastOperationId  = table.Column <string>(nullable: true),
                Modified         = table.Column <DateTime>(nullable: false),
                ModifiedBy       = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceServiceChannelPhone", x => new { x.ServiceId, x.ServiceChannelId, x.PhoneId });
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelPhone_Phone_PhoneId",
                    column: x => x.PhoneId,
                    principalSchema: "public",
                    principalTable: "Phone",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelPhone_ServiceChannel_ServiceChannelId",
                    column: x => x.ServiceChannelId,
                    principalSchema: "public",
                    principalTable: "ServiceChannel",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelPhone_Service_ServiceId",
                    column: x => x.ServiceId,
                    principalSchema: "public",
                    principalTable: "Service",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ServiceServiceChannelWebPage",
                schema: "public",
                columns: table => new
            {
                ServiceId        = table.Column <Guid>(nullable: false),
                ServiceChannelId = table.Column <Guid>(nullable: false),
                WebPageId        = table.Column <Guid>(nullable: false),
                Created          = table.Column <DateTime>(nullable: false),
                CreatedBy        = table.Column <string>(nullable: true),
                LastOperationId  = table.Column <string>(nullable: true),
                Modified         = table.Column <DateTime>(nullable: false),
                ModifiedBy       = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceServiceChannelWebPage", x => new { x.ServiceId, x.ServiceChannelId, x.WebPageId });
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelWebPage_ServiceChannel_ServiceChannelId",
                    column: x => x.ServiceChannelId,
                    principalSchema: "public",
                    principalTable: "ServiceChannel",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelWebPage_Service_ServiceId",
                    column: x => x.ServiceId,
                    principalSchema: "public",
                    principalTable: "Service",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelWebPage_WebPage_WebPageId",
                    column: x => x.WebPageId,
                    principalSchema: "public",
                    principalTable: "WebPage",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ServiceServiceChannelServiceHours",
                schema: "public",
                columns: table => new
            {
                ServiceId        = table.Column <Guid>(nullable: false),
                ServiceChannelId = table.Column <Guid>(nullable: false),
                ServiceHoursId   = table.Column <Guid>(nullable: false),
                Created          = table.Column <DateTime>(nullable: false),
                CreatedBy        = table.Column <string>(nullable: true),
                LastOperationId  = table.Column <string>(nullable: true),
                Modified         = table.Column <DateTime>(nullable: false),
                ModifiedBy       = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceServiceChannelServiceHours", x => new { x.ServiceId, x.ServiceChannelId, x.ServiceHoursId });
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelServiceHours_ServiceChannel_ServiceChannelId",
                    column: x => x.ServiceChannelId,
                    principalSchema: "public",
                    principalTable: "ServiceChannel",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelServiceHours_ServiceHours_ServiceHoursId",
                    column: x => x.ServiceHoursId,
                    principalSchema: "public",
                    principalTable: "ServiceHours",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceServiceChannelServiceHours_Service_ServiceId",
                    column: x => x.ServiceId,
                    principalSchema: "public",
                    principalTable: "Service",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_SerHou_Id",
                schema: "public",
                table: "ServiceHours",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_SerHou_ServiceHourTypeId",
                schema: "public",
                table: "ServiceHours",
                column: "ServiceHourTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaAdd_AddressId",
                schema: "public",
                table: "ServiceServiceChannelAddress",
                column: "AddressId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaAdd_CharacterId",
                schema: "public",
                table: "ServiceServiceChannelAddress",
                column: "CharacterId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaAdd_ServiceChannelId",
                schema: "public",
                table: "ServiceServiceChannelAddress",
                column: "ServiceChannelId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaAdd_ServiceId",
                schema: "public",
                table: "ServiceServiceChannelAddress",
                column: "ServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaEma_EmailId",
                schema: "public",
                table: "ServiceServiceChannelEmail",
                column: "EmailId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaEma_ServiceChannelId",
                schema: "public",
                table: "ServiceServiceChannelEmail",
                column: "ServiceChannelId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaEma_ServiceId",
                schema: "public",
                table: "ServiceServiceChannelEmail",
                column: "ServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaPho_PhoneId",
                schema: "public",
                table: "ServiceServiceChannelPhone",
                column: "PhoneId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaPho_ServiceChannelId",
                schema: "public",
                table: "ServiceServiceChannelPhone",
                column: "ServiceChannelId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaPho_ServiceId",
                schema: "public",
                table: "ServiceServiceChannelPhone",
                column: "ServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaSerHou_ServiceChannelId",
                schema: "public",
                table: "ServiceServiceChannelServiceHours",
                column: "ServiceChannelId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaSerHou_ServiceHoursId",
                schema: "public",
                table: "ServiceServiceChannelServiceHours",
                column: "ServiceHoursId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaSerHou_ServiceId",
                schema: "public",
                table: "ServiceServiceChannelServiceHours",
                column: "ServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaWebPag_ServiceChannelId",
                schema: "public",
                table: "ServiceServiceChannelWebPage",
                column: "ServiceChannelId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaWebPag_ServiceId",
                schema: "public",
                table: "ServiceServiceChannelWebPage",
                column: "ServiceId");

            migrationBuilder.CreateIndex(
                name: "IX_SerSerChaWebPag_WebPageId",
                schema: "public",
                table: "ServiceServiceChannelWebPage",
                column: "WebPageId");

            migrationBuilder.AddForeignKey(
                name: "FK_DailyOpeningTime_ServiceHours_OpeningHourId",
                schema: "public",
                table: "DailyOpeningTime",
                column: "OpeningHourId",
                principalSchema: "public",
                principalTable: "ServiceHours",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ServiceChannelServiceHours_ServiceHours_ServiceHoursId",
                schema: "public",
                table: "ServiceChannelServiceHours",
                column: "ServiceHoursId",
                principalSchema: "public",
                principalTable: "ServiceHours",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ServiceHoursAdditionalInformation_ServiceHours_ServiceHoursId",
                schema: "public",
                table: "ServiceHoursAdditionalInformation",
                column: "ServiceHoursId",
                principalSchema: "public",
                principalTable: "ServiceHours",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
Beispiel #12
0
 public void Up(MigrationBuilder migrationBuilder)
 {
     dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_6", "4QuartzInit.sql"));
 }
Beispiel #13
0
        public void Up(MigrationBuilder migrationBuilder)
        {
            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_4_5", "Fixed", "2AreaInformationType.sql"));

            migrationBuilder.CreateTable(
                name: "AreaInformationType",
                schema: "public",
                columns: table => new
            {
                Id          = table.Column <Guid>(nullable: false),
                Code        = table.Column <string>(nullable: true),
                Created     = table.Column <DateTime>(nullable: false),
                CreatedBy   = table.Column <string>(nullable: true),
                Modified    = table.Column <DateTime>(nullable: false),
                ModifiedBy  = table.Column <string>(nullable: true),
                OrderNumber = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AreaInformationType", x => x.Id);
            });

            migrationBuilder.AddColumn <Guid>(
                name: "AreaInformationTypeId",
                schema: "public",
                table: "OrganizationVersioned",
                nullable: false,
                defaultValueSql: @"GetOrCreateDefaultAreaInformationTypeId('WholeCountry')"
                );

            migrationBuilder.CreateTable(
                name: "AreaInformationTypeName",
                schema: "public",
                columns: table => new
            {
                Id             = table.Column <Guid>(nullable: false),
                Created        = table.Column <DateTime>(nullable: false),
                CreatedBy      = table.Column <string>(nullable: true),
                LocalizationId = table.Column <Guid>(nullable: false),
                Modified       = table.Column <DateTime>(nullable: false),
                ModifiedBy     = table.Column <string>(nullable: true),
                Name           = table.Column <string>(nullable: true),
                TypeId         = table.Column <Guid>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AreaInformationTypeName", x => x.Id);
                table.ForeignKey(
                    name: "FK_AreaInformationTypeName_Language_LocalizationId",
                    column: x => x.LocalizationId,
                    principalSchema: "public",
                    principalTable: "Language",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AreaInformationTypeName_AreaInformationType_TypeId",
                    column: x => x.TypeId,
                    principalSchema: "public",
                    principalTable: "AreaInformationType",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_OrgVer_AreaInformationTypeId",
                schema: "public",
                table: "OrganizationVersioned",
                column: "AreaInformationTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_AreInfTyp_Id",
                schema: "public",
                table: "AreaInformationType",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_AreInfTypNam_Id",
                schema: "public",
                table: "AreaInformationTypeName",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_AreInfTypNam_LocalizationId",
                schema: "public",
                table: "AreaInformationTypeName",
                column: "LocalizationId");

            migrationBuilder.CreateIndex(
                name: "IX_AreInfTypNam_TypeId",
                schema: "public",
                table: "AreaInformationTypeName",
                column: "TypeId");

            migrationBuilder.AddForeignKey(
                name: "FK_OrganizationVersioned_AreaInformationType_AreaInformationTypeId",
                schema: "public",
                table: "OrganizationVersioned",
                column: "AreaInformationTypeId",
                principalSchema: "public",
                principalTable: "AreaInformationType",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
Beispiel #14
0
 public void Up(MigrationBuilder migrationBuilder)
 {
     dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_7", "4UpdateDeliveryAddressNoAddress.sql"));
 }
Beispiel #15
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_OrganizationType_OrganizationType_ParentTypeId",
                schema: "public",
                table: "OrganizationType");

            migrationBuilder.DropForeignKey(
                name: "FK_OrganizationTypeName_OrganizationType_TypeId",
                schema: "public",
                table: "OrganizationTypeName");

            migrationBuilder.RenameColumn(
                name: "TypeId",
                schema: "public",
                table: "OrganizationTypeName",
                newName: "OrganizationTypeId");

            migrationBuilder.RenameIndex(
                name: "IX_OrgTypNam_TypeId",
                schema: "public",
                table: "OrganizationTypeName",
                newName: "IX_OrgTypNam_OrganizationTypeId");

            migrationBuilder.RenameColumn(
                name: "ParentTypeId",
                schema: "public",
                table: "OrganizationType",
                newName: "ParentId");

            migrationBuilder.RenameIndex(
                name: "IX_OrgTyp_ParentTypeId",
                schema: "public",
                table: "OrganizationType",
                newName: "IX_OrgTyp_ParentId");

            migrationBuilder.AddColumn <string>(
                name: "Label",
                schema: "public",
                table: "OrganizationType",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "OntologyType",
                schema: "public",
                table: "OrganizationType",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "ParentUri",
                schema: "public",
                table: "OrganizationType",
                nullable: true);

            migrationBuilder.AddColumn <string>(
                name: "Uri",
                schema: "public",
                table: "OrganizationType",
                nullable: true);

            migrationBuilder.AddForeignKey(
                name: "FK_OrganizationType_OrganizationType_ParentId",
                schema: "public",
                table: "OrganizationType",
                column: "ParentId",
                principalSchema: "public",
                principalTable: "OrganizationType",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_OrganizationTypeName_OrganizationType_OrganizationTypeId",
                schema: "public",
                table: "OrganizationTypeName",
                column: "OrganizationTypeId",
                principalSchema: "public",
                principalTable: "OrganizationType",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_4", "Fixed", "4OrganizationTypeUriSetting.sql"));
        }
        public void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "OrganizationServiceWebPage",
                schema: "public");

            migrationBuilder.DropForeignKey(
                name: "FK_OrganizationServiceAdditionalInformation_OrganizationService",
                schema: "public",
                table: "OrganizationServiceAdditionalInformation");

            migrationBuilder.DropForeignKey(
                name: "FK_OrganizationService_ProvisionType_ProvisionTypeId",
                schema: "public",
                table: "OrganizationService");

            migrationBuilder.DropForeignKey(
                name: "FK_OrganizationService_RoleType_RoleTypeId",
                schema: "public",
                table: "OrganizationService");

            migrationBuilder.DropPrimaryKey(
                name: "PK_OrganizationService",
                schema: "public",
                table: "OrganizationService");

            migrationBuilder.DropIndex(
                name: "IX_OrgSer_Id",
                schema: "public",
                table: "OrganizationService");

            migrationBuilder.DropIndex(
                name: "IX_OrgSer_ProvisionTypeId",
                schema: "public",
                table: "OrganizationService");

            migrationBuilder.DropIndex(
                name: "IX_OrgSer_RoleTypeId",
                schema: "public",
                table: "OrganizationService");

            migrationBuilder.CreateTable(
                name: "ServiceProducer",
                schema: "public",
                columns: table => new
            {
                Id                 = table.Column <Guid>(nullable: false),
                Created            = table.Column <DateTime>(nullable: false),
                CreatedBy          = table.Column <string>(nullable: true),
                Modified           = table.Column <DateTime>(nullable: false),
                ModifiedBy         = table.Column <string>(nullable: true),
                ProvisionTypeId    = table.Column <Guid>(nullable: false),
                ServiceVersionedId = table.Column <Guid>(nullable: false),
                LastOperationId    = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceProducer", x => x.Id);
                table.ForeignKey(
                    name: "FK_ServiceProducer_ProvisionType_ProvisionTypeId",
                    column: x => x.ProvisionTypeId,
                    principalSchema: "public",
                    principalTable: "ProvisionType",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceProducer_ServiceVersioned_ServiceVersionedId",
                    column: x => x.ServiceVersionedId,
                    principalSchema: "public",
                    principalTable: "ServiceVersioned",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_ServiceProducer_Id",
                schema: "public",
                table: "ServiceProducer",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_ServiceProducer_ProvisionTypeId",
                schema: "public",
                table: "ServiceProducer",
                column: "ProvisionTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_ServiceProducer_ServiceVersionedId",
                schema: "public",
                table: "ServiceProducer",
                column: "ServiceVersionedId");

            migrationBuilder.CreateTable(
                name: "ServiceProducerOrganization",
                schema: "public",
                columns: table => new
            {
                OrganizationId    = table.Column <Guid>(nullable: false),
                ServiceProducerId = table.Column <Guid>(nullable: false),
                Created           = table.Column <DateTime>(nullable: false),
                CreatedBy         = table.Column <string>(nullable: true),
                LastOperationId   = table.Column <string>(nullable: true),
                Modified          = table.Column <DateTime>(nullable: false),
                ModifiedBy        = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceProducerOrganization", x => new { x.OrganizationId, x.ServiceProducerId });
                table.ForeignKey(
                    name: "FK_ServiceProducerOrganization_Organization_OrganizationId",
                    column: x => x.OrganizationId,
                    principalSchema: "public",
                    principalTable: "Organization",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceProducerOrganization_ServiceProducer_ServiceProducerId",
                    column: x => x.ServiceProducerId,
                    principalSchema: "public",
                    principalTable: "ServiceProducer",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_SerProOrg_OrganizationId",
                schema: "public",
                table: "ServiceProducerOrganization",
                column: "OrganizationId");

            migrationBuilder.CreateIndex(
                name: "IX_SerProOrg_ServiceProducerId",
                schema: "public",
                table: "ServiceProducerOrganization",
                column: "ServiceProducerId");

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_6", "1ServiceProducer.sql"));

            migrationBuilder.DropColumn(
                name: "Id",
                schema: "public",
                table: "OrganizationService");

            migrationBuilder.DropColumn(
                name: "ProvisionTypeId",
                schema: "public",
                table: "OrganizationService");

            migrationBuilder.DropColumn(
                name: "RoleTypeId",
                schema: "public",
                table: "OrganizationService");

            migrationBuilder.AlterColumn <Guid>(
                name: "OrganizationId",
                schema: "public",
                table: "OrganizationService",
                nullable: false,
                oldClrType: typeof(Guid),
                oldNullable: true);

            migrationBuilder.AddPrimaryKey(
                name: "PK_OrganizationService",
                schema: "public",
                table: "OrganizationService",
                columns: new[] { "OrganizationId", "ServiceVersionedId" });

            migrationBuilder.DropTable(
                name: "RoleTypeName",
                schema: "public");

            migrationBuilder.DropTable(
                name: "RoleType",
                schema: "public");

            migrationBuilder.RenameTable(
                name: "OrganizationServiceAdditionalInformation",
                newName: "ServiceProducerAdditionalInformation",
                schema: "public"
                );

            migrationBuilder.RenameColumn(
                name: "OrganizationServiceId",
                newName: "ServiceProducerId",
                table: "ServiceProducerAdditionalInformation",
                schema: "public");

            migrationBuilder.CreateIndex(
                name: "IX_SerProAddInf_ServiceProducerId",
                schema: "public",
                table: "ServiceProducerAdditionalInformation",
                column: "ServiceProducerId");
        }
Beispiel #17
0
        public void Up(MigrationBuilder migrationBuilder)
        {
            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_4_5", "Fixed", "2AreaInformationType.sql"));

            migrationBuilder.AddColumn <Guid>(
                name: "AreaInformationTypeId",
                schema: "public",
                table: "ServiceVersioned",
                nullable: false,
                defaultValueSql: @"GetOrCreateDefaultAreaInformationTypeId('WholeCountry')");

            migrationBuilder.AddColumn <Guid>(
                name: "AreaInformationTypeId",
                schema: "public",
                table: "ServiceChannelVersioned",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "Area",
                schema: "public",
                columns: table => new
            {
                Id         = table.Column <Guid>(nullable: false),
                AreaTypeId = table.Column <Guid>(nullable: false),
                Created    = table.Column <DateTime>(nullable: false),
                CreatedBy  = table.Column <string>(nullable: true),
                Modified   = table.Column <DateTime>(nullable: false),
                ModifiedBy = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Area", x => x.Id);
                table.ForeignKey(
                    name: "FK_Area_AreaType_AreaTypeId",
                    column: x => x.AreaTypeId,
                    principalSchema: "public",
                    principalTable: "AreaType",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "OrganizationAreaMunicipality",
                schema: "public",
                columns: table => new
            {
                OrganizationVersionedId = table.Column <Guid>(nullable: false),
                MunicipalityId          = table.Column <Guid>(nullable: false),
                Created    = table.Column <DateTime>(nullable: false),
                CreatedBy  = table.Column <string>(nullable: true),
                Modified   = table.Column <DateTime>(nullable: false),
                ModifiedBy = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_OrganizationAreaMunicipality", x => new { x.OrganizationVersionedId, x.MunicipalityId });
                table.ForeignKey(
                    name: "FK_OrganizationAreaMunicipality_Municipality_MunicipalityId",
                    column: x => x.MunicipalityId,
                    principalSchema: "public",
                    principalTable: "Municipality",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_OrganizationAreaMunicipality_OrganizationVersioned_OrganizationVersionedId",
                    column: x => x.OrganizationVersionedId,
                    principalSchema: "public",
                    principalTable: "OrganizationVersioned",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ServiceAreaMunicipality",
                schema: "public",
                columns: table => new
            {
                ServiceVersionedId = table.Column <Guid>(nullable: false),
                MunicipalityId     = table.Column <Guid>(nullable: false),
                Created            = table.Column <DateTime>(nullable: false),
                CreatedBy          = table.Column <string>(nullable: true),
                Modified           = table.Column <DateTime>(nullable: false),
                ModifiedBy         = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceAreaMunicipality", x => new { x.ServiceVersionedId, x.MunicipalityId });
                table.ForeignKey(
                    name: "FK_ServiceAreaMunicipality_Municipality_MunicipalityId",
                    column: x => x.MunicipalityId,
                    principalSchema: "public",
                    principalTable: "Municipality",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceAreaMunicipality_ServiceVersioned_ServiceVersionedId",
                    column: x => x.ServiceVersionedId,
                    principalSchema: "public",
                    principalTable: "ServiceVersioned",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ServiceChannelAreaMunicipality",
                schema: "public",
                columns: table => new
            {
                ServiceChannelVersionedId = table.Column <Guid>(nullable: false),
                MunicipalityId            = table.Column <Guid>(nullable: false),
                Created    = table.Column <DateTime>(nullable: false),
                CreatedBy  = table.Column <string>(nullable: true),
                Modified   = table.Column <DateTime>(nullable: false),
                ModifiedBy = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceChannelAreaMunicipality", x => new { x.ServiceChannelVersionedId, x.MunicipalityId });
                table.ForeignKey(
                    name: "FK_ServiceChannelAreaMunicipality_Municipality_MunicipalityId",
                    column: x => x.MunicipalityId,
                    principalSchema: "public",
                    principalTable: "Municipality",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceChannelAreaMunicipality_ServiceChannelVersioned_ServiceChannelVersionedId",
                    column: x => x.ServiceChannelVersionedId,
                    principalSchema: "public",
                    principalTable: "ServiceChannelVersioned",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AreaMunicipality",
                schema: "public",
                columns: table => new
            {
                AreaId         = table.Column <Guid>(nullable: false),
                MunicipalityId = table.Column <Guid>(nullable: false),
                Created        = table.Column <DateTime>(nullable: false),
                CreatedBy      = table.Column <string>(nullable: true),
                Modified       = table.Column <DateTime>(nullable: false),
                ModifiedBy     = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AreaMunicipality", x => new { x.AreaId, x.MunicipalityId });
                table.ForeignKey(
                    name: "FK_AreaMunicipality_Area_AreaId",
                    column: x => x.AreaId,
                    principalSchema: "public",
                    principalTable: "Area",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AreaMunicipality_Municipality_MunicipalityId",
                    column: x => x.MunicipalityId,
                    principalSchema: "public",
                    principalTable: "Municipality",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AreaName",
                schema: "public",
                columns: table => new
            {
                AreaId         = table.Column <Guid>(nullable: false),
                LocalizationId = table.Column <Guid>(nullable: false),
                Created        = table.Column <DateTime>(nullable: false),
                CreatedBy      = table.Column <string>(nullable: true),
                Id             = table.Column <Guid>(nullable: false),
                Modified       = table.Column <DateTime>(nullable: false),
                ModifiedBy     = table.Column <string>(nullable: true),
                Name           = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AreaName", x => new { x.AreaId, x.LocalizationId });
                table.ForeignKey(
                    name: "FK_AreaName_Area_AreaId",
                    column: x => x.AreaId,
                    principalSchema: "public",
                    principalTable: "Area",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AreaName_Language_LocalizationId",
                    column: x => x.LocalizationId,
                    principalSchema: "public",
                    principalTable: "Language",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "OrganizationArea",
                schema: "public",
                columns: table => new
            {
                OrganizationVersionedId = table.Column <Guid>(nullable: false),
                AreaId     = table.Column <Guid>(nullable: false),
                Created    = table.Column <DateTime>(nullable: false),
                CreatedBy  = table.Column <string>(nullable: true),
                Modified   = table.Column <DateTime>(nullable: false),
                ModifiedBy = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_OrganizationArea", x => new { x.OrganizationVersionedId, x.AreaId });
                table.ForeignKey(
                    name: "FK_OrganizationArea_Area_AreaId",
                    column: x => x.AreaId,
                    principalSchema: "public",
                    principalTable: "Area",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_OrganizationArea_OrganizationVersioned_OrganizationVersionedId",
                    column: x => x.OrganizationVersionedId,
                    principalSchema: "public",
                    principalTable: "OrganizationVersioned",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ServiceArea",
                schema: "public",
                columns: table => new
            {
                ServiceVersionedId = table.Column <Guid>(nullable: false),
                AreaId             = table.Column <Guid>(nullable: false),
                Created            = table.Column <DateTime>(nullable: false),
                CreatedBy          = table.Column <string>(nullable: true),
                Modified           = table.Column <DateTime>(nullable: false),
                ModifiedBy         = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceArea", x => new { x.ServiceVersionedId, x.AreaId });
                table.ForeignKey(
                    name: "FK_ServiceArea_Area_AreaId",
                    column: x => x.AreaId,
                    principalSchema: "public",
                    principalTable: "Area",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceArea_ServiceVersioned_ServiceVersionedId",
                    column: x => x.ServiceVersionedId,
                    principalSchema: "public",
                    principalTable: "ServiceVersioned",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "ServiceChannelArea",
                schema: "public",
                columns: table => new
            {
                ServiceChannelVersionedId = table.Column <Guid>(nullable: false),
                AreaId     = table.Column <Guid>(nullable: false),
                Created    = table.Column <DateTime>(nullable: false),
                CreatedBy  = table.Column <string>(nullable: true),
                Modified   = table.Column <DateTime>(nullable: false),
                ModifiedBy = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_ServiceChannelArea", x => new { x.ServiceChannelVersionedId, x.AreaId });
                table.ForeignKey(
                    name: "FK_ServiceChannelArea_Area_AreaId",
                    column: x => x.AreaId,
                    principalSchema: "public",
                    principalTable: "Area",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_ServiceChannelArea_ServiceChannelVersioned_ServiceChannelVersionedId",
                    column: x => x.ServiceChannelVersionedId,
                    principalSchema: "public",
                    principalTable: "ServiceChannelVersioned",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_SerVer_AreaInformationTypeId",
                schema: "public",
                table: "ServiceVersioned",
                column: "AreaInformationTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_SerChaVer_AreaInformationTypeId",
                schema: "public",
                table: "ServiceChannelVersioned",
                column: "AreaInformationTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_Are_AreaTypeId",
                schema: "public",
                table: "Area",
                column: "AreaTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_Are_Id",
                schema: "public",
                table: "Area",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_AreMun_AreaId",
                schema: "public",
                table: "AreaMunicipality",
                column: "AreaId");

            migrationBuilder.CreateIndex(
                name: "IX_AreMun_MunicipalityId",
                schema: "public",
                table: "AreaMunicipality",
                column: "MunicipalityId");

            migrationBuilder.CreateIndex(
                name: "IX_AreNam_AreaId",
                schema: "public",
                table: "AreaName",
                column: "AreaId");

            migrationBuilder.CreateIndex(
                name: "IX_AreNam_LocalizationId",
                schema: "public",
                table: "AreaName",
                column: "LocalizationId");

            migrationBuilder.CreateIndex(
                name: "IX_OrgAre_AreaId",
                schema: "public",
                table: "OrganizationArea",
                column: "AreaId");

            migrationBuilder.CreateIndex(
                name: "IX_OrgAre_OrganizationVersionedId",
                schema: "public",
                table: "OrganizationArea",
                column: "OrganizationVersionedId");

            migrationBuilder.CreateIndex(
                name: "IX_OrgAreMun_MunicipalityId",
                schema: "public",
                table: "OrganizationAreaMunicipality",
                column: "MunicipalityId");

            migrationBuilder.CreateIndex(
                name: "IX_OrgAreMun_OrganizationVersionedId",
                schema: "public",
                table: "OrganizationAreaMunicipality",
                column: "OrganizationVersionedId");

            migrationBuilder.CreateIndex(
                name: "IX_SerAre_AreaId",
                schema: "public",
                table: "ServiceArea",
                column: "AreaId");

            migrationBuilder.CreateIndex(
                name: "IX_SerAre_ServiceVersionedId",
                schema: "public",
                table: "ServiceArea",
                column: "ServiceVersionedId");

            migrationBuilder.CreateIndex(
                name: "IX_SerAreMun_MunicipalityId",
                schema: "public",
                table: "ServiceAreaMunicipality",
                column: "MunicipalityId");

            migrationBuilder.CreateIndex(
                name: "IX_SerAreMun_ServiceVersionedId",
                schema: "public",
                table: "ServiceAreaMunicipality",
                column: "ServiceVersionedId");

            migrationBuilder.CreateIndex(
                name: "IX_SerChaAre_AreaId",
                schema: "public",
                table: "ServiceChannelArea",
                column: "AreaId");

            migrationBuilder.CreateIndex(
                name: "IX_SerChaAre_ServiceChannelVersionedId",
                schema: "public",
                table: "ServiceChannelArea",
                column: "ServiceChannelVersionedId");

            migrationBuilder.CreateIndex(
                name: "IX_SerChaAreMun_MunicipalityId",
                schema: "public",
                table: "ServiceChannelAreaMunicipality",
                column: "MunicipalityId");

            migrationBuilder.CreateIndex(
                name: "IX_SerChaAreMun_ServiceChannelVersionedId",
                schema: "public",
                table: "ServiceChannelAreaMunicipality",
                column: "ServiceChannelVersionedId");

            migrationBuilder.AddForeignKey(
                name: "FK_ServiceChannelVersioned_AreaInformationType_AreaInformationTypeId",
                schema: "public",
                table: "ServiceChannelVersioned",
                column: "AreaInformationTypeId",
                principalSchema: "public",
                principalTable: "AreaInformationType",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_ServiceVersioned_AreaInformationType_AreaInformationTypeId",
                schema: "public",
                table: "ServiceVersioned",
                column: "AreaInformationTypeId",
                principalSchema: "public",
                principalTable: "AreaInformationType",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }
Beispiel #18
0
        public void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.RenameTable(
                name: "AddressType",
                newName: "AddressCharacter",
                schema: "public");

            migrationBuilder.CreateTable(
                name: "AddressType",
                schema: "public",
                columns: table => new
            {
                Id              = table.Column <Guid>(nullable: false),
                Code            = table.Column <string>(nullable: true),
                Created         = table.Column <DateTime>(nullable: false),
                CreatedBy       = table.Column <string>(nullable: true),
                LastOperationId = table.Column <string>(nullable: true),
                Modified        = table.Column <DateTime>(nullable: false),
                ModifiedBy      = table.Column <string>(nullable: true),
                OrderNumber     = table.Column <int>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AddressTypeId", x => x.Id);
            });

            migrationBuilder.CreateTable(
                name: "AddressForeign",
                schema: "public",
                columns: table => new
            {
                AddressId       = table.Column <Guid>(nullable: false),
                Created         = table.Column <DateTime>(nullable: false),
                CreatedBy       = table.Column <string>(nullable: true),
                LastOperationId = table.Column <string>(nullable: true),
                Modified        = table.Column <DateTime>(nullable: false),
                ModifiedBy      = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AddressForeign", x => x.AddressId);
                table.ForeignKey(
                    name: "FK_AddressForeign_Address_AddressId",
                    column: x => x.AddressId,
                    principalSchema: "public",
                    principalTable: "Address",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });



            migrationBuilder.CreateTable(
                name: "AddressPostOfficeBox",
                schema: "public",
                columns: table => new
            {
                AddressId       = table.Column <Guid>(nullable: false),
                Created         = table.Column <DateTime>(nullable: false),
                CreatedBy       = table.Column <string>(nullable: true),
                LastOperationId = table.Column <string>(nullable: true),
                Modified        = table.Column <DateTime>(nullable: false),
                ModifiedBy      = table.Column <string>(nullable: true),
                MunicipalityId  = table.Column <Guid>(nullable: true),
                PostalCodeId    = table.Column <Guid>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AddressPostOfficeBox", x => x.AddressId);
                table.ForeignKey(
                    name: "FK_AddressPostOfficeBox_Address_AddressId",
                    column: x => x.AddressId,
                    principalSchema: "public",
                    principalTable: "Address",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AddressPostOfficeBox_Municipality_MunicipalityId",
                    column: x => x.MunicipalityId,
                    principalSchema: "public",
                    principalTable: "Municipality",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_AddressPostOfficeBox_PostalCode_PostalCodeId",
                    column: x => x.PostalCodeId,
                    principalSchema: "public",
                    principalTable: "PostalCode",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AddressStreet",
                schema: "public",
                columns: table => new
            {
                AddressId       = table.Column <Guid>(nullable: false),
                Created         = table.Column <DateTime>(nullable: false),
                CreatedBy       = table.Column <string>(nullable: true),
                LastOperationId = table.Column <string>(nullable: true),
                Modified        = table.Column <DateTime>(nullable: false),
                ModifiedBy      = table.Column <string>(nullable: true),
                MunicipalityId  = table.Column <Guid>(nullable: true),
                PostalCodeId    = table.Column <Guid>(nullable: false),
                StreetNumber    = table.Column <string>(maxLength: 30, nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AddressStreet", x => x.AddressId);
                table.ForeignKey(
                    name: "FK_AddressStreet_Address_AddressId",
                    column: x => x.AddressId,
                    principalSchema: "public",
                    principalTable: "Address",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AddressStreet_Municipality_MunicipalityId",
                    column: x => x.MunicipalityId,
                    principalSchema: "public",
                    principalTable: "Municipality",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Restrict);
                table.ForeignKey(
                    name: "FK_AddressStreet_PostalCode_PostalCodeId",
                    column: x => x.PostalCodeId,
                    principalSchema: "public",
                    principalTable: "PostalCode",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "AddressForeignTextName",
                schema: "public",
                columns: table => new
            {
                AddressForeignId = table.Column <Guid>(nullable: false),
                LocalizationId   = table.Column <Guid>(nullable: false),
                Created          = table.Column <DateTime>(nullable: false),
                CreatedBy        = table.Column <string>(nullable: true),
                LastOperationId  = table.Column <string>(nullable: true),
                Modified         = table.Column <DateTime>(nullable: false),
                ModifiedBy       = table.Column <string>(nullable: true),
                Name             = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AddressForeignTextName", x => new { x.AddressForeignId, x.LocalizationId });
                table.ForeignKey(
                    name: "FK_AddressForeignTextName_AddressForeign_AddressForeignId",
                    column: x => x.AddressForeignId,
                    principalSchema: "public",
                    principalTable: "AddressForeign",
                    principalColumn: "AddressId",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AddressForeignTextName_Language_LocalizationId",
                    column: x => x.LocalizationId,
                    principalSchema: "public",
                    principalTable: "Language",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            foreach (AddressTypeEnum addressType in Enum.GetValues(typeof(AddressTypeEnum)))
            {
                migrationBuilder.Sql($@"INSERT INTO ""AddressType""(""Id"", ""Code"", ""Created"", ""Modified"") VALUES ('{addressType.ToString().GetGuid()}','{addressType.ToString()}','2017-01-01 01:01:01','2017-01-01 01:01:01');");
            }

            migrationBuilder.AddColumn <Guid>(
                name: "TypeId",
                schema: "public",
                table: "Address",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_6", "3AddressThirdType.sql"));

            migrationBuilder.DropForeignKey(
                name: "FK_Address_Municipality_MunicipalityId",
                schema: "public",
                table: "Address");

            migrationBuilder.DropForeignKey(
                name: "FK_Address_PostalCode_PostalCodeId",
                schema: "public",
                table: "Address");

            migrationBuilder.DropForeignKey(
                name: "FK_OrganizationAddress_AddressType_TypeId",
                schema: "public",
                table: "OrganizationAddress");

            migrationBuilder.DropForeignKey(
                name: "FK_PostOfficeBoxName_Address_AddressId",
                schema: "public",
                table: "PostOfficeBoxName");

            migrationBuilder.DropForeignKey(
                name: "FK_ServiceLocationChannelAddress_AddressType_TypeId",
                schema: "public",
                table: "ServiceLocationChannelAddress");

            migrationBuilder.DropForeignKey(
                name: "FK_StreetAddress_Address_AddressId",
                schema: "public",
                table: "StreetName");

            migrationBuilder.DropPrimaryKey(
                name: "PK_StreetName",
                schema: "public",
                table: "StreetName");

            migrationBuilder.DropIndex(
                name: "IX_StrNam_Id",
                schema: "public",
                table: "StreetName");

            migrationBuilder.DropPrimaryKey(
                name: "PK_PostOfficeBoxName",
                schema: "public",
                table: "PostOfficeBoxName");

            migrationBuilder.DropIndex(
                name: "IX_PosOffBoxNam_Id",
                schema: "public",
                table: "PostOfficeBoxName");

            migrationBuilder.DropIndex(
                name: "IX_Add_MunicipalityId",
                schema: "public",
                table: "Address");


            migrationBuilder.DropColumn(
                name: "Id",
                schema: "public",
                table: "StreetName");

            migrationBuilder.DropColumn(
                name: "Id",
                schema: "public",
                table: "PostOfficeBoxName");

            migrationBuilder.DropColumn(
                name: "MunicipalityId",
                schema: "public",
                table: "Address");

            migrationBuilder.DropColumn(
                name: "PostalCodeId",
                schema: "public",
                table: "Address");

            migrationBuilder.DropColumn(
                name: "StreetNumber",
                schema: "public",
                table: "Address");

            migrationBuilder.RenameColumn(
                name: "Text",
                schema: "public",
                table: "StreetName",
                newName: "Name");

            migrationBuilder.RenameColumn(
                name: "AddressId",
                schema: "public",
                table: "StreetName",
                newName: "AddressStreetId");

            migrationBuilder.RenameIndex(
                name: "IX_StrNam_AddressId",
                schema: "public",
                table: "StreetName",
                newName: "IX_StrNam_AddressStreetId");

            migrationBuilder.RenameColumn(
                name: "TypeId",
                schema: "public",
                table: "ServiceLocationChannelAddress",
                newName: "CharacterId");

            migrationBuilder.RenameIndex(
                name: "IX_SerLocChaAdd_TypeId",
                schema: "public",
                table: "ServiceLocationChannelAddress",
                newName: "IX_SerLocChaAdd_CharacterId");

            migrationBuilder.RenameColumn(
                name: "Text",
                schema: "public",
                table: "PostOfficeBoxName",
                newName: "Name");

            migrationBuilder.RenameColumn(
                name: "AddressId",
                schema: "public",
                table: "PostOfficeBoxName",
                newName: "AddressPostOfficeBoxId");

            migrationBuilder.RenameIndex(
                name: "IX_PosOffBoxNam_AddressId",
                schema: "public",
                table: "PostOfficeBoxName",
                newName: "IX_PosOffBoxNam_AddressPostOfficeBoxId");

            migrationBuilder.RenameColumn(
                name: "TypeId",
                schema: "public",
                table: "OrganizationAddress",
                newName: "CharacterId");

            migrationBuilder.RenameIndex(
                name: "IX_OrgAdd_TypeId",
                schema: "public",
                table: "OrganizationAddress",
                newName: "IX_OrgAdd_CharacterId");

//            migrationBuilder.AlterColumn<Guid>(
//                name: "PostalCodeId",
//                schema: "public",
//                table: "Address",
//                nullable: true,
//                oldClrType: typeof(Guid));

            migrationBuilder.AddColumn <int>(
                name: "OrderNumber",
                schema: "public",
                table: "Address",
                nullable: true);



            migrationBuilder.AddPrimaryKey(
                name: "PK_StreetName",
                schema: "public",
                table: "StreetName",
                columns: new[] { "AddressStreetId", "LocalizationId" });

            migrationBuilder.AddPrimaryKey(
                name: "PK_PostOfficeBoxName",
                schema: "public",
                table: "PostOfficeBoxName",
                columns: new[] { "AddressPostOfficeBoxId", "LocalizationId" });



            migrationBuilder.CreateTable(
                name: "AddressCharacterName",
                schema: "public",
                columns: table => new
            {
                Id              = table.Column <Guid>(nullable: false),
                Created         = table.Column <DateTime>(nullable: false),
                CreatedBy       = table.Column <string>(nullable: true),
                LastOperationId = table.Column <string>(nullable: true),
                LocalizationId  = table.Column <Guid>(nullable: false),
                Modified        = table.Column <DateTime>(nullable: false),
                ModifiedBy      = table.Column <string>(nullable: true),
                Name            = table.Column <string>(nullable: true),
                TypeId          = table.Column <Guid>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AddressCharacterName", x => x.Id);
                table.ForeignKey(
                    name: "FK_AddressCharacterName_Language_LocalizationId",
                    column: x => x.LocalizationId,
                    principalSchema: "public",
                    principalTable: "Language",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AddressCharacterName_AddressCharacter_TypeId",
                    column: x => x.TypeId,
                    principalSchema: "public",
                    principalTable: "AddressCharacter",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });
            migrationBuilder.DropTable(name: "AddressTypeName", schema: "public");
            migrationBuilder.CreateTable(
                name: "AddressTypeName",
                schema: "public",
                columns: table => new
            {
                Id              = table.Column <Guid>(nullable: false),
                Created         = table.Column <DateTime>(nullable: false),
                CreatedBy       = table.Column <string>(nullable: true),
                LastOperationId = table.Column <string>(nullable: true),
                LocalizationId  = table.Column <Guid>(nullable: false),
                Modified        = table.Column <DateTime>(nullable: false),
                ModifiedBy      = table.Column <string>(nullable: true),
                Name            = table.Column <string>(nullable: true),
                TypeId          = table.Column <Guid>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_AddressTypeName", x => x.Id);
                table.ForeignKey(
                    name: "FK_AddressTypeName_Language_LocalizationId",
                    column: x => x.LocalizationId,
                    principalSchema: "public",
                    principalTable: "Language",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_AddressTypeName_AddressType_TypeId",
                    column: x => x.TypeId,
                    principalSchema: "public",
                    principalTable: "AddressType",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_AddTypNam_Id",
                schema: "public",
                table: "AddressTypeName",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_Add_TypeId",
                schema: "public",
                table: "Address",
                column: "TypeId");

            migrationBuilder.CreateIndex(
                name: "IX_AddFor_AddressId",
                schema: "public",
                table: "AddressForeign",
                column: "AddressId");

            migrationBuilder.CreateIndex(
                name: "IX_AddForTexNam_AddressForeignId",
                schema: "public",
                table: "AddressForeignTextName",
                column: "AddressForeignId");

            migrationBuilder.CreateIndex(
                name: "IX_AddForTexNam_LocalizationId",
                schema: "public",
                table: "AddressForeignTextName",
                column: "LocalizationId");

            migrationBuilder.CreateIndex(
                name: "IX_AddCha_Id",
                schema: "public",
                table: "AddressCharacter",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_AddChaNam_Id",
                schema: "public",
                table: "AddressCharacterName",
                column: "Id");

            migrationBuilder.CreateIndex(
                name: "IX_AddChaNam_LocalizationId",
                schema: "public",
                table: "AddressCharacterName",
                column: "LocalizationId");

            migrationBuilder.CreateIndex(
                name: "IX_AddChaNam_TypeId",
                schema: "public",
                table: "AddressCharacterName",
                column: "TypeId");

            migrationBuilder.CreateIndex(
                name: "IX_AddPosOffBox_AddressId",
                schema: "public",
                table: "AddressPostOfficeBox",
                column: "AddressId");

            migrationBuilder.CreateIndex(
                name: "IX_AddPosOffBox_MunicipalityId",
                schema: "public",
                table: "AddressPostOfficeBox",
                column: "MunicipalityId");

            migrationBuilder.CreateIndex(
                name: "IX_AddPosOffBox_PostalCodeId",
                schema: "public",
                table: "AddressPostOfficeBox",
                column: "PostalCodeId");

            migrationBuilder.CreateIndex(
                name: "IX_AddStr_AddressId",
                schema: "public",
                table: "AddressStreet",
                column: "AddressId");

            migrationBuilder.CreateIndex(
                name: "IX_AddStr_MunicipalityId",
                schema: "public",
                table: "AddressStreet",
                column: "MunicipalityId");

            migrationBuilder.CreateIndex(
                name: "IX_AddStr_PostalCodeId",
                schema: "public",
                table: "AddressStreet",
                column: "PostalCodeId");

//            migrationBuilder.AddForeignKey(
//                name: "FK_Address_PostalCode_PostalCodeId",
//                schema: "public",
//                table: "Address",
//                column: "PostalCodeId",
//                principalSchema: "public",
//                principalTable: "PostalCode",
//                principalColumn: "Id",
//                onDelete: ReferentialAction.Restrict);

            migrationBuilder.AddForeignKey(
                name: "FK_Address_AddressType_TypeId",
                schema: "public",
                table: "Address",
                column: "TypeId",
                principalSchema: "public",
                principalTable: "AddressType",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_OrganizationAddress_AddressCharacter_CharacterId",
                schema: "public",
                table: "OrganizationAddress",
                column: "CharacterId",
                principalSchema: "public",
                principalTable: "AddressCharacter",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_PostOfficeBoxName_AddressPostOfficeBox_AddressPostOfficeBoxId",
                schema: "public",
                table: "PostOfficeBoxName",
                column: "AddressPostOfficeBoxId",
                principalSchema: "public",
                principalTable: "AddressPostOfficeBox",
                principalColumn: "AddressId",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_ServiceLocationChannelAddress_AddressCharacter_CharacterId",
                schema: "public",
                table: "ServiceLocationChannelAddress",
                column: "CharacterId",
                principalSchema: "public",
                principalTable: "AddressCharacter",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);

            migrationBuilder.AddForeignKey(
                name: "FK_StreetName_AddressStreet_AddressStreetId",
                schema: "public",
                table: "StreetName",
                column: "AddressStreetId",
                principalSchema: "public",
                principalTable: "AddressStreet",
                principalColumn: "AddressId",
                onDelete: ReferentialAction.Cascade);
        }
Beispiel #19
0
        public void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "OrganizationDisplayNameType",
                schema: "public",
                columns: table => new
            {
                OrganizationVersionedId = table.Column <Guid>(nullable: false),
                LocalizationId          = table.Column <Guid>(nullable: false),
                Created           = table.Column <DateTime>(nullable: false),
                CreatedBy         = table.Column <string>(nullable: true),
                DisplayNameTypeId = table.Column <Guid>(nullable: false),
                Modified          = table.Column <DateTime>(nullable: false),
                ModifiedBy        = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_OrganizationDisplayNameType", x => new { x.OrganizationVersionedId, x.LocalizationId });
                table.ForeignKey(
                    name: "FK_OrganizationDisplayNameType_NameType_DisplayNameTypeId",
                    column: x => x.DisplayNameTypeId,
                    principalSchema: "public",
                    principalTable: "NameType",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_OrganizationDisplayNameType_Language_LocalizationId",
                    column: x => x.LocalizationId,
                    principalSchema: "public",
                    principalTable: "Language",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
                table.ForeignKey(
                    name: "FK_OrganizationDisplayNameType_OrganizationVersioned_OrganizationVersionedId",
                    column: x => x.OrganizationVersionedId,
                    principalSchema: "public",
                    principalTable: "OrganizationVersioned",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_OrgDisNamTyp_DisplayNameTypeId",
                schema: "public",
                table: "OrganizationDisplayNameType",
                column: "DisplayNameTypeId");

            migrationBuilder.CreateIndex(
                name: "IX_OrgDisNamTyp_LocalizationId",
                schema: "public",
                table: "OrganizationDisplayNameType",
                column: "LocalizationId");

            migrationBuilder.CreateIndex(
                name: "IX_OrgDisNamTyp_OrganizationVersionedId",
                schema: "public",
                table: "OrganizationDisplayNameType",
                column: "OrganizationVersionedId");

            dataUtils.AddSqlScript(migrationBuilder, Path.Combine("SqlMigrations", "PTV_1_4_5", "Fixed", "5OrganizationDisplayNameType.sql"));

            migrationBuilder.DropForeignKey(
                name: "FK_Organization_NameType_DisplayNameTypeId",
                schema: "public",
                table: "OrganizationVersioned");

            migrationBuilder.DropIndex(
                name: "IX_Org_DisplayNameTypeId",
                schema: "public",
                table: "OrganizationVersioned");

            migrationBuilder.DropColumn(
                name: "DisplayNameTypeId",
                schema: "public",
                table: "OrganizationVersioned");
        }