Skip to content

Commit

Permalink
Merge pull request #35 from BiggerNoise/topic/warnononetimescriptchan…
Browse files Browse the repository at this point in the history
…ges_correction

Change  this_script_should_run() logic
  • Loading branch information
BiggerNoise committed Jan 2, 2012
2 parents dbcd894 + 4a604ab commit f333dcf
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions product/roundhouse/migrators/DefaultDatabaseMigrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -300,26 +300,24 @@ private bool this_script_has_changed_since_last_run(string script_name, string s
return !hash_is_same;
}

private bool this_script_should_run(string script_name, string sql_to_run, bool run_this_script_once, bool run_this_script_every_time)
{
if (this_is_an_every_time_script(script_name, run_this_script_every_time))
{
return true;
}

if (this_script_has_run_already(script_name) && run_this_script_once)
{
return false;
}

if (is_running_all_any_time_scripts && !run_this_script_once)
{
return true;
}

return this_script_has_changed_since_last_run(script_name, sql_to_run);
}

private bool this_script_should_run(string script_name, string sql_to_run, bool run_this_script_once, bool run_this_script_every_time)
{
if (this_is_an_every_time_script(script_name, run_this_script_every_time))
{
return true;
}

if (is_running_all_any_time_scripts && !run_this_script_once)
{
return true;
}

return
!run_this_script_once ||
this_script_has_changed_since_last_run(script_name, sql_to_run) ||
!this_script_has_run_already(script_name);
}

public bool this_is_an_environment_file_and_its_in_the_right_environment(string script_name, Environment environment)
{
Log.bound_to(this).log_a_debug_event_containing("Checking to see if {0} is an environment file. We are in the {1} environment.", script_name, environment.name);
Expand Down

6 comments on commit f333dcf

@mpareja
Copy link
Member

@mpareja mpareja commented on f333dcf Jan 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this change has broken the ability to skip already run stored procedures...

@mpareja
Copy link
Member

@mpareja mpareja commented on f333dcf Jan 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about something like this?

private bool this_script_should_run(string script_name, string sql_to_run, bool run_this_script_once, bool run_this_script_every_time)
{
    if (this_is_an_every_time_script(script_name, run_this_script_every_time))
    {
        return true;
    }

    if (is_running_all_any_time_scripts && !run_this_script_once)
    {
        return true;
    }

    if (this_script_has_run_already(script_name)
        && !this_script_has_changed_since_last_run(script_name, sql_to_run))
    {
        return false;
    }
    return true;
}

Update: slightly modified to make it more clear that we won't rerun an already run script that has not changed.

@ferventcoder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Mario. What do you think Andy?

@ferventcoder
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#42

@BiggerNoise
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks good, thanks for the fix.

@mpareja
Copy link
Member

@mpareja mpareja commented on f333dcf Jan 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. Thanks to you folks for working on RoundhousE which does exactly what we need it to do!

Please sign in to comment.