Hi Helen,
I would typically not drop / recreate things everytime - usually you'd have your create script which is run once. To make changes you would then write an alter script rather than drop / recreate to apply the change. The idea is if there are no changes to an object in the database then it won't be touched. I have needed to run scripts in the past in every deployment but i have done this manually in the console application either before or after dbup does its thing. For example a script to check if the database exists and if not, create it. A script to ensure a user exists and if not create it..
Does this help?
Kind Regards
Darrell
--
You received this message because you are subscribed to the Google Groups "DbUp Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dbup-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/// <summary>
/// This journal tells DbUp to always run scripts from Programmability folder
/// </summary>
/// <remarks>
/// The trick is following:
/// - we tell DbUp in GetExecutedScripts that no script from Programmability has ever been run
/// - (so DbUp runs them every time)
/// - we don't change behaviour of "StoreExecutedScript", so each script run is still stored in Journal
/// </remarks>
public class ProgrammabilityReRunningJournal : IJournal
{
private readonly IJournal _innerJournal;
public ProgrammabilityReRunningJournal(IJournal innerJournal)
{
_innerJournal = innerJournal;
}
public string[] GetExecutedScripts()
{
return _innerJournal.GetExecutedScripts().Where(x => !x.Contains("Programmability")).ToArray();
}
public void StoreExecutedScript(SqlScript script)
{
_innerJournal.StoreExecutedScript(script);
}
}
public static UpgradeEngineBuilder WithProgrammabilityReRunningJournal(this UpgradeEngineBuilder builder, string schema, string table)
{
builder.Configure(c => c.Journal = new ProgrammabilityReRunningJournal(new SqlTableJournal(() => c.ConnectionManager, () => c.Log, schema, table)));
return builder;
}
Cheers,
Pawel