|
| 1 | +// Copyright (C) 2021 Xtensive LLC. |
| 2 | +// This code is distributed under MIT license terms. |
| 3 | +// See the License.txt file in the project root for more information. |
| 4 | + |
1 | 5 | using System;
|
2 | 6 | using System.Collections.Generic;
|
3 | 7 | using System.Linq;
|
4 | 8 | using System.Text;
|
5 | 9 | using System.Threading.Tasks;
|
6 | 10 | using NUnit.Framework;
|
7 | 11 | using Xtensive.Core;
|
| 12 | +using Xtensive.Collections; |
8 | 13 | using Xtensive.Modelling.Actions;
|
9 | 14 | using Xtensive.Modelling.Comparison;
|
10 | 15 | using Xtensive.Orm.Configuration;
|
11 | 16 | using Xtensive.Orm.Model;
|
12 | 17 | using Xtensive.Orm.Services;
|
| 18 | +using Xtensive.Orm.Upgrade; |
13 | 19 | using OneToOneStructure = Xtensive.Orm.Tests.Upgrade.UpgradeToNewHierarchyThatInheritsStructureTestModel.OneToOneStructure;
|
14 | 20 | using NewColumnWithinTable = Xtensive.Orm.Tests.Upgrade.UpgradeToNewHierarchyThatInheritsStructureTestModel.NewColumnWithinTable;
|
15 | 21 | using RemoveColumnWithinTable = Xtensive.Orm.Tests.Upgrade.UpgradeToNewHierarchyThatInheritsStructureTestModel.RemoveColumnWithinTable;
|
16 | 22 | using NewTable = Xtensive.Orm.Tests.Upgrade.UpgradeToNewHierarchyThatInheritsStructureTestModel.NewTable;
|
17 | 23 | using RemoveTable = Xtensive.Orm.Tests.Upgrade.UpgradeToNewHierarchyThatInheritsStructureTestModel.RemoveTable;
|
18 | 24 |
|
19 |
| -using ConnectorType = Xtensive.Orm.Tests.Upgrade.UpgradeToNewHierarchyThatInheritsStructureTestModel.ConnectorType; |
20 |
| -using Xtensive.Orm.Upgrade; |
21 |
| -using Xtensive.Collections; |
22 |
| - |
23 | 25 | namespace Xtensive.Orm.Tests.Upgrade
|
24 | 26 | {
|
25 | 27 | [TestFixture]
|
@@ -753,90 +755,6 @@ private bool CheckExistance(TypeInfo rootType, Session session)
|
753 | 755 |
|
754 | 756 | namespace Xtensive.Orm.Tests.Upgrade.UpgradeToNewHierarchyThatInheritsStructureTestModel
|
755 | 757 | {
|
756 |
| - namespace ConnectorType |
757 |
| - { |
758 |
| - namespace Before |
759 |
| - { |
760 |
| - [HierarchyRoot] |
761 |
| - public class Author : Entity |
762 |
| - { |
763 |
| - [Field, Key] |
764 |
| - public int Id { get; private set; } |
765 |
| - |
766 |
| - [Field] |
767 |
| - public string Name { get; set; } |
768 |
| - |
769 |
| - [Field] |
770 |
| - [Association(PairTo = nameof(Book.Authors))] |
771 |
| - public EntitySet<Book> Books { get; private set; } |
772 |
| - } |
773 |
| - |
774 |
| - [HierarchyRoot] |
775 |
| - public class Book : Entity |
776 |
| - { |
777 |
| - [Field, Key] |
778 |
| - public int Id { get; private set; } |
779 |
| - |
780 |
| - [Field] |
781 |
| - public string Name { get; set; } |
782 |
| - |
783 |
| - [Field] |
784 |
| - public EntitySet<Author> Authors { get; private set; } |
785 |
| - } |
786 |
| - } |
787 |
| - |
788 |
| - namespace After |
789 |
| - { |
790 |
| - [HierarchyRoot] |
791 |
| - public class Author : Entity |
792 |
| - { |
793 |
| - [Field, Key] |
794 |
| - public int Id { get; private set; } |
795 |
| - |
796 |
| - [Field] |
797 |
| - public string Name { get; set; } |
798 |
| - |
799 |
| - [Field] |
800 |
| - [Association(PairTo = nameof(Book.Authors))] |
801 |
| - public EntitySet<Book> Books { get; private set; } |
802 |
| - } |
803 |
| - |
804 |
| - [HierarchyRoot] |
805 |
| - [Index(nameof(NewUniqueName), Unique = true)] |
806 |
| - public class Book : Entity |
807 |
| - { |
808 |
| - [Field, Key] |
809 |
| - public int Id { get; private set; } |
810 |
| - |
811 |
| - [Field] |
812 |
| - public string Name { get; set; } |
813 |
| - |
814 |
| - [Field] |
815 |
| - public string NewUniqueName { get; set; } |
816 |
| - |
817 |
| - [Field] |
818 |
| - public EntitySet<Author> Authors { get; private set; } |
819 |
| - } |
820 |
| - |
821 |
| - public class CustomUpgradeHandler : UpgradeHandler |
822 |
| - { |
823 |
| - public override bool CanUpgradeFrom(string oldVersion) => true; |
824 |
| - |
825 |
| - public override void OnUpgrade() |
826 |
| - { |
827 |
| - base.OnUpgrade(); |
828 |
| - |
829 |
| - var session = UpgradeContext.Session; |
830 |
| - foreach (var item in session.Query.All<Book>()) { |
831 |
| - item.NewUniqueName = Guid.NewGuid().ToString(); |
832 |
| - } |
833 |
| - session.SaveChanges(); |
834 |
| - } |
835 |
| - } |
836 |
| - } |
837 |
| - } |
838 |
| - |
839 |
| - |
840 | 758 | namespace OneToOneStructure
|
841 | 759 | {
|
842 | 760 | namespace Before
|
|
0 commit comments