Skip to content

Commit

Permalink
Merge branch 'master' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Changaco committed Mar 6, 2017
2 parents 73fd860 + ec69680 commit 0518045
Showing 1 changed file with 95 additions and 95 deletions.
190 changes: 95 additions & 95 deletions legi/sql/schema.sql
Original file line number Diff line number Diff line change
@@ -1,140 +1,140 @@

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)
);

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
Expand Down

0 comments on commit 0518045

Please sign in to comment.