aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/PGSQL/Resources/InventoryStore.migrations
blob: 8f7982ad356080af23213e10dc8aa7da37438058 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
:VERSION 1

BEGIN TRANSACTION;

CREATE TABLE inventoryfolders (
  "folderID" varchar(36) NOT NULL default '' PRIMARY KEY,
  "agentID" varchar(36) default NULL,
  "parentFolderID" varchar(36) default NULL,
  "folderName" varchar(64) default NULL,
  "type" smallint NOT NULL default 0,
  "version" int NOT NULL default 0
);


CREATE INDEX owner ON inventoryfolders
(
	"agentID" ASC
);

CREATE INDEX parent ON inventoryfolders
(
	"parentFolderID" ASC
);


CREATE TABLE inventoryitems (
  "inventoryID" varchar(36) NOT NULL default '' Primary Key,
  "assetID" varchar(36) default NULL,
  "assetType" int default NULL,
  "parentFolderID" varchar(36) default NULL,
  "avatarID" varchar(36) default NULL,
  "inventoryName" varchar(64) default NULL,
  "inventoryDescription" varchar(128) default NULL,
  "inventoryNextPermissions" int default NULL,
  "inventoryCurrentPermissions" int default NULL,
  "invType" int default NULL,
  "creatorID" varchar(36) default NULL,
  "inventoryBasePermissions" int NOT NULL default 0,
  "inventoryEveryOnePermissions" int NOT NULL default 0,
  "salePrice" int default NULL,
  "saleType" smallint default NULL,
  "creationDate" int default NULL,
  "groupID" varchar(36) default NULL,
  "groupOwned" boolean default NULL,
  "flags" int default NULL
);


CREATE INDEX ii_owner ON inventoryitems
(
	"avatarID" ASC
);

CREATE INDEX ii_folder ON inventoryitems
(
	"parentFolderID" ASC
);

COMMIT;


:VERSION 2

BEGIN TRANSACTION;

ALTER TABLE inventoryitems ADD "inventoryGroupPermissions" INTEGER NOT NULL default 0;

COMMIT;

:VERSION 3

/* To prevent any potential data loss issues, you should review this script in detail before running it outside the cotext of the database designer.*/
BEGIN TRANSACTION;

CREATE TABLE Tmp_inventoryfolders
	(
	"folderID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
	"agentID" uuid NULL DEFAULT (NULL),
	"parentFolderID" uuid NULL DEFAULT (NULL),
	"folderName" varchar(64) NULL DEFAULT (NULL),
	"type" smallint NOT NULL DEFAULT ((0)),
	"version" int NOT NULL DEFAULT ((0))
	);

 INSERT INTO Tmp_inventoryfolders ("folderID", "agentID", "parentFolderID", "folderName", type, version)
   SELECT cast("folderID" as uuid), cast("agentID" as uuid), cast("parentFolderID" as uuid), "folderName", "type", "version"
   FROM inventoryfolders;

DROP TABLE inventoryfolders;

alter table Tmp_inventoryfolders rename to inventoryfolders;

ALTER TABLE inventoryfolders ADD CONSTRAINT
	PK__inventor__C2FABFB3173876EA PRIMARY KEY 
	(
	"folderID"
	);

CREATE INDEX owner ON inventoryfolders
	(
	"agentID"
	);

CREATE INDEX parent ON inventoryfolders
	(
	"parentFolderID"
	);

COMMIT;


:VERSION 4

BEGIN TRANSACTION;

CREATE TABLE Tmp_inventoryitems
	(
	"inventoryID" uuid NOT NULL DEFAULT ('00000000-0000-0000-0000-000000000000'),
	"assetID" uuid NULL DEFAULT (NULL),
	"assetType" int NULL DEFAULT (NULL),
	"parentFolderID" uuid NULL DEFAULT (NULL),
	"avatarID" uuid NULL DEFAULT (NULL),
	"inventoryName" varchar(64) NULL DEFAULT (NULL),
	"inventoryDescription" varchar(128) NULL DEFAULT (NULL),
	"inventoryNextPermissions" int NULL DEFAULT (NULL),
	"inventoryCurrentPermissions" int NULL DEFAULT (NULL),
	"invType" int NULL DEFAULT (NULL),
	"creatorID" uuid NULL DEFAULT (NULL),
	"inventoryBasePermissions" int NOT NULL DEFAULT ((0)),
	"inventoryEveryOnePermissions" int NOT NULL DEFAULT ((0)),
	"salePrice" int NULL DEFAULT (NULL),
	"SaleType" smallint NULL DEFAULT (NULL),
	"creationDate" int NULL DEFAULT (NULL),
	"groupID" uuid NULL DEFAULT (NULL),
	"groupOwned" boolean NULL DEFAULT (NULL),
	"flags" int NULL DEFAULT (NULL),
	"inventoryGroupPermissions" int NOT NULL DEFAULT ((0))
	);


	 INSERT INTO Tmp_inventoryitems ("inventoryID", "assetID", "assetType", "parentFolderID", "avatarID", "inventoryName", "inventoryDescription", "inventoryNextPermissions", "inventoryCurrentPermissions", "invType", "creatorID", "inventoryBasePermissions", "inventoryEveryOnePermissions", "salePrice", "SaleType", "creationDate", "groupID", "groupOwned", "flags", "inventoryGroupPermissions")
		SELECT cast("inventoryID" as uuid), cast("assetID" as uuid), "assetType", cast("parentFolderID" as uuid), cast("avatarID" as uuid), "inventoryName", "inventoryDescription", "inventoryNextPermissions", "inventoryCurrentPermissions", "invType", cast("creatorID" as uuid), "inventoryBasePermissions", "inventoryEveryOnePermissions", "salePrice", "SaleType", "creationDate", cast("groupID" as uuid), "groupOwned", "flags", "inventoryGroupPermissions" 
		FROM inventoryitems ;

DROP TABLE inventoryitems;

alter table Tmp_inventoryitems rename to inventoryitems;

ALTER TABLE inventoryitems ADD CONSTRAINT
	PK__inventor__C4B7BC2220C1E124 PRIMARY KEY 
	(
	"inventoryID"
	);


CREATE INDEX ii2_owner ON inventoryitems
	(
	"avatarID"
	);

CREATE INDEX ii2_folder ON inventoryitems
	(
	"parentFolderID"
	);

COMMIT;

:VERSION 5


BEGIN TRANSACTION;

-- # Restoring defaults:   
-- # NOTE: "inventoryID" does NOT need one: it's NOT NULL PK and a unique Guid must be provided every time anyway!
 
alter table inventoryitems
   alter column "inventoryBasePermissions" set default 0;    
alter table inventoryitems
   alter column "inventoryEveryOnePermissions" set default 0;  
alter table inventoryitems
   alter column "inventoryGroupPermissions" set default 0 ;   
   
COMMIT     ;
   
:VERSION 7

BEGIN TRANSACTION;

-- # "creatorID" goes back to VARCHAR(36) (???)

alter table inventoryitems
  alter column "creatorID" type varchar(36);

COMMIT	;
   
:VERSION 8

ALTER TABLE inventoryitems
 alter column "creatorID" set DEFAULT '00000000-0000-0000-0000-000000000000';
   

:VERSION 9

BEGIN TRANSACTION;

--# "creatorID" goes up to VARCHAR(255)

alter table inventoryitems
  alter column "creatorID" type varchar(255);
  
Commit;

:VERSION 10

BEGIN TRANSACTION;

Alter table inventoryitems Rename Column "SaleType" to "saleType";

Commit;