mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.6 KiB
68 lines
2.6 KiB
using System;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Volo.Abp;
|
|
using VoloDocs.EntityFrameworkCore;
|
|
|
|
namespace VoloDocs.Migrator
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
Console.WriteLine("Initializing VoloDocs Migrator ... ");
|
|
|
|
using (var app = AbpApplicationFactory.Create<VoloDocsMigratorModule>())
|
|
{
|
|
app.Initialize();
|
|
|
|
using (var dbContext = app.Resolve<VoloDocsDbContext>())
|
|
{
|
|
var connectionString = dbContext.Database.GetDbConnection().ConnectionString;
|
|
|
|
Console.Clear();
|
|
|
|
Console.Write("\nThis program updates an existing database or creates a new one if not exists.\n" +
|
|
"The following connection string will be used:\n\n" +
|
|
new string('=', 70) + "\n" +
|
|
connectionString + "\n" +
|
|
new string('=', 70) + "\n\n" +
|
|
"Do you confirm to run the migration? (y/n) ");
|
|
|
|
if (Console.ReadKey().Key == ConsoleKey.Y)
|
|
{
|
|
try
|
|
{
|
|
Console.WriteLine("\nMigrating...");
|
|
|
|
dbContext.Database.Migrate();
|
|
|
|
Console.WriteLine("\nCompleted.");
|
|
|
|
Console.Write("\nDo you want to see the applied migrations? (y/n) ");
|
|
if (Console.ReadKey().Key == ConsoleKey.Y)
|
|
{
|
|
Console.WriteLine("\n\n-- start of migrations --");
|
|
|
|
var appliedMigrations = dbContext.Database.GetAppliedMigrations();
|
|
foreach (var appliedMigration in appliedMigrations)
|
|
{
|
|
Console.WriteLine(appliedMigration);
|
|
}
|
|
|
|
Console.WriteLine("-- end of migrations --\n");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.Write("\nAn error occured while migrating the database:\n");
|
|
Console.Write(ex.ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
Console.WriteLine("Press ENTER to exit...");
|
|
Console.ReadLine();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|