Daizu

 view release on metacpan or  search on metacpan

db.sql  view on Meta::CPAN

        check (last_revnum >= 1),
    constraint file_path_bad_revnums_chk
        check (last_revnum >= first_revnum),
    primary key (guid_id, branch_id, first_revnum)
);
create index file_path_path_idx on file_path (path);
create unique index file_path_unique_idx on file_path (branch_id, path, first_revnum);

create table wc_file (
    id serial primary key,
    wc_id int not null references working_copy on delete cascade,
    guid_id int not null references file_guid,
    parent_id int references wc_file on delete cascade,
    is_dir boolean not null,
    name text not null
        check (name <> '' and name <> '.' and name <> '..' and
               name not like '%/%'),
    path text not null  -- redundant, but probably useful
        check (path <> '' and path not like '/%' and path not like '%/'),
    constraint wc_file_bad_path_and_name_chk
        check (path = name or path like ('%/' || name)),

    -- Revision number the file is based on and changes which have been made

db.sql  view on Meta::CPAN

        check (cur_revnum is not null or (not modified and not deleted)),

    -- Class name of this file's generator.  Either directly from the
    -- 'daizu:generator' property, or inherited from its parent, or taking
    -- the default value.
    generator text not null
        check (generator similar to '[\\_a-zA-Z][-\\_:a-zA-Z0-9]*[\\_a-zA-Z0-9]'),
    -- Files which are their own root file have this set to NULL.  Other
    -- files have it pointing to one of their ancestors, whichever is the
    -- closest to have a 'daizu:generator' property.
    root_file_id int references wc_file on delete cascade,

    custom_url text     -- daizu:url
        check (custom_url similar to '[a-z][-+.a-z0-9]*:%'),

    article boolean not null default false,     -- 'article' type
    retired boolean not null default false,     -- 'retired' flag
    no_index boolean not null default false,    -- 'no-index' flag

    issued_at timestamp not null,
    modified_at timestamp not null,

db.sql  view on Meta::CPAN

    article_content text,
    constraint wc_file_article_loaded_chk
        check ((article and article_content is not null and
                            article_pages_url is not null) or
               (not article and article_content is null and
                                article_pages_url is null))
);
create unique index wc_file_path_idx on wc_file (wc_id, path);

create table wc_property (
    file_id int not null references wc_file on delete cascade,
    name text not null check (name <> ''),
    value text not null,
    modified boolean not null default false,    -- modified or added
    deleted boolean not null default false,
    primary key (file_id, name)
);

create table tag (
    tag text primary key
        check (tag <> '')
);

create table wc_file_tag (
    file_id int not null references wc_file on delete cascade,
    tag text not null references tag,   -- Canonicalized spelling.
    original_spelling text not null,    -- As specified in daizu:tags.
    primary key (file_id, tag)
);

create table wc_article_extra_url (
    file_id int not null references wc_file on delete cascade,
    url text not null,
    content_type text not null
        -- All ASCII characters allowed except 'tspecials' defined in RFC 2045.
        check (content_type similar to '[-!#$\\%&''*+.0-9A-Z^\\_`a-z{|}~]+/[-!#$\\%&''*+.0-9A-Z^\\_`a-z{|}~]+'),
    generator text not null
        check (generator similar to '[\\_a-zA-Z][-\\_:a-zA-Z0-9]*[\\_a-zA-Z0-9]'),
    method text not null
        check (method similar to '[\\_a-zA-Z0-9]+'),
    argument text not null default ''
);

create table wc_article_extra_template (
    file_id int not null references wc_file on delete cascade,
    filename text not null
);

create table wc_article_included_files (
    file_id int not null references wc_file on delete cascade,
    included_file_id int not null
        references wc_file deferrable initially deferred
);

create table url (
    id serial primary key,
    url text not null
        check (url similar to '[a-z][-+.a-z0-9]*:%'),
    wc_id int not null references working_copy on delete cascade,
    guid_id int not null references file_guid,
    generator text not null
        check (generator similar to '[\\_a-zA-Z][-\\_:a-zA-Z0-9]*[\\_a-zA-Z0-9]'),
    method text not null
        check (method similar to '[\\_a-zA-Z0-9]+'),
    argument text not null default '',
    content_type text
        -- All ASCII characters allowed except 'tspecials' defined in RFC 2045.
        check (content_type similar to '[-!#$\\%&''*+.0-9A-Z^\\_`a-z{|}~]+/[-!#$\\%&''*+.0-9A-Z^\\_`a-z{|}~]+'),
    status char(1) not null

db.sql  view on Meta::CPAN

);

 -- TODO - allow for a seperate Latin transliterated name, e.g. for Chinese
create table person (
    id serial primary key,
    username text not null unique       -- UTF-8
        check (username !~ '\s')
);

create table person_info (
    person_id int not null references person on delete cascade,
    path text not null,
    name text not null,                 -- UTF-8
    email text,
    uri text,                           -- person's homepage, or whatever
    primary key (person_id, path)
);

create table file_author (
    file_id int not null references wc_file on delete cascade,
    person_id int not null references person,
    pos int not null,   -- sort on this to get order authors were specified in
    primary key (file_id, person_id)
);

 -- vi:ts=4 sw=4 expandtab

upgrade/0.2/upgrade.pl  view on Meta::CPAN

    add column no_index boolean not null default false
});
print STDERR " * wc_file.short_title\n";
$db->do(q{
    alter table wc_file
    add column short_title text
});
print STDERR " * wc_file.root_file_id\n";
$db->do(q{
    alter table wc_file
    add column root_file_id int references wc_file on delete cascade
});
print STDERR " * wc_file.article_pages_url\n";
$db->do(q{
    alter table wc_file
    add column article_pages_url text
});
print STDERR " * wc_file.article_content\n";
$db->do(q{
    alter table wc_file
    add column article_content text
});
print STDERR " * wc_article_extra_url\n";
$db->do(q<
    create table wc_article_extra_url (
        file_id int not null references wc_file on delete cascade,
        url text not null,
        content_type text not null
            -- All ASCII characters allowed except 'tspecials' defined in RFC 2045.
            check (content_type similar to '[-!#$\\\\%&''*+.0-9A-Z^\\\\_`a-z{|}~]+/[-!#$\\\\%&''*+.0-9A-Z^\\\\_`a-z{|}~]+'),
        generator text not null
            check (generator similar to '[\\\\_a-zA-Z][-\\\\_:a-zA-Z0-9]*[\\\\_a-zA-Z0-9]'),
        method text not null
            check (method similar to '[\\\\_a-zA-Z0-9]+'),
        argument text not null default ''
    );
>);
print STDERR " * wc_article_extra_template\n";
$db->do(q{
    create table wc_article_extra_template (
        file_id int not null references wc_file on delete cascade,
        filename text not null
    );
});
print STDERR " * wc_article_included_files\n";
$db->do(q{
    create table wc_article_included_files (
        file_id int not null references wc_file on delete cascade,
        included_file_id int not null
            references wc_file deferrable initially deferred
    );
});

print STDERR "Rename wc_file.base_url to wc_file.custom_url.\n";
$db->do(q{
    alter table wc_file rename column base_url to custom_url
});



( run in 0.573 second using v1.01-cache-2.11-cpan-49f99fa48dc )