:VERSION 12

BEGIN TRANSACTION;

-- ----------------------------
--  Table structure for estate_groups
-- ----------------------------
CREATE TABLE IF NOT EXISTS "public"."estate_groups" (
	"EstateID" int4 NOT NULL,
	"uuid" uuid NOT NULL
)
WITH (OIDS=FALSE);

--  Indexes structure for table estate_groups
-- ----------------------------
CREATE INDEX IF NOT EXISTS "ix_estate_groups" ON "public"."estate_groups" USING btree("EstateID" "pg_catalog"."int4_ops" ASC NULLS LAST);

-- ----------------------------
--  Table structure for estate_managers
-- ----------------------------
CREATE TABLE IF NOT EXISTS "public"."estate_managers" (
	"EstateID" int4 NOT NULL,
	"uuid" uuid NOT NULL
)
WITH (OIDS=FALSE);

--  Indexes structure for table estate_managers
-- ----------------------------
CREATE INDEX IF NOT EXISTS "ix_estate_managers" ON "public"."estate_managers" USING btree("EstateID" "pg_catalog"."int4_ops" ASC NULLS LAST);

-- ----------------------------
--  Table structure for estate_map
-- ----------------------------
CREATE TABLE IF NOT EXISTS "public"."estate_map" (
	"RegionID" uuid NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'::uuid,
	"EstateID" int4 NOT NULL
)
WITH (OIDS=FALSE);

--  Primary key structure for table estate_map
-- ----------------------------
ALTER TABLE "public"."estate_map" ADD PRIMARY KEY ("RegionID") NOT DEFERRABLE INITIALLY IMMEDIATE;

-- ----------------------------
-- SEQUENCE estate_settings_id
-- ----------------------------
CREATE SEQUENCE IF NOT EXISTS "public"."estate_settings_id"
  INCREMENT 100
  MINVALUE 1
  MAXVALUE 9223372036854775807
  START 100
  CACHE 1;

-- ----------------------------
--  Table structure for estate_settings
-- ----------------------------
CREATE TABLE IF NOT EXISTS "public"."estate_settings" (
	"EstateID" int4 NOT NULL DEFAULT nextval('estate_settings_id'::regclass),
	"EstateName" varchar(64) DEFAULT NULL::character varying COLLATE "default",
	"AbuseEmailToEstateOwner" bool NOT NULL,
	"DenyAnonymous" bool NOT NULL,
	"ResetHomeOnTeleport" bool NOT NULL,
	"FixedSun" bool NOT NULL,
	"DenyTransacted" bool NOT NULL,
	"BlockDwell" bool NOT NULL,
	"DenyIdentified" bool NOT NULL,
	"AllowVoice" bool NOT NULL,
	"UseGlobalTime" bool NOT NULL,
	"PricePerMeter" int4 NOT NULL,
	"TaxFree" bool NOT NULL,
	"AllowDirectTeleport" bool NOT NULL,
	"RedirectGridX" int4 NOT NULL,
	"RedirectGridY" int4 NOT NULL,
	"ParentEstateID" int4 NOT NULL,
	"SunPosition" float8 NOT NULL,
	"EstateSkipScripts" bool NOT NULL,
	"BillableFactor" float8 NOT NULL,
	"PublicAccess" bool NOT NULL,
	"AbuseEmail" varchar(255) NOT NULL COLLATE "default",
	"EstateOwner" uuid NOT NULL,
	"DenyMinors" bool NOT NULL,
	"AllowLandmark" bool NOT NULL DEFAULT true,
	"AllowParcelChanges" bool NOT NULL DEFAULT true,
	"AllowSetHome" bool NOT NULL DEFAULT true
)
WITH (OIDS=FALSE);

--  Primary key structure for table estate_settings
-- ----------------------------
ALTER TABLE "public"."estate_settings" ADD PRIMARY KEY ("EstateID") NOT DEFERRABLE INITIALLY IMMEDIATE;

-- ----------------------------
--  Table structure for estate_users
-- ----------------------------
CREATE TABLE IF NOT EXISTS "public"."estate_users" (
	"EstateID" int4 NOT NULL,
	"uuid" uuid NOT NULL
)
WITH (OIDS=FALSE);

--  Indexes structure for table estate_users
-- ----------------------------
CREATE INDEX  IF NOT EXISTS "ix_estate_users" ON "public"."estate_users" USING btree("EstateID" "pg_catalog"."int4_ops" ASC NULLS LAST);

-- ----------------------------
--  Table structure for estateban
-- ----------------------------
CREATE TABLE IF NOT EXISTS "public"."estateban" (
	"EstateID" int4 NOT NULL,
	"bannedUUID" uuid NOT NULL,
	"bannedIp" varchar(16) COLLATE "default",
	"bannedIpHostMask" varchar(16) COLLATE "default",
	"bannedNameMask" varchar(64) COLLATE "default"
)
WITH (OIDS=FALSE);

--  Indexes structure for table estateban
-- ----------------------------
CREATE INDEX IF NOT EXISTS  "ix_estateban" ON "public"."estateban" USING btree("EstateID" "pg_catalog"."int4_ops" ASC NULLS LAST);

COMMIT;

:VERSION 14
BEGIN TRANSACTION;

ALTER TABLE "public"."estateban"
    ADD COLUMN "banningUUID" uuid NOT NULL,
    ADD COLUMN "banTime" int4 NOT NULL DEFAULT 0;
COMMIT;

:VERSION 15
BEGIN TRANSACTION;
ALTER TABLE "public"."estate_settings"
    ADD COLUMN "AllowEnviromentOverride" bool NOT NULL;
COMMIT;