-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sql
49 lines (48 loc) · 1.58 KB
/
init.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
PRAGMA foreign_keys=ON;
BEGIN TRANSACTION;
CREATE TABLE metadata(
id integer primary key,
size int default 0 not null,
atime text,
atime_nsec int,
mtime text,
mtime_nsec int,
ctime text,
ctime_nsec int,
crtime text,
crtime_nsec int,
kind int,
mode int,
nlink int default 0 not null,
uid int default 0,
gid int default 0,
rdev int default 0,
flags int default 0
);
INSERT INTO metadata VALUES(1,0,'1970-01-01 00:00:00',0,'1970-01-01 00:00:00',0,'1970-01-01 00:00:00',0,'1970-01-01 00:00:00',0,16384,16832,1,0,0,0,0);
CREATE TABLE data(
file_id int,
block_num int,
data blob,
foreign key (file_id) references metadata(id) on delete cascade,
primary key (file_id, block_num)
);
CREATE TABLE dentry(
parent_id int,
child_id int,
file_type int,
name text,
foreign key (parent_id) references metadata(id) on delete cascade,
foreign key (child_id) references metadata(id) on delete cascade,
primary key (parent_id, name)
);
INSERT INTO dentry VALUES(1,1,16384,'.');
INSERT INTO dentry VALUES(1,1,16384,'..');
CREATE TABLE xattr(
file_id int,
name text,
value blob,
foreign key (file_id) references metadata(id) on delete cascade,
primary key (file_id, name)
);
COMMIT;