-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmemoryTables.sql
More file actions
90 lines (74 loc) · 2.89 KB
/
memoryTables.sql
File metadata and controls
90 lines (74 loc) · 2.89 KB
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
/* Shift Memory Tables
*
*/
BEGIN;
CREATE TABLE IF NOT EXISTS "mem_accounts"(
"username" VARCHAR(20),
"isDelegate" SMALLINT DEFAULT 0,
"u_isDelegate" SMALLINT DEFAULT 0,
"secondSignature" SMALLINT DEFAULT 0,
"u_secondSignature" SMALLINT DEFAULT 0,
"u_username" VARCHAR(20),
"address" VARCHAR(22) NOT NULL UNIQUE PRIMARY KEY,
"publicKey" BYTEA,
"secondPublicKey" BYTEA,
"balance" BIGINT DEFAULT 0,
"u_balance" BIGINT DEFAULT 0,
"vote" BIGINT DEFAULT 0,
"rate" BIGINT DEFAULT 0,
"delegates" TEXT,
"u_delegates" TEXT,
"multisignatures" TEXT,
"u_multisignatures" TEXT,
"multimin" BIGINT DEFAULT 0,
"u_multimin" BIGINT DEFAULT 0,
"multilifetime" BIGINT DEFAULT 0,
"u_multilifetime" BIGINT DEFAULT 0,
"blockId" VARCHAR(20),
"nameexist" SMALLINT DEFAULT 0,
"u_nameexist" SMALLINT DEFAULT 0,
"producedblocks" int DEFAULT 0,
"missedblocks" int DEFAULT 0,
"fees" BIGINT DEFAULT 0,
"rewards" BIGINT DEFAULT 0,
"virgin" SMALLINT DEFAULT 1
);
CREATE INDEX IF NOT EXISTS "mem_accounts_balance" ON "mem_accounts"("balance");
CREATE TABLE IF NOT EXISTS "mem_round"(
"address" VARCHAR(22),
"amount" BIGINT,
"delegate" VARCHAR(64),
"blockId" VARCHAR(20),
"round" BIGINT
);
CREATE INDEX IF NOT EXISTS "mem_round_address" ON "mem_round"("address");
CREATE INDEX IF NOT EXISTS "mem_round_round" ON "mem_round"("round");
CREATE TABLE IF NOT EXISTS "mem_accounts2delegates"(
"accountId" VARCHAR(22) NOT NULL,
"dependentId" VARCHAR(64) NOT NULL,
FOREIGN KEY ("accountId") REFERENCES mem_accounts("address") ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS "mem_accounts2delegates_accountId" ON "mem_accounts2delegates"("accountId");
CREATE TABLE IF NOT EXISTS "mem_accounts2u_delegates"(
"accountId" VARCHAR(22) NOT NULL,
"dependentId" VARCHAR(64) NOT NULL,
FOREIGN KEY ("accountId") REFERENCES mem_accounts("address") ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS "mem_accounts2u_delegates_accountId" ON "mem_accounts2u_delegates"("accountId");
CREATE TABLE IF NOT EXISTS "mem_accounts2multisignatures"(
"accountId" VARCHAR(22) NOT NULL,
"dependentId" VARCHAR(64) NOT NULL,
FOREIGN KEY ("accountId") REFERENCES mem_accounts("address") ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS "mem_accounts2multisignatures_accountId" ON "mem_accounts2multisignatures"("accountId");
CREATE TABLE IF NOT EXISTS "mem_accounts2u_multisignatures"(
"accountId" VARCHAR(22) NOT NULL,
"dependentId" VARCHAR(64) NOT NULL,
FOREIGN KEY ("accountId") REFERENCES mem_accounts("address") ON DELETE CASCADE
);
CREATE INDEX IF NOT EXISTS "mem_accounts2u_multisignatures_accountId" ON "mem_accounts2u_multisignatures"("accountId");
DELETE FROM "mem_accounts2u_delegates";
DELETE FROM "mem_accounts2u_multisignatures";
INSERT INTO "mem_accounts2u_delegates" SELECT * FROM "mem_accounts2delegates";
INSERT INTO "mem_accounts2u_multisignatures" SELECT * FROM "mem_accounts2multisignatures";
COMMIT;