Open Closed

Need advice on migrating changes to database in production environment #7588


User avatar
0
dzungle created
  • ABP Framework version: v7.4.4
  • UI Type: Angular
  • Database System: MongoDB
  • Tiered (for MVC) or Auth Server Separated (for Angular): no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Hello Support Team,

I have deployed my application to Azure Kubernetes Service cluster. Now I have made changes to the database (adding new entities and modify existing entities). Please, advise me the best way to migrate the changes to the current running application in AKS cluster. I have read your document on seeding data using the dbmigrator console application. But it does not provide detail information. I would highly appreciate if you could show me how to do this step by step.

Thank you in advance. Best Regards Dzungle


5 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You should be able to publish and run the DB migrator in the CI.

    Create multiple environment appsettings files, appsettings.Development.json, appsettings.Production.json etc.

  • User Avatar
    0
    dzungle created

    Hi Liangshiwei,

    Could you please provide more details?

    Here is the appsettings.json in project DbMigrator:

    { "ConnectionStrings": { "Default": "mongodb://localhost:27017/LogiPlat?retryWrites=false", "HangFire": "Data Source=127.0.0.1;Initial Catalog=logi_hangfire;User id=sa;Password=0aP57hal0l39Y1R1GmUoSW;TrustServerCertificate=True;" }, "Redis": { "Configuration": "127.0.0.1" }, "OpenIddict": { "Applications": { "LogiPlat_Web": { "ClientId": "LogiPlat_Web", "ClientSecret": "1q2w3e*", "RootUrl": "https://localhost:44375" }, "LogiPlat_Web_Public": { "ClientId": "LogiPlat_Web_Public", "ClientSecret": "1q2w3e*", "RootUrl": "https://localhost:44377" }, "LogiPlat_Web_Public_Tiered": { "ClientId": "LogiPlat_Web_Public_Tiered", "ClientSecret": "1q2w3e*", "RootUrl": "https://localhost:44316" }, "LogiPlat_App": { "ClientId": "LogiPlat_App", "RootUrl": "http://localhost:4200" }, "LogiPlat_Maui": { "ClientId": "LogiPlat_Maui", "RootUrl": "logiplat://" }, "LogiPlat_Mobile": { "ClientId": "LogiPlat_Mobile", "RootUrl": "exp://localhost:19000" }, "LogiPlat_MauiBlazor": { "ClientId": "LogiPlat_MauiBlazor", "RootUrl": "logiplatmauiblazor://" }, "LogiPlat_BlazorServerTiered": { "ClientId": "LogiPlat_BlazorServerTiered", "ClientSecret": "1q2w3e*", "RootUrl": "https://localhost:44361" }, "LogiPlat_Swagger": { "ClientId": "LogiPlat_Swagger", "RootUrl": "https://localhost:44343" } } } }

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    you can check thishttps://medium.com/abp-community/deploy-your-abp-framework-angular-project-to-azure-kubernetes-service-aks-83fe6bf27d66

  • User Avatar
    0
    dzungle created

    Hi Liangshiwei,

    1. I have successfully connected and updated the remote database from the local development machine. Please, show me how to create and configure multiple environment appsettings files (appsettings.Development.json, appsettings.Production.json) in the DbMigrator project so that I don't have to change the values of OpenIddict Applications when migrating to the remote database.

    2. By the way, I don't see the changes (remove and modify some properties of an entity) applied to the existing documents in MongoDb after running the DbMigrator. Does the DbMigrator (for MongoDb) apply the changes to the existing documents or only apply to the new ones? Or do I have to manually update the changes to the existing documents?

    Thank you

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Please, show me how to create and configure multiple environment appsettings files (appsettings.Development.json, appsettings.Production.json) in the DbMigrator project so that I don't have to change the values of OpenIddict Applications when migrating to the remote database.

    you just need to create an appsettings.Production.json JSON file. And update the DbMigrator.csproj

      <ItemGroup>
        <None Remove="appsettings.Production.json" />
        <Content Include="appsettings.Production.json">
          <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        </Content>
      </ItemGroup>
    

    then you are use then dotnet run --environment Production command

    By the way, I don't see the changes (remove and modify some properties of an entity) applied to the existing documents in MongoDb after running the DbMigrator. Does the DbMigrator (for MongoDb) apply the changes to the existing documents or only apply to the new ones? Or do I have to manually update the changes to the existing documents?

    how do i reproduce this

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15