|
| 1 | +using System.Threading.Tasks; |
| 2 | +using grate.Configuration; |
1 | 3 | using grate.unittests.TestInfrastructure;
|
2 | 4 | using NUnit.Framework;
|
3 | 5 |
|
| 6 | +using static grate.Configuration.KnownFolderKeys; |
| 7 | + |
4 | 8 | namespace grate.unittests.SqlServer.Running_MigrationScripts;
|
5 | 9 |
|
6 | 10 | [TestFixture]
|
7 | 11 | [Category("SqlServer")]
|
| 12 | +[NonParallelizable] |
8 | 13 | // ReSharper disable once InconsistentNaming
|
9 | 14 | public class Versioning_The_Database: Generic.Running_MigrationScripts.Versioning_The_Database
|
10 | 15 | {
|
11 | 16 | protected override IGrateTestContext Context => GrateTestContext.SqlServer;
|
| 17 | + |
| 18 | + |
| 19 | + [Test] |
| 20 | + public async Task Bug230_Uses_Server_Casing_Rules_For_Schema() |
| 21 | + { |
| 22 | + //for bug #230 - when targeting an existing schema use the servers casing rules, not .Net's |
| 23 | + var db = TestConfig.RandomDatabase(); |
| 24 | + var parent = CreateRandomTempDirectory(); |
| 25 | + var knownFolders = FoldersConfiguration.Default(null); |
| 26 | + |
| 27 | + CreateDummySql(parent, knownFolders[Sprocs]); // make sure there's something that could be logged... |
| 28 | + |
| 29 | + await using (var migrator = Context.GetMigrator(db, parent, knownFolders)) |
| 30 | + { |
| 31 | + await migrator.Migrate(); |
| 32 | + Assert.True(await migrator.DbMigrator.Database.VersionTableExists()); // we migrated into the `grate` schema. |
| 33 | + } |
| 34 | + |
| 35 | + // Now we'll run again with the same name but different cased schema |
| 36 | + var grateConfig = Context.GetConfiguration(db, parent, knownFolders) with |
| 37 | + { |
| 38 | + SchemaName = "GRATE" |
| 39 | + }; |
| 40 | + |
| 41 | + await using (var migrator = Context.GetMigrator(grateConfig)) |
| 42 | + { |
| 43 | + await migrator.Migrate(); // should either reuse the existing schema if a case-insensitive server, or create a new second schema for use if case-sensitive. |
| 44 | + Assert.True(await migrator.DbMigrator.Database.VersionTableExists()); // we migrated into the `GRATE` schema, which may be the same as 'grate' depending on server settings. |
| 45 | + } |
| 46 | + } |
12 | 47 | }
|
0 commit comments