Skip to content

Commit

Permalink
Merge pull request #6855 from abpframework/Dbms-Change-ConnectionString
Browse files Browse the repository at this point in the history
change connection string by Dbms preference
  • Loading branch information
ebicoglu authored Jan 3, 2021
2 parents 5dc91ed + cfa005f commit 6b8edd4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ public async Task ExecuteAsync(CommandLineArgs commandLineArgs)

Logger.LogInformation("Output folder: " + outputFolder);

if (connectionString == null &&
databaseManagementSystem != DatabaseManagementSystem.NotSpecified &&
databaseManagementSystem != DatabaseManagementSystem.SQLServer)
{
connectionString = GetNewConnectionStringByDbms(databaseManagementSystem, outputFolder);
}

commandLineArgs.Options.Add(CliConsts.Command, commandLineArgs.Command);

var result = await TemplateProjectBuilder.BuildAsync(
Expand Down Expand Up @@ -219,6 +226,24 @@ public async Task ExecuteAsync(CommandLineArgs commandLineArgs)
}
}

private string GetNewConnectionStringByDbms(DatabaseManagementSystem databaseManagementSystem, string outputFolder)
{
switch (databaseManagementSystem)
{
case DatabaseManagementSystem.MySQL:
return "Server=localhost;Port=3306;Database=MyProjectName;Uid=root;Pwd=myPassword;";
case DatabaseManagementSystem.PostgreSQL:
return "User ID=root;Password=myPassword;Host=localhost;Port=5432;Database=MyProjectName;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;";
//case DatabaseManagementSystem.Oracle:
case DatabaseManagementSystem.OracleDevart:
return "Data Source=MyProjectName;Integrated Security=yes;";
case DatabaseManagementSystem.SQLite:
return $"Data Source={Path.Combine(outputFolder,"database\\MyProjectName.db")};Version=3;";
default:
return null;
}
}

private void DeleteMigrationsIfNeeded(DatabaseProvider databaseProvider, DatabaseManagementSystem databaseManagementSystem, string outputFolder)
{
if (databaseManagementSystem == DatabaseManagementSystem.NotSpecified || databaseManagementSystem == DatabaseManagementSystem.SQLServer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ public static ProjectBuildPipeline Build(ProjectBuildContext context)

pipeline.Steps.Add(new ProjectReferenceReplaceStep());
pipeline.Steps.Add(new TemplateCodeDeleteStep());

if (context.BuildArgs.ConnectionString != null)
{
pipeline.Steps.Add(new ConnectionStringChangeStep());
}

pipeline.Steps.Add(new SolutionRenameStep());

if (context.Template.Name == AppProTemplate.TemplateName ||
Expand All @@ -37,11 +43,6 @@ public static ProjectBuildPipeline Build(ProjectBuildContext context)
pipeline.Steps.Add(new RemoveRootFolderStep());
}

if (context.BuildArgs.ConnectionString != null)
{
pipeline.Steps.Add(new ConnectionStringChangeStep());
}

pipeline.Steps.Add(new CreateProjectResultZipStep());

return pipeline;
Expand Down

0 comments on commit 6b8edd4

Please sign in to comment.