-- ユーザ情報 drop table if exists user_info; create table user_info ( uid varchar(64) not null, -- ユーザID passwd varchar(64) not null, -- パスワード(空でも良い) name varchar(64) not null, -- ユーザ名 can_see enum("yes", "no") default "yes", -- 閲覧許可 can_add enum("yes", "no") default "no", -- 登録追加許可 can_edit enum("yes", "no") default "no", -- 登録変更許可 can_update enum("yes", "no") default "no", -- 手動更新許可 can_del enum("yes", "no") default "no", -- 削除許可 can_config enum("yes", "no") default "no", -- 一般設定変更許可 primary key (uid) ); -- uid 'guest' は特別な意味を持つ: -- [1] ログイン前のユーザはこのユーザであると見做される。 -- [2] このユーザへ改めてログインする事は出来ない。 insert into user_info values ("guest", "", "Guest User", "yes", "no" , "no" , "no" , "no" , "no"), ("root", "", "Root", "yes", "yes", "yes", "yes", "yes", "yes"); -- 對象URL -- これはUIから追加される他、再歸fetchで自動追加される drop table if exists target_url; create table target_url ( urlid bigint unsigned not null auto_increment, -- URL ID url blob not null, -- URL (e.g. http://...) priority enum("high", "normal") default "normal" not null, -- 優先度 label blob, -- ラベル notation blob, -- 註釋 -- 手動での豫約が行はれた時、次の二つのカラムは NULL に設定される。 -- 二つのカラムが NULL であるやうなジョブの實行が開始された時、 -- カラムはそれぞれ -- invoked_by: 同じ行の urlid -- invoked_at: 豫約の行なはれた時刻 -- に設定される。 -- 自動での豫約が行はれようとした時、リンク元の (invoked_by, invoked_at) -- とリンク先のもの(現在豫約しようとしてゐる URL)が全く同じであるなら -- リンクがループしてゐるので豫約を中止する。同じでなければリンク先の -- ものをリンク元のもので上書きした後に豫約を續行する。 invoked_by bigint unsigned, invoked_at datetime, added_date datetime not null, -- このエントリが追加された時刻 last_modified timestamp not null, -- このエントリの最終更新日 -- optionsはData::Dumperでダンプしたハッシュ。 -- キーと値は次の通り。 -- overwrite => 更新時に古いバージョンを消すかどうか -- auto_update_interval => 自動更新を行ふ時、その間隔(分) -- keep_update_on_disappear => ページが消滅しても自動更新を續けるかどうか -- inherit_auto_update => 再歸的に追加されたURLにも自動更新を伝播するかどうか -- recursive_fetch => 再歸取得を行うかどうか -- recursion_level => 再歸取得の深さ制限 -- no_parent => 再歸取得時、親ディレクトリを見るかどうか -- span_hosts => 再歸取得時、他のホストを見るかどうか options blob, primary key (urlid), unique key (url(255)), foreign key (invoked_by) references target_url (urlid) on delete set null on update cascade ); -- ジョブ一覧 drop table if exists job_queue; create table job_queue ( jobid bigint unsigned not null auto_increment, -- ジョブID urlid bigint unsigned not null, -- URL ID status enum("wait", "run", "done") default "wait", -- 状態 begin_time datetime not null, -- ジョブ開始(予定)時刻 -- urlidはUNIQUEにしてはならない。消えてゐないログの爲。 index (urlid), foreign key (urlid) references target_url (urlid) on delete cascade on update cascade, primary key (jobid) ); -- ジョブ實行ログ drop table if exists job_log; create table job_log ( jobid bigint unsigned not null, -- ジョブID urlid bigint unsigned not null, -- URL ID exec_time timestamp not null, -- 實行時刻 message blob not null, -- メッセージ本文 url blob not null, -- URLの複製(urlidが消滅した場合に備へて) index (jobid), foreign key (jobid) references job_queue (jobid) on delete no action on update cascade, index (urlid), foreign key (urlid) references target_url (urlid) on delete no action on update cascade, primary key (jobid, urlid) ); -- 保存されたデータの情報 drop table if exists versions; create table versions ( urlid bigint unsigned not null, -- URL ID version bigint unsigned not null, -- バージョン番號 type enum("checkpoint", "xdelta") default "checkpoint", -- checkpoint: 全體, xdelta: Xdelta差分 timestamp datetime not null, -- このバージョンの日付と時刻 content_type varchar(255), -- 不明ならNULL pieceid bigint unsigned not null, -- このバージョンのPiece ID index (urlid), foreign key (urlid) references target_url (urlid) on delete cascade on update cascade, index (pieceid), -- 勿論UNIQUEではない。 foreign key (pieceid) references pieces_info (pieceid) on delete restrict on update cascade, primary key (urlid, version) ); -- ファイルの實體を示すメタデータ -- これはハードリンクであり、versions_infoから複數回參照される drop table if exists pieces_info; create table pieces_info ( pieceid bigint not null auto_increment, -- Piece ID splits int unsigned default 1, -- 分割數 data_size bigint unsigned default 0, -- このバージョンのデータサイズ(差分であれば差分のサイズ) md5sum char(32) not null, -- MD5 (差分であれば現在の状態のMD5) refcount bigint unsigned not null default 1, -- 參照カウント index (md5sum), primary key (pieceid) ); -- ファイルの實體 drop table if exists pieces_storage; create table pieces_storage ( pieceid bigint unsigned not null, -- Piece ID split bigint unsigned not null, -- 分割番號 content mediumblob not null, -- 内容(16Mib以内) index (pieceid), foreign key (pieceid) references pieces_info (pieceid) on delete restrict on update cascade, primary key (pieceid, split) ); -- 一般設定 drop table if exists config; create table config ( confkey varchar(255) not null, -- キー confvalue blob not null, -- 値 primary key (confkey) ); insert into config values ("httpd.port", "5654"), ("ui.title", "Celaenito"), -- HTMLのタイトルに使用 ("log.limit", "500"); -- 保存するログの數(レコード單位) 0: 無制限 -- HyperEstraier Indexer State DROP TABLE IF EXISTS est_state; CREATE TABLE est_state ( state_key VARCHAR(255) NOT NULL, state_value BLOB NOT NULL, PRIMARY KEY (state_key) ); -- Local Variables: -- sql-product: mysql -- End: