/Aurora/DataManager/Migration/Migrators/Directory/DirectoryMigrator_11.cs

https://bitbucket.org/VirtualReality/software-testing · C# · 175 lines · 138 code · 10 blank · 27 comment · 0 complexity · 2b365f4e19fe7980394a25fb1a72478a MD5 · raw file

  1. /*
  2. * Copyright (c) Contributors, http://aurora-sim.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the Aurora-Sim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections.Generic;
  29. using Aurora.Framework;
  30. using Aurora.Framework.Utilities;
  31. namespace Aurora.DataManager.Migration.Migrators
  32. {
  33. public class DirectoryMigrator_11 : Migrator
  34. {
  35. public DirectoryMigrator_11()
  36. {
  37. Version = new Version(0, 0, 11);
  38. MigrationName = "Directory";
  39. schema = new List<SchemaDefinition>();
  40. AddSchema("searchparcel", ColDefs(
  41. ColDef("RegionID", ColumnTypes.Char36),
  42. ColDef("ParcelID", ColumnTypes.String50),
  43. ColDef("LocalID", ColumnTypes.String50),
  44. ColDef("LandingX", ColumnTypes.String50),
  45. ColDef("LandingY", ColumnTypes.String50),
  46. ColDef("LandingZ", ColumnTypes.String50),
  47. ColDef("Name", ColumnTypes.String50),
  48. ColDef("Description", ColumnTypes.String255),
  49. ColDef("Flags", ColumnTypes.String50),
  50. ColDef("Dwell", ColumnTypes.String50),
  51. ColDef("InfoUUID", ColumnTypes.String50),
  52. ColDef("ForSale", ColumnTypes.String50),
  53. ColDef("SalePrice", ColumnTypes.String50),
  54. ColDef("Auction", ColumnTypes.String50),
  55. ColDef("Area", ColumnTypes.String50),
  56. ColDef("EstateID", ColumnTypes.String50),
  57. ColDef("Maturity", ColumnTypes.String50),
  58. ColDef("OwnerID", ColumnTypes.String50),
  59. ColDef("GroupID", ColumnTypes.String50),
  60. ColDef("ShowInSearch", ColumnTypes.String50),
  61. ColDef("SnapshotID", ColumnTypes.String50),
  62. ColDef("Bitmap", ColumnTypes.LongText),
  63. ColDef("Category", ColumnTypes.String50),
  64. new ColumnDefinition
  65. {
  66. Name = "ScopeID",
  67. Type = new ColumnTypeDef
  68. {
  69. Type = ColumnType.UUID,
  70. defaultValue = OpenMetaverse.UUID.Zero.ToString()
  71. }
  72. }
  73. ), IndexDefs(
  74. IndexDef(new string[1] {"ParcelID"}, IndexType.Primary),
  75. IndexDef(new string[4] {"RegionID", "OwnerID", "Flags", "Category"},
  76. IndexType.Index),
  77. IndexDef(new string[2] {"RegionID", "Name"}, IndexType.Index),
  78. IndexDef(new string[1] {"OwnerID"}, IndexType.Index),
  79. // IndexDef(new string[4]{ "Name", "Description", "ShowInSearch", "Category" }, IndexType.Index),
  80. IndexDef(new string[3] {"ForSale", "SalePrice", "Area"}, IndexType.Index)
  81. ));
  82. AddSchema("asevents", ColDefs(
  83. ColDef("EID", ColumnTypes.Integer11),
  84. new ColumnDefinition
  85. {
  86. Name = "creator",
  87. Type = new ColumnTypeDef
  88. {
  89. Type = ColumnType.UUID
  90. }
  91. },
  92. new ColumnDefinition
  93. {
  94. Name = "region",
  95. Type = new ColumnTypeDef
  96. {
  97. Type = ColumnType.UUID
  98. }
  99. },
  100. new ColumnDefinition
  101. {
  102. Name = "parcel",
  103. Type = new ColumnTypeDef
  104. {
  105. Type = ColumnType.UUID
  106. }
  107. },
  108. ColDef("date", ColumnTypes.DateTime),
  109. ColDef("cover", ColumnTypes.Integer11),
  110. ColDef("maturity", ColumnTypes.TinyInt4),
  111. ColDef("flags", ColumnTypes.Integer11),
  112. ColDef("duration", ColumnTypes.Integer11),
  113. ColDef("localPosX", ColumnTypes.Float),
  114. ColDef("localPosY", ColumnTypes.Float),
  115. ColDef("localPosZ", ColumnTypes.Float),
  116. ColDef("name", ColumnTypes.String50),
  117. ColDef("description", ColumnTypes.String255),
  118. ColDef("category", ColumnTypes.String50),
  119. new ColumnDefinition
  120. {
  121. Name = "scopeID",
  122. Type = new ColumnTypeDef
  123. {
  124. Type = ColumnType.UUID,
  125. defaultValue = OpenMetaverse.UUID.Zero.ToString()
  126. }
  127. }
  128. ), IndexDefs(
  129. IndexDef(new string[1] {"EID"}, IndexType.Primary),
  130. IndexDef(new string[1] {"name"}, IndexType.Index),
  131. IndexDef(new string[2] {"date", "flags"}, IndexType.Index),
  132. IndexDef(new string[2] {"region", "maturity"}, IndexType.Index)
  133. ));
  134. AddSchema("event_notifications", ColDefs(
  135. new ColumnDefinition
  136. {
  137. Name = "UserID",
  138. Type = new ColumnTypeDef
  139. {
  140. Type = ColumnType.UUID
  141. }
  142. },
  143. ColDef("EventID", ColumnTypes.Integer11)
  144. ), IndexDefs(
  145. IndexDef(new string[1] {"UserID"}, IndexType.Primary)
  146. ));
  147. }
  148. protected override void DoCreateDefaults(IDataConnector genericData)
  149. {
  150. EnsureAllTablesInSchemaExist(genericData);
  151. }
  152. protected override bool DoValidate(IDataConnector genericData)
  153. {
  154. return TestThatAllTablesValidate(genericData);
  155. }
  156. protected override void DoMigrate(IDataConnector genericData)
  157. {
  158. DoCreateDefaults(genericData);
  159. }
  160. protected override void DoPrepareRestorePoint(IDataConnector genericData)
  161. {
  162. CopyAllTablesToTempVersions(genericData);
  163. }
  164. }
  165. }