diff --git a/legi/sql/schema.sql b/legi/sql/schema.sql index 7a0ab22..3082f13 100644 --- a/legi/sql/schema.sql +++ b/legi/sql/schema.sql @@ -1,109 +1,109 @@ CREATE TABLE db_meta -( key char(30) primary key -, value blob +( key char(30) primary key +, value blob ); INSERT INTO db_meta (key, value) VALUES ('schema_version', 2); CREATE TABLE textes -( id integer primary key not null -, nature text not null -, num text -, nor char(12) unique -- only used during factorization -, titrefull_s text unique -- only used during factorization +( id integer primary key not null +, nature text not null +, num text +, nor char(12) unique -- only used during factorization +, titrefull_s text unique -- only used during factorization , UNIQUE (nature, num) ); CREATE TABLE textes_structs -( id char(20) unique not null -, versions text -, dossier text not null -, cid char(20) not null -, mtime int not null +( id char(20) unique not null +, versions text +, dossier text not null +, cid char(20) not null +, mtime int not null ); CREATE TABLE textes_versions -( id char(20) unique not null -, nature text -, titre text -, titrefull char(40) -, titrefull_s char(40) -, etat text -, date_debut day -, date_fin day -, autorite text -, ministere text -, num text -, num_sequence int -, nor char(12) -, date_publi day -, date_texte day -, derniere_modification day -, origine_publi text -, page_deb_publi int -, page_fin_publi int -, visas text -, signataires text -, tp text -, nota text -, abro text -, rect text -, dossier text not null -, cid char(20) not null -, mtime int not null -, texte_id int references textes +( id char(20) unique not null +, nature text +, titre text +, titrefull char(40) +, titrefull_s char(40) +, etat text +, date_debut day +, date_fin day +, autorite text +, ministere text +, num text +, num_sequence int +, nor char(12) +, date_publi day +, date_texte day +, derniere_modification day +, origine_publi text +, page_deb_publi int +, page_fin_publi int +, visas text +, signataires text +, tp text +, nota text +, abro text +, rect text +, dossier text not null +, cid char(20) not null +, mtime int not null +, texte_id int references textes ); CREATE INDEX textes_versions_titrefull_s ON textes_versions (titrefull_s); CREATE INDEX textes_versions_texte_id ON textes_versions (texte_id); CREATE TABLE sections -( id char(20) unique not null -, titre_ta text -, commentaire text -, parent char(20) -- REFERENCES sections(id) -, dossier text not null -, cid char(20) not null -, mtime int not null +( id char(20) unique not null +, titre_ta text +, commentaire text +, parent char(20) -- REFERENCES sections(id) +, dossier text not null +, cid char(20) not null +, mtime int not null ); CREATE TABLE articles -( id char(20) unique not null -, section char(20) -- REFERENCES sections(id) -, num text -, etat text -, date_debut day -, date_fin day -, type text -, nota text -, bloc_textuel text -, dossier text not null -, cid char(20) not null -, mtime int not null +( id char(20) unique not null +, section char(20) -- REFERENCES sections(id) +, num text +, etat text +, date_debut day +, date_fin day +, type text +, nota text +, bloc_textuel text +, dossier text not null +, cid char(20) not null +, mtime int not null ); CREATE TABLE sommaires -( cid char(20) not null -, parent char(20) -- REFERENCES sections -, element char(20) not null -- REFERENCES articles OR sections -, debut day -, fin day -, etat text -, num text -, position int -, _source text -- to support incremental updates +( cid char(20) not null +, parent char(20) -- REFERENCES sections +, element char(20) not null -- REFERENCES articles OR sections +, debut day +, fin day +, etat text +, num text +, position int +, _source text -- to support incremental updates ); CREATE INDEX sommaires_cid_idx ON sommaires (cid); CREATE TABLE liens -( src_id char(20) not null -, dst_cid char(20) -, dst_id char(20) -, dst_titre text -, typelien text -, _reversed bool -- to support incremental updates +( src_id char(20) not null +, dst_cid char(20) +, dst_id char(20) +, dst_titre text +, typelien text +, _reversed bool -- to support incremental updates , CHECK (length(dst_cid) > 0 OR length(dst_id) > 0 OR length(dst_titre) > 0) ); @@ -111,30 +111,30 @@ CREATE INDEX liens_src_idx ON liens (src_id) WHERE NOT _reversed; CREATE INDEX liens_dst_idx ON liens (dst_id) WHERE _reversed; CREATE TABLE duplicate_files -( id char(20) not null -, sous_dossier text not null -, cid char(20) not null -, dossier text not null -, mtime int not null -, data text not null -, other_cid char(20) not null -, other_dossier text not null -, other_mtime int not null +( id char(20) not null +, sous_dossier text not null +, cid char(20) not null +, dossier text not null +, mtime int not null +, data text not null +, other_cid char(20) not null +, other_dossier text not null +, other_mtime int not null , UNIQUE (id, sous_dossier, cid, dossier) ); CREATE TABLE textes_versions_brutes -( id char(20) unique not null -, bits int not null -, nature text -, titre text -, titrefull text -, autorite text -, num text -, date_texte day -, dossier text not null -, cid char(20) not null -, mtime int not null +( id char(20) unique not null +, bits int not null +, nature text +, titre text +, titrefull text +, autorite text +, num text +, date_texte day +, dossier text not null +, cid char(20) not null +, mtime int not null ); CREATE VIEW textes_versions_brutes_view AS