Testing schema updates - any recommendations?

25 views
Skip to first unread message

Alex Norcliffe

unread,
Mar 22, 2012, 9:23:59 AM3/22/12
to Nhusers
Hi all

I'd like to write a test that confirms a schema change to an existing database succeeds (namely, adding some indexes to existing tables and a new table) after running SchemaUpdate.

Does anyone have any learnings to share with this scenario?

Best,
Alex

Sent from my Windows Phone

Mark Cranness

unread,
Apr 4, 2012, 9:17:04 PM4/4/12
to nhu...@googlegroups.com
On 23 March 2012 02:23, Alex Norcliffe <emailmes...@googlemail.com> wrote:
> I'd like to write a test that confirms a schema change to an existing
> database succeeds (namely, adding some indexes to existing tables and a new
> table) after running SchemaUpdate.

My experience is that adding indexes to existing tables by modifying
the in-memory NHibernate config, then running SchemaUpdate does not
result in any SQL DDL being run to add the indexes to the database.

For new tables, yes, DDL is run to create the table and add indexes.

It may be different if the config is set with Fluent Hibernate or
ActiveRecord or modified NHibernate config files, but I don't know; I
suspect that would also not add new indexes for existing tables.

Fabio Maulo

unread,
Apr 7, 2012, 6:45:50 PM4/7/12
to nhu...@googlegroups.com
Run SchemaUpdate again and check that it does not generate the script:

var configuration = CreateConfiguration();
new SchemaUpdate(configuration).Execute(false, true); 
var sb = new StringBuilder(500);
new SchemaUpdate(configuration).Execute(s => sb.Append(s), false);
sb.ToString().Should().Be.Empty();
Reply all
Reply to author
Forward
0 new messages