lib/physique/task_builders/fluent_migrator.rb in physique-0.3.8 vs lib/physique/task_builders/fluent_migrator.rb in physique-0.3.9

- old
+ new

@@ -84,10 +84,11 @@ private def expand_project_config(db) project = Albacore::Project.new(db.project_file) + db[:project_namespace] = project.namespace db[:project_dir] = project.proj_path_base db[:scripts_dir] = "#{project.proj_path_base}/#{db.scripts_dir}" build_conf = solution.compile.configuration db[:output_path] = project.output_path build_conf @@ -132,11 +133,14 @@ end def add_migrator_tasks(db) require 'physique/tasks/fluent_migrator' - build :compile_db do |b| + # Compile just the database project. + # This task is registered as a dependency of the migration + # tasks to ensure the latest code is available. + build :compile_db => [ :restore ] do |b| b.target = [ 'Build' ] b.file = db.project_file b.prop 'Configuration', solution.compile.configuration b.logging = solution.compile.logging end @@ -205,11 +209,11 @@ end # Save the new migration file version = migration_version migration_file_name = "#{version}_#{name}.cs" - migration_content = migration_template(version, name, description, db.project) + migration_content = migration_template(version, name, description, db.project_namespace) save_file migration_content, "#{db.project_dir}/Migrations/#{migration_file_name}" # Add the new migration file to the project Albacore::Project.new(db.project_file).tap do |p| p.add_compile_node :Migrations, migration_file_name @@ -220,15 +224,15 @@ def migration_version Time.now.utc.strftime('%Y%m%d%H%M%S') end - def migration_template(version, name, description, project_name) + def migration_template(version, name, description, project_namespace) description = ", \"#{description}\"" unless description.nil? return <<TEMPLATE using FluentMigrator; -namespace #{project_name}.Migrations +namespace #{project_namespace}.Migrations { [Migration(#{version}#{description})] public class #{name} : Migration { public override void Up() \ No newline at end of file