-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathsnebu_update_db.sql
103 lines (96 loc) · 2.9 KB
/
snebu_update_db.sql
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
alter table file_entities rename to file_entities_old;
alter table received_file_entities rename to received_file_entities_old;
alter table needed_file_entities rename to needed_file_entities_old;
create table if not exists file_entities (
file_id integer primary key,
ftype char,
permission char,
device_id char,
inode char,
user_name char,
user_id integer,
group_name char,
group_id integer,
size integer,
sha1 char,
cdatestamp integer,
datestamp integer,
filename char,
extdata char default '',
xheader blob default '',
constraint file_entities_c1 unique (
ftype,
permission,
device_id,
inode,
user_name,
user_id,
group_name,
group_id,
size,
sha1,
cdatestamp,
datestamp,
filename,
extdata,
xheader ));
create table if not exists received_file_entities (
file_id integer primary key,
backupset_id integer,
ftype char,
permission char,
user_name char,
user_id integer,
group_name char,
group_id integer,
size integer,
sha1 char,
datestamp integer,
filename char,
extdata char default '',
xheader blob default '',
foreign key(backupset_id) references backupsets(backupset_id),
unique (
backupset_id,
ftype,
permission,
user_name,
user_id,
group_name,
group_id,
size,
sha1,
datestamp,
filename,
extdata,
xheader ));
create table if not exists needed_file_entities (
backupset_id integer,
device_id char,
inode char,
filename char,
infilename char,
size integer,
cdatestamp integer,
foreign key(backupset_id) references backupsets(backupset_id),
unique (
backupset_id,
filename,
infilename ));
insert into file_entities
( file_id, ftype, permission, device_id, inode, user_name, user_id,
group_name, group_id, size, sha1, cdatestamp, datestamp, filename,
extdata, xheader)
select file_id, ftype, permission, device_id, inode, user_name, user_id,
group_name, group_id, size, sha1, datestamp, datestamp, filename,
extdata, '' from file_entities_old;
insert into received_file_entities
( file_id, backupset_id, ftype, permission, user_name, user_id,
group_name, group_id, size, sha1, datestamp, filename, extdata, xheader)
select file_id, backupset_id, ftype, permission, user_name, user_id,
group_name, group_id, size, sha1, datestamp, filename, extdata, ''
from received_file_entities_old;
insert into needed_file_entities
(backupset_id, device_id, inode, filename, infilename, size, cdatestamp)
select backupset_id, device_id, inode, filename, infilename, size, ''
from needed_file_entities_old;