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
|
# -----------------
:VERSION 1
BEGIN;
CREATE TABLE XAssetsMeta (
"ID" char(36) NOT NULL,
"Hash" char(32) NOT NULL,
"Name" varchar(64) NOT NULL,
"Description" varchar(64) NOT NULL,
"AssetType" smallint NOT NULL,
"Local" smallint NOT NULL,
"Temporary" smallint NOT NULL,
"CreateTime" integer NOT NULL,
"AccessTime" integer NOT NULL,
"AssetFlags" integer NOT NULL,
"CreatorID" varchar(128) NOT NULL,
PRIMARY KEY ("ID")
);
CREATE TABLE XAssetsData (
"Hash" char(32) NOT NULL,
"Data" bytea NOT NULL,
PRIMARY KEY ("Hash")
);
COMMIT;
:VERSION 2
BEGIN;
ALTER TABLE xassetsmeta ALTER COLUMN "Local" SET DATA TYPE boolean USING CASE WHEN '0' THEN FALSE ELSE TRUE END;
ALTER TABLE xassetsmeta ALTER COLUMN "Temporary" SET DATA TYPE boolean USING CASE WHEN '0' THEN FALSE ELSE TRUE END;
ALTER TABLE xassetsmeta ALTER COLUMN "Hash" SET DATA TYPE char(66);
ALTER TABLE xassetsdata ALTER COLUMN "Hash" SET DATA TYPE char(66);
COMMIT;
:VERSION 3
BEGIN;
ALTER TABLE xassetsmeta RENAME COLUMN "ID" TO id;
ALTER TABLE xassetsmeta RENAME COLUMN "Hash" TO hash;
ALTER TABLE xassetsmeta RENAME COLUMN "Name" TO name;
ALTER TABLE xassetsmeta RENAME COLUMN "Description" TO description;
ALTER TABLE xassetsmeta RENAME COLUMN "Local" to local;
ALTER TABLE xassetsmeta RENAME COLUMN "Temporary" TO temporary;
ALTER TABLE xassetsmeta RENAME COLUMN "CreateTime" TO create_time;
ALTER TABLE xassetsmeta RENAME COLUMN "AccessTime" TO access_time;
ALTER TABLE xassetsmeta RENAME COLUMN "AssetFlags" TO asset_flags;
ALTER TABLE xassetsmeta RENAME COLUMN "CreatorID" TO creatorid;
ALTER TABLE xassetsmeta DROP CONSTRAINT xassetsmeta_pkey;
ALTER TABLE xassetsmeta ADD PRIMARY KEY (id);
ALTER TABLE xassetsdata RENAME COLUMN "Hash" TO hash;
ALTER TABLE xassetsdata RENAME COLUMN "Data" TO data;
ALTER TABLE xassetsdata DROP CONSTRAINT xassetsdata_pkey;
ALTER TABLE xassetsdata ADD PRIMARY KEY (hash);
COMMIT;
:VERSION 4
BEGIN;
ALTER TABLE xassetsmeta ALTER COLUMN id SET DATA TYPE uuid USING id::uuid;
ALTER TABLE xassetsmeta ALTER COLUMN hash SET DATA TYPE bytea USING hash::bytea;
ALTER TABLE xassetsdata ALTER COLUMN hash SET DATA TYPE bytea USING hash::bytea;
COMMIT;
:VERSION 5
BEGIN;
COMMIT;
|