
:VERSION 51		#---------------------

BEGIN;

CREATE TABLE IF NOT EXISTS `prims` (
  `CreationDate` int(11) DEFAULT NULL,
  `Name` varchar(255) DEFAULT NULL,
  `Text` varchar(255) DEFAULT NULL,
  `Description` varchar(255) DEFAULT NULL,
  `SitName` varchar(255) DEFAULT NULL,
  `TouchName` varchar(255) DEFAULT NULL,
  `ObjectFlags` int(11) DEFAULT NULL,
  `OwnerMask` int(11) DEFAULT NULL,
  `NextOwnerMask` int(11) DEFAULT NULL,
  `GroupMask` int(11) DEFAULT NULL,
  `EveryoneMask` int(11) DEFAULT NULL,
  `BaseMask` int(11) DEFAULT NULL,
  `PositionX` double DEFAULT NULL,
  `PositionY` double DEFAULT NULL,
  `PositionZ` double DEFAULT NULL,
  `GroupPositionX` double DEFAULT NULL,
  `GroupPositionY` double DEFAULT NULL,
  `GroupPositionZ` double DEFAULT NULL,
  `VelocityX` double DEFAULT NULL,
  `VelocityY` double DEFAULT NULL,
  `VelocityZ` double DEFAULT NULL,
  `AngularVelocityX` double DEFAULT NULL,
  `AngularVelocityY` double DEFAULT NULL,
  `AngularVelocityZ` double DEFAULT NULL,
  `AccelerationX` double DEFAULT NULL,
  `AccelerationY` double DEFAULT NULL,
  `AccelerationZ` double DEFAULT NULL,
  `RotationX` double DEFAULT NULL,
  `RotationY` double DEFAULT NULL,
  `RotationZ` double DEFAULT NULL,
  `RotationW` double DEFAULT NULL,
  `SitTargetOffsetX` double DEFAULT NULL,
  `SitTargetOffsetY` double DEFAULT NULL,
  `SitTargetOffsetZ` double DEFAULT NULL,
  `SitTargetOrientW` double DEFAULT NULL,
  `SitTargetOrientX` double DEFAULT NULL,
  `SitTargetOrientY` double DEFAULT NULL,
  `SitTargetOrientZ` double DEFAULT NULL,
  `UUID` char(36) NOT NULL DEFAULT '',
  `RegionUUID` char(36) DEFAULT NULL,
  `CreatorID` varchar(255) NOT NULL DEFAULT '',
  `OwnerID` char(36) DEFAULT NULL,
  `GroupID` char(36) DEFAULT NULL,
  `LastOwnerID` char(36) DEFAULT NULL,
  `SceneGroupID` char(36) DEFAULT NULL,
  `PayPrice` int(11) NOT NULL DEFAULT '0',
  `PayButton1` int(11) NOT NULL DEFAULT '0',
  `PayButton2` int(11) NOT NULL DEFAULT '0',
  `PayButton3` int(11) NOT NULL DEFAULT '0',
  `PayButton4` int(11) NOT NULL DEFAULT '0',
  `LoopedSound` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
  `LoopedSoundGain` double NOT NULL DEFAULT '0',
  `TextureAnimation` blob,
  `OmegaX` double NOT NULL DEFAULT '0',
  `OmegaY` double NOT NULL DEFAULT '0',
  `OmegaZ` double NOT NULL DEFAULT '0',
  `CameraEyeOffsetX` double NOT NULL DEFAULT '0',
  `CameraEyeOffsetY` double NOT NULL DEFAULT '0',
  `CameraEyeOffsetZ` double NOT NULL DEFAULT '0',
  `CameraAtOffsetX` double NOT NULL DEFAULT '0',
  `CameraAtOffsetY` double NOT NULL DEFAULT '0',
  `CameraAtOffsetZ` double NOT NULL DEFAULT '0',
  `ForceMouselook` tinyint(4) NOT NULL DEFAULT '0',
  `ScriptAccessPin` int(11) NOT NULL DEFAULT '0',
  `AllowedDrop` tinyint(4) NOT NULL DEFAULT '0',
  `DieAtEdge` tinyint(4) NOT NULL DEFAULT '0',
  `SalePrice` int(11) NOT NULL DEFAULT '10',
  `SaleType` tinyint(4) NOT NULL DEFAULT '0',
  `ColorR` int(11) NOT NULL DEFAULT '0',
  `ColorG` int(11) NOT NULL DEFAULT '0',
  `ColorB` int(11) NOT NULL DEFAULT '0',
  `ColorA` int(11) NOT NULL DEFAULT '0',
  `ParticleSystem` blob,
  `ClickAction` tinyint(4) NOT NULL DEFAULT '0',
  `Material` tinyint(4) NOT NULL DEFAULT '3',
  `CollisionSound` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
  `CollisionSoundVolume` double NOT NULL DEFAULT '0',
  `LinkNumber` int(11) NOT NULL DEFAULT '0',
  `PassTouches` tinyint(4) NOT NULL DEFAULT '0',
  `MediaURL` varchar(255) DEFAULT NULL,
  `DynAttrs` text,
  `PhysicsShapeType` tinyint(4) NOT NULL DEFAULT '0',
  `Density` double NOT NULL DEFAULT '1000',
  `GravityModifier` double NOT NULL DEFAULT '1',
  `Friction` double NOT NULL DEFAULT '0.6',
  `Restitution` double NOT NULL DEFAULT '0.5',
  `KeyframeMotion` blob,
  `AttachedPosX` double DEFAULT '0',
  `AttachedPosY` double DEFAULT '0',
  `AttachedPosZ` double DEFAULT '0',
  PRIMARY KEY (`UUID`),
  KEY `prims_regionuuid` (`RegionUUID`),
  KEY `prims_scenegroupid` (`SceneGroupID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `primshapes` (
  `Shape` int(11) DEFAULT NULL,
  `ScaleX` double NOT NULL DEFAULT '0',
  `ScaleY` double NOT NULL DEFAULT '0',
  `ScaleZ` double NOT NULL DEFAULT '0',
  `PCode` int(11) DEFAULT NULL,
  `PathBegin` int(11) DEFAULT NULL,
  `PathEnd` int(11) DEFAULT NULL,
  `PathScaleX` int(11) DEFAULT NULL,
  `PathScaleY` int(11) DEFAULT NULL,
  `PathShearX` int(11) DEFAULT NULL,
  `PathShearY` int(11) DEFAULT NULL,
  `PathSkew` int(11) DEFAULT NULL,
  `PathCurve` int(11) DEFAULT NULL,
  `PathRadiusOffset` int(11) DEFAULT NULL,
  `PathRevolutions` int(11) DEFAULT NULL,
  `PathTaperX` int(11) DEFAULT NULL,
  `PathTaperY` int(11) DEFAULT NULL,
  `PathTwist` int(11) DEFAULT NULL,
  `PathTwistBegin` int(11) DEFAULT NULL,
  `ProfileBegin` int(11) DEFAULT NULL,
  `ProfileEnd` int(11) DEFAULT NULL,
  `ProfileCurve` int(11) DEFAULT NULL,
  `ProfileHollow` int(11) DEFAULT NULL,
  `State` int(11) DEFAULT NULL,
  `Texture` longblob,
  `ExtraParams` longblob,
  `UUID` char(36) NOT NULL DEFAULT '',
  `Media` text,
  `LastAttachPoint` int(4) NOT NULL DEFAULT '0',
  PRIMARY KEY (`UUID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `primitems` (
  `invType` int(11) DEFAULT NULL,
  `assetType` int(11) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `creationDate` bigint(20) DEFAULT NULL,
  `nextPermissions` int(11) DEFAULT NULL,
  `currentPermissions` int(11) DEFAULT NULL,
  `basePermissions` int(11) DEFAULT NULL,
  `everyonePermissions` int(11) DEFAULT NULL,
  `groupPermissions` int(11) DEFAULT NULL,
  `flags` int(11) NOT NULL DEFAULT '0',
  `itemID` char(36) NOT NULL DEFAULT '',
  `primID` char(36) DEFAULT NULL,
  `assetID` char(36) DEFAULT NULL,
  `parentFolderID` char(36) DEFAULT NULL,
  `CreatorID` varchar(255) NOT NULL DEFAULT '',
  `ownerID` char(36) DEFAULT NULL,
  `groupID` char(36) DEFAULT NULL,
  `lastOwnerID` char(36) DEFAULT NULL,
  PRIMARY KEY (`itemID`),
  KEY `primitems_primid` (`primID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `terrain` (
  `RegionUUID` varchar(255) DEFAULT NULL,
  `Revision` int(11) DEFAULT NULL,
  `Heightfield` longblob
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `land` (
  `UUID` varchar(255) NOT NULL,
  `RegionUUID` varchar(255) DEFAULT NULL,
  `LocalLandID` int(11) DEFAULT NULL,
  `Bitmap` longblob,
  `Name` varchar(255) DEFAULT NULL,
  `Description` varchar(255) DEFAULT NULL,
  `OwnerUUID` varchar(255) DEFAULT NULL,
  `IsGroupOwned` int(11) DEFAULT NULL,
  `Area` int(11) DEFAULT NULL,
  `AuctionID` int(11) DEFAULT NULL,
  `Category` int(11) DEFAULT NULL,
  `ClaimDate` int(11) DEFAULT NULL,
  `ClaimPrice` int(11) DEFAULT NULL,
  `GroupUUID` varchar(255) DEFAULT NULL,
  `SalePrice` int(11) DEFAULT NULL,
  `LandStatus` int(11) DEFAULT NULL,
  `LandFlags` int(10) unsigned DEFAULT NULL,
  `LandingType` int(11) DEFAULT NULL,
  `MediaAutoScale` int(11) DEFAULT NULL,
  `MediaTextureUUID` varchar(255) DEFAULT NULL,
  `MediaURL` varchar(255) DEFAULT NULL,
  `MusicURL` varchar(255) DEFAULT NULL,
  `PassHours` float DEFAULT NULL,
  `PassPrice` int(11) DEFAULT NULL,
  `SnapshotUUID` varchar(255) DEFAULT NULL,
  `UserLocationX` float DEFAULT NULL,
  `UserLocationY` float DEFAULT NULL,
  `UserLocationZ` float DEFAULT NULL,
  `UserLookAtX` float DEFAULT NULL,
  `UserLookAtY` float DEFAULT NULL,
  `UserLookAtZ` float DEFAULT NULL,
  `AuthbuyerID` varchar(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
  `OtherCleanTime` int(11) NOT NULL DEFAULT '0',
  `Dwell` int(11) NOT NULL DEFAULT '0',
  `MediaType` varchar(32) NOT NULL DEFAULT 'none/none',
  `MediaDescription` varchar(255) NOT NULL DEFAULT '',
  `MediaSize` varchar(16) NOT NULL DEFAULT '0,0',
  `MediaLoop` tinyint(1) NOT NULL DEFAULT '0',
  `ObscureMusic` tinyint(1) NOT NULL DEFAULT '0',
  `ObscureMedia` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`UUID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `landaccesslist` (
  `LandUUID` varchar(255) DEFAULT NULL,
  `AccessUUID` varchar(255) DEFAULT NULL,
  `Flags` int(11) DEFAULT NULL,
  `Expires` int(11) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `regionban` (
  `regionUUID` varchar(36) NOT NULL,
  `bannedUUID` varchar(36) NOT NULL,
  `bannedIp` varchar(16) NOT NULL,
  `bannedIpHostMask` varchar(16) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `regionsettings` (
  `regionUUID` char(36) NOT NULL,
  `block_terraform` int(11) NOT NULL,
  `block_fly` int(11) NOT NULL,
  `allow_damage` int(11) NOT NULL,
  `restrict_pushing` int(11) NOT NULL,
  `allow_land_resell` int(11) NOT NULL,
  `allow_land_join_divide` int(11) NOT NULL,
  `block_show_in_search` int(11) NOT NULL,
  `agent_limit` int(11) NOT NULL,
  `object_bonus` double NOT NULL,
  `maturity` int(11) NOT NULL,
  `disable_scripts` int(11) NOT NULL,
  `disable_collisions` int(11) NOT NULL,
  `disable_physics` int(11) NOT NULL,
  `terrain_texture_1` char(36) NOT NULL,
  `terrain_texture_2` char(36) NOT NULL,
  `terrain_texture_3` char(36) NOT NULL,
  `terrain_texture_4` char(36) NOT NULL,
  `elevation_1_nw` double NOT NULL,
  `elevation_2_nw` double NOT NULL,
  `elevation_1_ne` double NOT NULL,
  `elevation_2_ne` double NOT NULL,
  `elevation_1_se` double NOT NULL,
  `elevation_2_se` double NOT NULL,
  `elevation_1_sw` double NOT NULL,
  `elevation_2_sw` double NOT NULL,
  `water_height` double NOT NULL,
  `terrain_raise_limit` double NOT NULL,
  `terrain_lower_limit` double NOT NULL,
  `use_estate_sun` int(11) NOT NULL,
  `fixed_sun` int(11) NOT NULL,
  `sun_position` double NOT NULL,
  `covenant` char(36) DEFAULT NULL,
  `Sandbox` tinyint(4) NOT NULL,
  `sunvectorx` double NOT NULL DEFAULT '0',
  `sunvectory` double NOT NULL DEFAULT '0',
  `sunvectorz` double NOT NULL DEFAULT '0',
  `loaded_creation_id` varchar(64) DEFAULT NULL,
  `loaded_creation_datetime` int(10) unsigned NOT NULL DEFAULT '0',
  `map_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
  `TelehubObject` varchar(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
  `parcel_tile_ID` char(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
  `covenant_datetime` int(10) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`regionUUID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `regionwindlight` (
  `region_id` varchar(36) NOT NULL DEFAULT '000000-0000-0000-0000-000000000000',
  `water_color_r` float(9,6) unsigned NOT NULL DEFAULT '4.000000',
  `water_color_g` float(9,6) unsigned NOT NULL DEFAULT '38.000000',
  `water_color_b` float(9,6) unsigned NOT NULL DEFAULT '64.000000',
  `water_fog_density_exponent` float(3,1) unsigned NOT NULL DEFAULT '4.0',
  `underwater_fog_modifier` float(3,2) unsigned NOT NULL DEFAULT '0.25',
  `reflection_wavelet_scale_1` float(3,1) unsigned NOT NULL DEFAULT '2.0',
  `reflection_wavelet_scale_2` float(3,1) unsigned NOT NULL DEFAULT '2.0',
  `reflection_wavelet_scale_3` float(3,1) unsigned NOT NULL DEFAULT '2.0',
  `fresnel_scale` float(3,2) unsigned NOT NULL DEFAULT '0.40',
  `fresnel_offset` float(3,2) unsigned NOT NULL DEFAULT '0.50',
  `refract_scale_above` float(3,2) unsigned NOT NULL DEFAULT '0.03',
  `refract_scale_below` float(3,2) unsigned NOT NULL DEFAULT '0.20',
  `blur_multiplier` float(4,3) unsigned NOT NULL DEFAULT '0.040',
  `big_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.05',
  `big_wave_direction_y` float(3,2) NOT NULL DEFAULT '-0.42',
  `little_wave_direction_x` float(3,2) NOT NULL DEFAULT '1.11',
  `little_wave_direction_y` float(3,2) NOT NULL DEFAULT '-1.16',
  `normal_map_texture` varchar(36) NOT NULL DEFAULT '822ded49-9a6c-f61c-cb89-6df54f42cdf4',
  `horizon_r` float(3,2) unsigned NOT NULL DEFAULT '0.25',
  `horizon_g` float(3,2) unsigned NOT NULL DEFAULT '0.25',
  `horizon_b` float(3,2) unsigned NOT NULL DEFAULT '0.32',
  `horizon_i` float(3,2) unsigned NOT NULL DEFAULT '0.32',
  `haze_horizon` float(3,2) unsigned NOT NULL DEFAULT '0.19',
  `blue_density_r` float(3,2) unsigned NOT NULL DEFAULT '0.12',
  `blue_density_g` float(3,2) unsigned NOT NULL DEFAULT '0.22',
  `blue_density_b` float(3,2) unsigned NOT NULL DEFAULT '0.38',
  `blue_density_i` float(3,2) unsigned NOT NULL DEFAULT '0.38',
  `haze_density` float(3,2) unsigned NOT NULL DEFAULT '0.70',
  `density_multiplier` float(3,2) unsigned NOT NULL DEFAULT '0.18',
  `distance_multiplier` float(4,1) unsigned NOT NULL DEFAULT '0.8',
  `max_altitude` int(4) unsigned NOT NULL DEFAULT '1605',
  `sun_moon_color_r` float(3,2) unsigned NOT NULL DEFAULT '0.24',
  `sun_moon_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.26',
  `sun_moon_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.30',
  `sun_moon_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.30',
  `sun_moon_position` float(4,3) unsigned NOT NULL DEFAULT '0.317',
  `ambient_r` float(3,2) unsigned NOT NULL DEFAULT '0.35',
  `ambient_g` float(3,2) unsigned NOT NULL DEFAULT '0.35',
  `ambient_b` float(3,2) unsigned NOT NULL DEFAULT '0.35',
  `ambient_i` float(3,2) unsigned NOT NULL DEFAULT '0.35',
  `east_angle` float(3,2) unsigned NOT NULL DEFAULT '0.00',
  `sun_glow_focus` float(3,2) unsigned NOT NULL DEFAULT '0.10',
  `sun_glow_size` float(3,2) unsigned NOT NULL DEFAULT '1.75',
  `scene_gamma` float(4,2) unsigned NOT NULL DEFAULT '1.00',
  `star_brightness` float(3,2) unsigned NOT NULL DEFAULT '0.00',
  `cloud_color_r` float(3,2) unsigned NOT NULL DEFAULT '0.41',
  `cloud_color_g` float(3,2) unsigned NOT NULL DEFAULT '0.41',
  `cloud_color_b` float(3,2) unsigned NOT NULL DEFAULT '0.41',
  `cloud_color_i` float(3,2) unsigned NOT NULL DEFAULT '0.41',
  `cloud_x` float(3,2) unsigned NOT NULL DEFAULT '1.00',
  `cloud_y` float(3,2) unsigned NOT NULL DEFAULT '0.53',
  `cloud_density` float(3,2) unsigned NOT NULL DEFAULT '1.00',
  `cloud_coverage` float(3,2) unsigned NOT NULL DEFAULT '0.27',
  `cloud_scale` float(3,2) unsigned NOT NULL DEFAULT '0.42',
  `cloud_detail_x` float(3,2) unsigned NOT NULL DEFAULT '1.00',
  `cloud_detail_y` float(3,2) unsigned NOT NULL DEFAULT '0.53',
  `cloud_detail_density` float(3,2) unsigned NOT NULL DEFAULT '0.12',
  `cloud_scroll_x` float(4,2) NOT NULL DEFAULT '0.20',
  `cloud_scroll_x_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `cloud_scroll_y` float(4,2) NOT NULL DEFAULT '0.01',
  `cloud_scroll_y_lock` tinyint(1) unsigned NOT NULL DEFAULT '0',
  `draw_classic_clouds` tinyint(1) unsigned NOT NULL DEFAULT '1',
  PRIMARY KEY (`region_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `spawn_points` (
  `RegionID` varchar(36) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `Yaw` float NOT NULL,
  `Pitch` float NOT NULL,
  `Distance` float NOT NULL,
  KEY `RegionID` (`RegionID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `regionenvironment` (
  `region_id` varchar(36) NOT NULL,
  `llsd_settings` text NOT NULL,
  PRIMARY KEY (`region_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `regionextra` (
  `RegionID` char(36) NOT NULL,
  `Name` varchar(32) NOT NULL,
  `value` text,
  PRIMARY KEY (`RegionID`,`Name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

COMMIT;

:VERSION 52        #---- avination fields

BEGIN;

ALTER TABLE `prims` ADD COLUMN `PassCollisions` tinyint(4) NOT NULL default '0';
ALTER TABLE `prims` ADD COLUMN `Vehicle` TEXT default NULL;
ALTER TABLE `regionsettings` ADD COLUMN `block_search` tinyint(4) NOT NULL default '0';
ALTER TABLE `regionsettings` ADD COLUMN `casino` tinyint(4) NOT NULL default '0';
ALTER TABLE `land` ADD COLUMN `SeeAVs` tinyint(4) NOT NULL default '1';
ALTER TABLE `land` ADD COLUMN `AnyAVSounds` tinyint(4) NOT NULL default '1';
ALTER TABLE `land` ADD COLUMN `GroupAVSounds` tinyint(4) NOT NULL default '1';

COMMIT;

:VERSION 53         #---- STATUS ROTATION axis locks

BEGIN;

ALTER TABLE `prims` ADD COLUMN `RotationAxisLocks` tinyint(4) NOT NULL default '0';

COMMIT;

:VERSION 54         #----- add baked terrain store

BEGIN;

CREATE TABLE IF NOT EXISTS `bakedterrain` (
  `RegionUUID` varchar(255) DEFAULT NULL,
  `Revision` int(11) DEFAULT NULL,
  `Heightfield` longblob
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

COMMIT;
