Skip to content

Commit

Permalink
Renaming PerDirectoryExecution to SearchAllSubdirectoriesInsteadOfTra…
Browse files Browse the repository at this point in the history
…verse. Upgrade roundhouse.databases.postgresql to newest fnh/nh

general cleanup
  • Loading branch information
ferventcoder committed Nov 11, 2011
1 parent 1abe28f commit d67cd30
Show file tree
Hide file tree
Showing 23 changed files with 492 additions and 507 deletions.
382 changes: 200 additions & 182 deletions product/roundhouse.console/Program.cs

Large diffs are not rendered by default.

99 changes: 0 additions & 99 deletions product/roundhouse.databases.postgre/PostgreSQLDatabase.cs

This file was deleted.

36 changes: 0 additions & 36 deletions product/roundhouse.databases.postgre/Properties/AssemblyInfo.cs

This file was deleted.

33 changes: 0 additions & 33 deletions product/roundhouse.databases.postgre/orm/ScriptsRunErrorMapping.cs

This file was deleted.

32 changes: 0 additions & 32 deletions product/roundhouse.databases.postgre/orm/ScriptsRunMapping.cs

This file was deleted.

28 changes: 0 additions & 28 deletions product/roundhouse.databases.postgre/orm/VersionMapping.cs

This file was deleted.

8 changes: 0 additions & 8 deletions product/roundhouse.databases.postgre/packages.config

This file was deleted.

100 changes: 100 additions & 0 deletions product/roundhouse.databases.postgresql/PostgreSQLDatabase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
namespace roundhouse.databases.postgresql
{
using System;
using infrastructure.app;
using infrastructure.extensions;
using infrastructure.logging;
using Npgsql;

public class PostgreSQLDatabase : AdoNetDatabase
{
private readonly PostgreAdoNetProviderResolver postgre_ado_net_provider_resolver;

public PostgreSQLDatabase()
{
postgre_ado_net_provider_resolver = new PostgreAdoNetProviderResolver();
postgre_ado_net_provider_resolver.register_db_provider_factory();
postgre_ado_net_provider_resolver.enable_loading_from_merged_assembly();
}

public override void initialize_connections(ConfigurationPropertyHolder configuration_property_holder)
{
if (!string.IsNullOrEmpty(connection_string))
{
var parts = connection_string.Split(';');
foreach (var part in parts)
{
if (string.IsNullOrEmpty(server_name) && (part.to_lower().Contains("server") || part.to_lower().Contains("data source")))
{
server_name = part.Substring(part.IndexOf("=") + 1);
}

if (string.IsNullOrEmpty(database_name) && (part.to_lower().Contains("database") || part.to_lower().Contains("database")))
{
database_name = part.Substring(part.IndexOf("=") + 1);
}
}
}

configuration_property_holder.ConnectionString = connection_string;

set_provider();
if (string.IsNullOrEmpty(admin_connection_string))
{
var builder = new NpgsqlConnection(connection_string);
admin_connection_string = builder.ConnectionString;
}
configuration_property_holder.ConnectionStringAdmin = admin_connection_string;
}

public override void set_provider()
{
provider = "Npgsql";
}

public override string create_database_script()
{
//TODO: Add IF EXISTS condition to CREATE DATABASE
return string.Format(
@"CREATE DATABASE {0};",
database_name);
}

public override string set_recovery_mode_script(bool simple)
{
return string.Empty;
}

public override string restore_database_script(string restore_from_path, string custom_restore_options)
{
throw new NotImplementedException();
}

public override string delete_database_script()
{
//TODO: Add IF EXISTS condition to DROP DATABASE
return string.Format(
@"DROP DATABASE {0};",
database_name);
}

public override void create_or_update_roundhouse_tables()
{
Log.bound_to(this).log_an_info_event_containing("Creating schema [{0}].", roundhouse_schema_name);
run_sql(TableCreationScripts.create_roundhouse_schema(roundhouse_schema_name), ConnectionType.Default);
Log.bound_to(this).log_an_info_event_containing("Creating table [{0}].", version_table_name);
run_sql(TableCreationScripts.create_roundhouse_version_table(roundhouse_schema_name, version_table_name), ConnectionType.Default);
Log.bound_to(this).log_an_info_event_containing("Creating table [{0}].", scripts_run_table_name);
run_sql(TableCreationScripts.create_roundhouse_scripts_run_table(roundhouse_schema_name, version_table_name, scripts_run_table_name),
ConnectionType.Default);
Log.bound_to(this).log_an_info_event_containing("Creating table [{0}].", scripts_run_errors_table_name);
run_sql(TableCreationScripts.create_roundhouse_scripts_run_errors_table(roundhouse_schema_name, scripts_run_errors_table_name),
ConnectionType.Default);
}

public override void run_database_specific_tasks()
{
Log.bound_to(this).log_a_debug_event_containing("PostgreSQL has no database specific tasks. Moving along now...");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using System.Runtime.InteropServices;

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("fe05ae73-d658-47c4-8117-ce0418e2e313")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace roundhouse.databases.postgresql.orm
{
using FluentNHibernate.Mapping;
using infrastructure;
using model;

public class ScriptsRunErrorMapping : ClassMap<ScriptsRunError>
{
public ScriptsRunErrorMapping()
{
HibernateMapping.Schema(ApplicationParameters.CurrentMappings.roundhouse_schema_name);
Table(ApplicationParameters.CurrentMappings.scripts_run_errors_table_name);
Not.LazyLoad();
HibernateMapping.DefaultAccess.Property();
HibernateMapping.DefaultCascade.SaveUpdate();

Id(x => x.id).Column("id").GeneratedBy.Increment().UnsavedValue(0);
Map(x => x.repository_path);
Map(x => x.version).Length(50);
Map(x => x.script_name);
Map(x => x.text_of_script).CustomSqlType("text");
Map(x => x.erroneous_part_of_script).CustomSqlType("text");
Map(x => x.error_message).CustomSqlType("text");

//audit
Map(x => x.entry_date);
Map(x => x.modified_date);
Map(x => x.entered_by).Length(50);
}
}
}
Loading

0 comments on commit d67cd30

Please sign in to comment.