BEGIN TRANSACTION;

create table Prims (
  UUID TEXT not null,
   RegionID TEXT,
   GroupID TEXT,
   ParentID INTEGER,
   ParentUUID TEXT,
   OwnerID TEXT,
   LastOwnerID TEXT,
   CreatorID TEXT,
   CreationDate INTEGER,
   LinkNum INTEGER,   
   Name TEXT,
   Text TEXT,
   Description TEXT,
   SitName TEXT,
   TouchName TEXT,
   ObjectFlags INTEGER,
   OwnerMask INTEGER,
   NextOwnerMask INTEGER,
   GroupMask INTEGER,
   EveryoneMask INTEGER,
   BaseMask INTEGER,
   Material INTEGER,
   ScriptAccessPin INTEGER,
   TextureAnimation BLOB,
   ParticleSystem BLOB,
   ClickAction INTEGER,
   Color INTEGER,
   PositionX NUMERIC,
   PositionY NUMERIC,
   PositionZ NUMERIC,
   GroupPositionX NUMERIC,
   GroupPositionY NUMERIC,
   GroupPositionZ NUMERIC,
   VelocityX NUMERIC,
   VelocityY NUMERIC,
   VelocityZ NUMERIC,
   AngularVelocityX NUMERIC,
   AngularVelocityY NUMERIC,
   AngularVelocityZ NUMERIC,
   AccelerationX NUMERIC,
   AccelerationY NUMERIC,
   AccelerationZ NUMERIC,
   SitTargetOffsetX NUMERIC,
   SitTargetOffsetY NUMERIC,
   SitTargetOffsetZ NUMERIC,
   RotationX NUMERIC,
   RotationY NUMERIC,
   RotationZ NUMERIC,
   RotationW NUMERIC,
   SitTargetOrientX NUMERIC,
   SitTargetOrientY NUMERIC,
   SitTargetOrientZ NUMERIC,
   SitTargetOrientW NUMERIC,
   ScaleX NUMERIC,
   ScaleY NUMERIC,
   ScaleZ NUMERIC,
   PCode INTEGER,
   PathBegin INTEGER,
   PathEnd INTEGER,
   PathScaleX INTEGER,
   PathScaleY INTEGER,
   PathShearX INTEGER,
   PathShearY INTEGER,
   PathSkew INTEGER,
   PathCurve INTEGER,
   PathRadiusOffset INTEGER,
   PathRevolutions INTEGER,
   PathTaperX INTEGER,
   PathTwist INTEGER,
   ProfileBegin INTEGER,
   ProfileEnd INTEGER,
   ProfileCurve INTEGER,
   ProfileHollow INTEGER,
   Texture BLOB,
   ExtraParams BLOB,
   State INTEGER,
   primary key (UUID)
);
create table Terrain (
  RegionID TEXT not null,
   MapData BLOB,
   primary key (RegionID)
);
create table PrimItems (
  ItemID TEXT not null,
   PrimID TEXT,
   AssetID TEXT,
   ParentFolderID TEXT,
   CreatorID TEXT,
   OwnerID TEXT,
   GroupID TEXT,
   LastOwnerID TEXT,
   CurrentPermissions INTEGER,
   BasePermissions INTEGER,
   EveryonePermissions INTEGER,
   GroupPermissions INTEGER,
   NextPermissions INTEGER,
   Name TEXT,
   Description TEXT,
   CreationDate INTEGER,
   Flags INTEGER,
   InvType INTEGER,
   primary key (ItemID)
);

CREATE TABLE RegionSettings (
  RegionID TEXT not null,
  BlockTerraform BIT,
  BlockFly BIT,
  AllowDamage BIT,
  RestrictPushing BIT,
  AllowLandResell BIT,
  AllowLandJoinDivide BIT,
  BlockShowInSearch BIT,
  AgentLimit INTEGER,
  ObjectBonus NUMERIC,
  Maturity INTEGER,
  DisableScripts BIT,
  DisableCollisions BIT,
  DisablePhysics BIT,
  TerrainTexture1 TEXT,
  TerrainTexture2 TEXT,
  TerrainTexture3 TEXT,
  TerrainTexture4 TEXT,
  Elevation1NW NUMERIC,
  Elevation2NW NUMERIC,
  Elevation1NE NUMERIC,
  Elevation2NE NUMERIC,
  Elevation1SE NUMERIC,
  Elevation2SE NUMERIC,
  Elevation1SW NUMERIC,
  Elevation2SW NUMERIC,
  WaterHeight NUMERIC,
  TerrainRaiseLimit NUMERIC,
  TerrainLowerLimit NUMERIC,
  UseEstateSun BIT,
  Sandbox BIT,
  SunVectorX NUMERIC,
  SunVectorY NUMERIC,
  SunVectorZ NUMERIC,
  FixedSun BIT, 
  SunPosition NUMERIC,
  Covenant TEXT,
  primary key (RegionID)
);

COMMIT;
