abp icon indicating copy to clipboard operation
abp copied to clipboard

Migrations in a production environment

Open dicksonkimeu opened this issue 6 years ago • 5 comments

Seems after adding a new tenant to use a different connection string from host database, migration must he done. The database migration project does this well, but in visual studio.

In a production server where no visual studio installed how can this be done ?

dicksonkimeu avatar Jul 07 '20 00:07 dicksonkimeu

You can publish the migration application and run in production server.

realLiangshiwei avatar Jul 07 '20 01:07 realLiangshiwei

Hi @liangshiw ,

Is it possible to create an endpoint/ApplicationService that will call the DB migration service? If yes please let us know.

So that we can just hit the endpoint which will call the DB migration service and DB will be created without running the DB migration project.

this what I tried

using Acme.BookStore.Data;
using Acme.BookStore.DbMigrator;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Application.Services;

namespace Acme.BookStore
{
    public class CreateDbAppService : ApplicationService
    {
        public async Task GetDb()
        {
            using (var application = AbpApplicationFactory.Create<BookStoreDbMigratorModule>(options =>
            {
                options.UseAutofac();
            }))
            {
                application.Initialize();

                await application
                    .ServiceProvider
                    .GetRequiredService<BookStoreDbMigrationService>()
                    .MigrateAsync();

                application.Shutdown();
            }
        }
    }
}

But the issue is I am not able to login using UI. and when I am trying from swagger using tenant Id login it is giving me success but from the angular its shows invalid.

Is there anything related to Identity server?

Logs.txt

jacmiller12 avatar Jul 07 '20 06:07 jacmiller12

You can directly inject the BookStoreDbMigrationService service.

You should check BookStore_App client exists. image

realLiangshiwei avatar Jul 07 '20 07:07 realLiangshiwei

We're deploying the Host and the DbMigrator for a microservice. Our docker-compose contains both as services.

NecatiMeral avatar Jul 07 '20 09:07 NecatiMeral

I will try this, though it would be good to have this as a standard features for abp

dicksonkimeu avatar Jul 13 '20 23:07 dicksonkimeu