--- /dev/null
+-- some test data
+
+insert into catalog_webarchive (path,title,uri) values (
+ '/rest/references/PgGeneratBits/bits',
+ 'PostgreSQL General Bits',
+ 'http://www.varlena.com/varlena/GeneralBits/archive.php'
+);
--- /dev/null
+#!/usr/bin/perl -w
+
+# Helper script to produce alter tables for inherited tables and
+# indexes from source shema
+
+use strict;
+#use Data::Dumper;
+
+my $out;
+
+my ($table, $inherit);
+
+while (<>) {
+ chomp;
+
+ if (/create\s+table\s+(\S+)/i) {
+ $table = $1;
+ }
+
+ next unless ($table);
+
+ if (/primary\s+key\s*\(\s*(\S+)\s*\)/i ) {
+ $out->{table_pk}->{$table} = $1;
+ }
+ if (/^\s*(\S+)\s*.+?--\s*((?:unique\s+)*index)/i) {
+ $out->{index}->{$2}->{$table} = $1;
+ }
+
+ if (/\s*inherits\s*\(\s*(\S+)\s*\)/) {
+ $out->{inherits}->{$table} = $1;
+ }
+
+}
+
+#print STDERR Dumper($out);
+
+foreach my $table (keys %{ $out->{inherits} }) {
+ my $parent = $out->{inherits}->{$table} || die;
+ my $pk = $out->{table_pk}->{$parent} || die;
+ my $seq = $parent . '_' . $pk . '_seq';
+ print qq{alter table $table alter column $pk set default nextval('$seq');\n};
+}
+
+foreach my $type (keys %{ $out->{index} }) {
+ foreach my $table (keys %{ $out->{index}->{$type} }) {
+ my $f = $out->{index}->{$type}->{$table} || die;
+ my $i = $table . '_' . $f . '_ind';
+ print qq{create $type $i on $table($f);\n};
+ }
+}
+
+
--- /dev/null
+-- Catalogs
+create table catalogs (
+ id serial,
+ title text not null,
+ path text,
+ date timestamp not null default now(),
+ primary key(id)
+);
+
+create table catalog_webarchive (
+ uri text not null, -- unique index
+ last_crawled timestamp
+) inherits (catalogs) ;
+
+-- Entries in Catalog
+create table entries (
+ id serial,
+ title text,
+ path text,
+ date timestamp not null default now(),
+ primary key(id)
+);
+
+create table catalog_entry (
+ catalog_id int references catalogs(id),
+ entry_id int references entries(id),
+ e_type text not null, -- index
+ primary key (catalog_id, entry_id)
+);
+
+-- Pg General Bits entries
+create table entries_pgbits (
+ issue int not null -- unique index
+) inherits (entries) ;
+
+-- Items in Entries
+create table items (
+ id serial,
+ title text,
+ entry_id int references entries(id),
+
+ i_type text not null,
+ date timestamp not null default now(),
+ primary key(id)
+);
+
+-- HyperEstraier support table
+create table items_est (
+ path text, -- unique index
+ uri text not null, -- unique index
+ size int
+) inherits (items) ;
+
+-- Tags for Entries
+create table tags (
+ id serial,
+ title text, -- index
+ date timestamp not null default now(),
+ primary key(id)
+);
+
+create table entry_tag (
+ entry_id int references entries(id),
+ tag_id int references tags(id),
+ value text not null,
+ t_type text not null, -- index
+ date timestamp not null default now(),
+ primary key (entry_id, tag_id)
+);
+