|
1 | 1 |
|
2 | 2 | CREATE TABLE db_meta |
3 | | -( key char(30) primary key |
4 | | -, value blob |
| 3 | +( key char(30) primary key |
| 4 | +, value blob |
5 | 5 | ); |
6 | 6 |
|
7 | 7 | INSERT INTO db_meta (key, value) VALUES ('schema_version', 2); |
8 | 8 |
|
9 | 9 | CREATE TABLE textes |
10 | | -( id integer primary key not null |
11 | | -, nature text not null |
12 | | -, num text |
13 | | -, nor char(12) unique -- only used during factorization |
14 | | -, titrefull_s text unique -- only used during factorization |
| 10 | +( id integer primary key not null |
| 11 | +, nature text not null |
| 12 | +, num text |
| 13 | +, nor char(12) unique -- only used during factorization |
| 14 | +, titrefull_s text unique -- only used during factorization |
15 | 15 | , UNIQUE (nature, num) |
16 | 16 | ); |
17 | 17 |
|
18 | 18 | CREATE TABLE textes_structs |
19 | | -( id char(20) unique not null |
20 | | -, versions text |
21 | | -, dossier text not null |
22 | | -, cid char(20) not null |
23 | | -, mtime int not null |
| 19 | +( id char(20) unique not null |
| 20 | +, versions text |
| 21 | +, dossier text not null |
| 22 | +, cid char(20) not null |
| 23 | +, mtime int not null |
24 | 24 | ); |
25 | 25 |
|
26 | 26 | CREATE TABLE textes_versions |
27 | | -( id char(20) unique not null |
28 | | -, nature text |
29 | | -, titre text |
30 | | -, titrefull char(40) |
31 | | -, titrefull_s char(40) |
32 | | -, etat text |
33 | | -, date_debut day |
34 | | -, date_fin day |
35 | | -, autorite text |
36 | | -, ministere text |
37 | | -, num text |
38 | | -, num_sequence int |
39 | | -, nor char(12) |
40 | | -, date_publi day |
41 | | -, date_texte day |
42 | | -, derniere_modification day |
43 | | -, origine_publi text |
44 | | -, page_deb_publi int |
45 | | -, page_fin_publi int |
46 | | -, visas text |
47 | | -, signataires text |
48 | | -, tp text |
49 | | -, nota text |
50 | | -, abro text |
51 | | -, rect text |
52 | | -, dossier text not null |
53 | | -, cid char(20) not null |
54 | | -, mtime int not null |
55 | | -, texte_id int references textes |
| 27 | +( id char(20) unique not null |
| 28 | +, nature text |
| 29 | +, titre text |
| 30 | +, titrefull char(40) |
| 31 | +, titrefull_s char(40) |
| 32 | +, etat text |
| 33 | +, date_debut day |
| 34 | +, date_fin day |
| 35 | +, autorite text |
| 36 | +, ministere text |
| 37 | +, num text |
| 38 | +, num_sequence int |
| 39 | +, nor char(12) |
| 40 | +, date_publi day |
| 41 | +, date_texte day |
| 42 | +, derniere_modification day |
| 43 | +, origine_publi text |
| 44 | +, page_deb_publi int |
| 45 | +, page_fin_publi int |
| 46 | +, visas text |
| 47 | +, signataires text |
| 48 | +, tp text |
| 49 | +, nota text |
| 50 | +, abro text |
| 51 | +, rect text |
| 52 | +, dossier text not null |
| 53 | +, cid char(20) not null |
| 54 | +, mtime int not null |
| 55 | +, texte_id int references textes |
56 | 56 | ); |
57 | 57 |
|
58 | 58 | CREATE INDEX textes_versions_titrefull_s ON textes_versions (titrefull_s); |
59 | 59 | CREATE INDEX textes_versions_texte_id ON textes_versions (texte_id); |
60 | 60 |
|
61 | 61 | CREATE TABLE sections |
62 | | -( id char(20) unique not null |
63 | | -, titre_ta text |
64 | | -, commentaire text |
65 | | -, parent char(20) -- REFERENCES sections(id) |
66 | | -, dossier text not null |
67 | | -, cid char(20) not null |
68 | | -, mtime int not null |
| 62 | +( id char(20) unique not null |
| 63 | +, titre_ta text |
| 64 | +, commentaire text |
| 65 | +, parent char(20) -- REFERENCES sections(id) |
| 66 | +, dossier text not null |
| 67 | +, cid char(20) not null |
| 68 | +, mtime int not null |
69 | 69 | ); |
70 | 70 |
|
71 | 71 | CREATE TABLE articles |
72 | | -( id char(20) unique not null |
73 | | -, section char(20) -- REFERENCES sections(id) |
74 | | -, num text |
75 | | -, etat text |
76 | | -, date_debut day |
77 | | -, date_fin day |
78 | | -, type text |
79 | | -, nota text |
80 | | -, bloc_textuel text |
81 | | -, dossier text not null |
82 | | -, cid char(20) not null |
83 | | -, mtime int not null |
| 72 | +( id char(20) unique not null |
| 73 | +, section char(20) -- REFERENCES sections(id) |
| 74 | +, num text |
| 75 | +, etat text |
| 76 | +, date_debut day |
| 77 | +, date_fin day |
| 78 | +, type text |
| 79 | +, nota text |
| 80 | +, bloc_textuel text |
| 81 | +, dossier text not null |
| 82 | +, cid char(20) not null |
| 83 | +, mtime int not null |
84 | 84 | ); |
85 | 85 |
|
86 | 86 | CREATE TABLE sommaires |
87 | | -( cid char(20) not null |
88 | | -, parent char(20) -- REFERENCES sections |
89 | | -, element char(20) not null -- REFERENCES articles OR sections |
90 | | -, debut day |
91 | | -, fin day |
92 | | -, etat text |
93 | | -, num text |
94 | | -, position int |
95 | | -, _source text -- to support incremental updates |
| 87 | +( cid char(20) not null |
| 88 | +, parent char(20) -- REFERENCES sections |
| 89 | +, element char(20) not null -- REFERENCES articles OR sections |
| 90 | +, debut day |
| 91 | +, fin day |
| 92 | +, etat text |
| 93 | +, num text |
| 94 | +, position int |
| 95 | +, _source text -- to support incremental updates |
96 | 96 | ); |
97 | 97 |
|
98 | 98 | CREATE INDEX sommaires_cid_idx ON sommaires (cid); |
99 | 99 |
|
100 | 100 | CREATE TABLE liens |
101 | | -( src_id char(20) not null |
102 | | -, dst_cid char(20) |
103 | | -, dst_id char(20) |
104 | | -, dst_titre text |
105 | | -, typelien text |
106 | | -, _reversed bool -- to support incremental updates |
| 101 | +( src_id char(20) not null |
| 102 | +, dst_cid char(20) |
| 103 | +, dst_id char(20) |
| 104 | +, dst_titre text |
| 105 | +, typelien text |
| 106 | +, _reversed bool -- to support incremental updates |
107 | 107 | , CHECK (length(dst_cid) > 0 OR length(dst_id) > 0 OR length(dst_titre) > 0) |
108 | 108 | ); |
109 | 109 |
|
110 | 110 | CREATE INDEX liens_src_idx ON liens (src_id) WHERE NOT _reversed; |
111 | 111 | CREATE INDEX liens_dst_idx ON liens (dst_id) WHERE _reversed; |
112 | 112 |
|
113 | 113 | CREATE TABLE duplicate_files |
114 | | -( id char(20) not null |
115 | | -, sous_dossier text not null |
116 | | -, cid char(20) not null |
117 | | -, dossier text not null |
118 | | -, mtime int not null |
119 | | -, data text not null |
120 | | -, other_cid char(20) not null |
121 | | -, other_dossier text not null |
122 | | -, other_mtime int not null |
| 114 | +( id char(20) not null |
| 115 | +, sous_dossier text not null |
| 116 | +, cid char(20) not null |
| 117 | +, dossier text not null |
| 118 | +, mtime int not null |
| 119 | +, data text not null |
| 120 | +, other_cid char(20) not null |
| 121 | +, other_dossier text not null |
| 122 | +, other_mtime int not null |
123 | 123 | , UNIQUE (id, sous_dossier, cid, dossier) |
124 | 124 | ); |
125 | 125 |
|
126 | 126 | CREATE TABLE textes_versions_brutes |
127 | | -( id char(20) unique not null |
128 | | -, bits int not null |
129 | | -, nature text |
130 | | -, titre text |
131 | | -, titrefull text |
132 | | -, autorite text |
133 | | -, num text |
134 | | -, date_texte day |
135 | | -, dossier text not null |
136 | | -, cid char(20) not null |
137 | | -, mtime int not null |
| 127 | +( id char(20) unique not null |
| 128 | +, bits int not null |
| 129 | +, nature text |
| 130 | +, titre text |
| 131 | +, titrefull text |
| 132 | +, autorite text |
| 133 | +, num text |
| 134 | +, date_texte day |
| 135 | +, dossier text not null |
| 136 | +, cid char(20) not null |
| 137 | +, mtime int not null |
138 | 138 | ); |
139 | 139 |
|
140 | 140 | CREATE VIEW textes_versions_brutes_view AS |
|
0 commit comments