:VERSION 1

BEGIN TRANSACTION

CREATE TABLE [dbo].[estate_managers](
	[EstateID] [int] NOT NULL,
	[uuid] [varchar](36) NOT NULL,
 CONSTRAINT [PK_estate_managers] PRIMARY KEY CLUSTERED 
(
	[EstateID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY];

CREATE TABLE [dbo].[estate_groups](
	[EstateID] [int] NOT NULL,
	[uuid] [varchar](36) NOT NULL,
 CONSTRAINT [PK_estate_groups] PRIMARY KEY CLUSTERED 
(
	[EstateID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY];


CREATE TABLE [dbo].[estate_users](
	[EstateID] [int] NOT NULL,
	[uuid] [varchar](36) NOT NULL,
 CONSTRAINT [PK_estate_users] PRIMARY KEY CLUSTERED 
(
	[EstateID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY];


CREATE TABLE [dbo].[estateban](
	[EstateID] [int] NOT NULL,
	[bannedUUID] [varchar](36) NOT NULL,
	[bannedIp] [varchar](16) NOT NULL,
	[bannedIpHostMask] [varchar](16) NOT NULL,
	[bannedNameMask] [varchar](64) NULL DEFAULT (NULL),
 CONSTRAINT [PK_estateban] PRIMARY KEY CLUSTERED 
(
	[EstateID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY];

CREATE TABLE [dbo].[estate_settings](
	[EstateID] [int] IDENTITY(1,100) NOT NULL,
	[EstateName] [varchar](64) NULL DEFAULT (NULL),
	[AbuseEmailToEstateOwner] [bit] NOT NULL,
	[DenyAnonymous] [bit] NOT NULL,
	[ResetHomeOnTeleport] [bit] NOT NULL,
	[FixedSun] [bit] NOT NULL,
	[DenyTransacted] [bit] NOT NULL,
	[BlockDwell] [bit] NOT NULL,
	[DenyIdentified] [bit] NOT NULL,
	[AllowVoice] [bit] NOT NULL,
	[UseGlobalTime] [bit] NOT NULL,
	[PricePerMeter] [int] NOT NULL,
	[TaxFree] [bit] NOT NULL,
	[AllowDirectTeleport] [bit] NOT NULL,
	[RedirectGridX] [int] NOT NULL,
	[RedirectGridY] [int] NOT NULL,
	[ParentEstateID] [int] NOT NULL,
	[SunPosition] [float] NOT NULL,
	[EstateSkipScripts] [bit] NOT NULL,
	[BillableFactor] [float] NOT NULL,
	[PublicAccess] [bit] NOT NULL,
	[AbuseEmail] [varchar](255) NOT NULL,
	[EstateOwner] [varchar](36) NOT NULL,
	[DenyMinors] [bit] NOT NULL,
 CONSTRAINT [PK_estate_settings] PRIMARY KEY CLUSTERED 
(
	[EstateID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY];


CREATE TABLE [dbo].[estate_map](
	[RegionID] [varchar](36) NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
	[EstateID] [int] NOT NULL,
 CONSTRAINT [PK_estate_map] PRIMARY KEY CLUSTERED 
(
	[RegionID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY];

COMMIT

:VERSION 2

BEGIN TRANSACTION

ALTER TABLE dbo.estate_managers DROP CONSTRAINT PK_estate_managers

CREATE NONCLUSTERED INDEX IX_estate_managers ON dbo.estate_managers
	(
	EstateID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

ALTER TABLE dbo.estate_groups DROP CONSTRAINT PK_estate_groups

CREATE NONCLUSTERED INDEX IX_estate_groups ON dbo.estate_groups
	(
	EstateID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


ALTER TABLE dbo.estate_users DROP CONSTRAINT PK_estate_users

CREATE NONCLUSTERED INDEX IX_estate_users ON dbo.estate_users
	(
	EstateID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

COMMIT


:VERSION 3

BEGIN TRANSACTION

CREATE TABLE dbo.Tmp_estateban
	(
	EstateID int NOT NULL,
	bannedUUID varchar(36) NOT NULL,
	bannedIp varchar(16) NULL,
	bannedIpHostMask varchar(16) NULL,
	bannedNameMask varchar(64) NULL
	)  ON [PRIMARY]

IF EXISTS(SELECT * FROM dbo.estateban)
	 EXEC('INSERT INTO dbo.Tmp_estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask)
		SELECT EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask FROM dbo.estateban')

DROP TABLE dbo.estateban

EXECUTE sp_rename N'dbo.Tmp_estateban', N'estateban', 'OBJECT' 

CREATE NONCLUSTERED INDEX IX_estateban ON dbo.estateban
	(
	EstateID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

COMMIT


:VERSION 4

BEGIN TRANSACTION

CREATE TABLE dbo.Tmp_estate_managers
	(
	EstateID int NOT NULL,
	uuid uniqueidentifier NOT NULL
	)  ON [PRIMARY]

IF EXISTS(SELECT * FROM dbo.estate_managers)
	 EXEC('INSERT INTO dbo.Tmp_estate_managers (EstateID, uuid)
		SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_managers WITH (HOLDLOCK TABLOCKX)')

DROP TABLE dbo.estate_managers

EXECUTE sp_rename N'dbo.Tmp_estate_managers', N'estate_managers', 'OBJECT' 

CREATE NONCLUSTERED INDEX IX_estate_managers ON dbo.estate_managers
	(
	EstateID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

COMMIT


:VERSION 5

BEGIN TRANSACTION

CREATE TABLE dbo.Tmp_estate_groups
	(
	EstateID int NOT NULL,
	uuid uniqueidentifier NOT NULL
	)  ON [PRIMARY]

IF EXISTS(SELECT * FROM dbo.estate_groups)
	 EXEC('INSERT INTO dbo.Tmp_estate_groups (EstateID, uuid)
		SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_groups WITH (HOLDLOCK TABLOCKX)')

DROP TABLE dbo.estate_groups

EXECUTE sp_rename N'dbo.Tmp_estate_groups', N'estate_groups', 'OBJECT' 

CREATE NONCLUSTERED INDEX IX_estate_groups ON dbo.estate_groups
	(
	EstateID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

COMMIT


:VERSION 6

BEGIN TRANSACTION

CREATE TABLE dbo.Tmp_estate_users
	(
	EstateID int NOT NULL,
	uuid uniqueidentifier NOT NULL
	)  ON [PRIMARY]

IF EXISTS(SELECT * FROM dbo.estate_users)
	 EXEC('INSERT INTO dbo.Tmp_estate_users (EstateID, uuid)
		SELECT EstateID, CONVERT(uniqueidentifier, uuid) FROM dbo.estate_users WITH (HOLDLOCK TABLOCKX)')

DROP TABLE dbo.estate_users

EXECUTE sp_rename N'dbo.Tmp_estate_users', N'estate_users', 'OBJECT' 

CREATE NONCLUSTERED INDEX IX_estate_users ON dbo.estate_users
	(
	EstateID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

COMMIT


:VERSION 7

BEGIN TRANSACTION

CREATE TABLE dbo.Tmp_estateban
	(
	EstateID int NOT NULL,
	bannedUUID uniqueidentifier NOT NULL,
	bannedIp varchar(16) NULL,
	bannedIpHostMask varchar(16) NULL,
	bannedNameMask varchar(64) NULL
	)  ON [PRIMARY]

IF EXISTS(SELECT * FROM dbo.estateban)
	 EXEC('INSERT INTO dbo.Tmp_estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask)
		SELECT EstateID, CONVERT(uniqueidentifier, bannedUUID), bannedIp, bannedIpHostMask, bannedNameMask FROM dbo.estateban WITH (HOLDLOCK TABLOCKX)')

DROP TABLE dbo.estateban

EXECUTE sp_rename N'dbo.Tmp_estateban', N'estateban', 'OBJECT' 

CREATE NONCLUSTERED INDEX IX_estateban ON dbo.estateban
	(
	EstateID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

COMMIT


:VERSION 8

BEGIN TRANSACTION

CREATE TABLE dbo.Tmp_estate_settings
	(
	EstateID int NOT NULL IDENTITY (1, 100),
	EstateName varchar(64) NULL DEFAULT (NULL),
	AbuseEmailToEstateOwner bit NOT NULL,
	DenyAnonymous bit NOT NULL,
	ResetHomeOnTeleport bit NOT NULL,
	FixedSun bit NOT NULL,
	DenyTransacted bit NOT NULL,
	BlockDwell bit NOT NULL,
	DenyIdentified bit NOT NULL,
	AllowVoice bit NOT NULL,
	UseGlobalTime bit NOT NULL,
	PricePerMeter int NOT NULL,
	TaxFree bit NOT NULL,
	AllowDirectTeleport bit NOT NULL,
	RedirectGridX int NOT NULL,
	RedirectGridY int NOT NULL,
	ParentEstateID int NOT NULL,
	SunPosition float(53) NOT NULL,
	EstateSkipScripts bit NOT NULL,
	BillableFactor float(53) NOT NULL,
	PublicAccess bit NOT NULL,
	AbuseEmail varchar(255) NOT NULL,
	EstateOwner uniqueidentifier NOT NULL,
	DenyMinors bit NOT NULL
	)  ON [PRIMARY]

SET IDENTITY_INSERT dbo.Tmp_estate_settings ON

IF EXISTS(SELECT * FROM dbo.estate_settings)
	 EXEC('INSERT INTO dbo.Tmp_estate_settings (EstateID, EstateName, AbuseEmailToEstateOwner, DenyAnonymous, ResetHomeOnTeleport, FixedSun, DenyTransacted, BlockDwell, DenyIdentified, AllowVoice, UseGlobalTime, PricePerMeter, TaxFree, AllowDirectTeleport, RedirectGridX, RedirectGridY, ParentEstateID, SunPosition, EstateSkipScripts, BillableFactor, PublicAccess, AbuseEmail, EstateOwner, DenyMinors)
		SELECT EstateID, EstateName, AbuseEmailToEstateOwner, DenyAnonymous, ResetHomeOnTeleport, FixedSun, DenyTransacted, BlockDwell, DenyIdentified, AllowVoice, UseGlobalTime, PricePerMeter, TaxFree, AllowDirectTeleport, RedirectGridX, RedirectGridY, ParentEstateID, SunPosition, EstateSkipScripts, BillableFactor, PublicAccess, AbuseEmail, CONVERT(uniqueidentifier, EstateOwner), DenyMinors FROM dbo.estate_settings WITH (HOLDLOCK TABLOCKX)')

SET IDENTITY_INSERT dbo.Tmp_estate_settings OFF

DROP TABLE dbo.estate_settings

EXECUTE sp_rename N'dbo.Tmp_estate_settings', N'estate_settings', 'OBJECT' 

ALTER TABLE dbo.estate_settings ADD CONSTRAINT
	PK_estate_settings PRIMARY KEY CLUSTERED 
	(
	EstateID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]

COMMIT


:VERSION 9

BEGIN TRANSACTION

CREATE TABLE dbo.Tmp_estate_map
	(
	RegionID uniqueidentifier NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
	EstateID int NOT NULL
	)  ON [PRIMARY]

IF EXISTS(SELECT * FROM dbo.estate_map)
	 EXEC('INSERT INTO dbo.Tmp_estate_map (RegionID, EstateID)
		SELECT CONVERT(uniqueidentifier, RegionID), EstateID FROM dbo.estate_map WITH (HOLDLOCK TABLOCKX)')

DROP TABLE dbo.estate_map

EXECUTE sp_rename N'dbo.Tmp_estate_map', N'estate_map', 'OBJECT' 

ALTER TABLE dbo.estate_map ADD CONSTRAINT
	PK_estate_map PRIMARY KEY CLUSTERED 
	(
	RegionID
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]


COMMIT


