Compare commits

...

3 Commits

Author SHA1 Message Date
barnold fe1ae0a240 Drop Makefile.PL, simpler without. 2022-10-15 14:42:49 +01:00
barnold d15be010ad Update the schema-reload script...
and found that DBIx produced multiple definitions for each of the two
result classes.  Edited them by hand to keep one each.
2022-10-15 13:54:14 +01:00
barnold 20a3cc4a04 Update INSTALL. 2022-10-13 18:58:50 +01:00
6 changed files with 41 additions and 534 deletions

28
INSTALL
View File

@ -9,10 +9,14 @@ These are required for loading the catalog data.
For the perl modules,
libdbix-class-perl
libdbix-class-schema-loader-perl
libtest2-suite-perl
libdatetime-format-pg-perl
If you want to alter the tables, this will let your run
bin/make-schema.sh to modify the DBIx-based modules to match.
libdbix-class-schema-loader-perl
1. Preliminary configuration for postgresql
These are one-time things to do, in that you can recreate and reload
@ -59,26 +63,24 @@ as postgres, run
use any of the targets in Makefile.orig to create and load the catalog
database.
$ make -f Makefile.orig PGC_DANGEROUS=1 rebuild-db
$ make -f Makefile.orig load-catalog
$ make PGC_DANGEROUS=1 rebuild-db
$ make load-catalog
At this point, "irulan" should be able to run the tests successfully
with e.g.
$ prove -l
3. To install the perl modules, run (for example)
3. To install the perl modules, run
perl Makefile.PL INSTALL_BASE=~/.local
make test
make install
sudo make install-modules
4. To use these modules from your program, assuming the INSTALL_BASE
suggested above,
which installs under /usr/local/lib/site_perl. Alternatively do e.g.
declare -x PERL5LIB="$HOME/.local/lib/perl5"
make PGC_PERL5LIB=~/.local/lib/perl5 install-modules
and run your program (e.g. pgc-www,
<https://tildegit.org/barnold/pgc-www>).
though you'll probably need to set PER5LIB in this case before using
the modules in your perl code.
Comments and questions welcome at <barnold@tilde.club>.
<barnold@tilde.club>

View File

@ -1,4 +1,4 @@
.PHONY: dangerous drop-db rebuild-db
.PHONY: dangerous drop-db rebuild-db load-catalog install-modules
dangerous:
ifndef PGC_DANGEROUS
@ -18,6 +18,12 @@ rebuild-db: drop-db
--command="COMMIT;"
load-catalog:
psql --username="pgc_owner" pg_book_catalog \
psql --username="pgc_owner" pg_book_catalog \
--command="TRUNCATE TABLE book, author;"
bin/load-gutenberg.pl pg_catalog.csv
PGC_PERL5LIB ?= "/usr/local/lib/site_perl"
install-modules:
install --directory $(PGC_PERL5LIB)
cp --recursive lib/Book $(PGC_PERL5LIB)

View File

@ -1,6 +0,0 @@
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Book',
VERSION_FROM => 'lib/Book/Schema.pm'
);

View File

@ -17,7 +17,7 @@ else
-o dump_directory=./lib \
-o components='["InflateColumn::DateTime"]' \
-o debug=0 \
"Book::Schema" "dbi:Pg:"
"Book::Schema" "dbi:Pg:dbname=pg_book_catalog" pgc_owner
fi
exit 0

View File

@ -50,7 +50,7 @@ __PACKAGE__->table("author");
data_type: 'varchar'
is_nullable: 0
size: 64
size: 128
=cut
@ -64,7 +64,7 @@ __PACKAGE__->add_columns(
is_nullable => 0,
},
"name",
{ data_type => "varchar", is_nullable => 0, size => 64 },
{ data_type => "varchar", is_nullable => 0, size => 128 },
);
=head1 PRIMARY KEY
@ -111,8 +111,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-24 10:45:01
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:shJXsxbKrxkxGu7bwRS+rQ
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-10-13 19:14:12
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:vwoWLTIl4qS7hd6gY1VPqw
# These lines were loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Author.pm' found in @INC.
# They are now part of the custom portion of this file
# for you to hand-edit. If you do not either delete
@ -121,249 +121,5 @@ __PACKAGE__->has_many(
# file again via Loader! See skip_load_external to disable
# this feature.
use utf8;
package Book::Schema::Result::Author;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Book::Schema::Result::Author
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=back
=cut
__PACKAGE__->load_components("InflateColumn::DateTime");
=head1 TABLE: C<author>
=cut
__PACKAGE__->table("author");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 0
=head2 when_created
data_type: 'timestamp with time zone'
default_value: current_timestamp
is_nullable: 0
=head2 name
data_type: 'varchar'
is_nullable: 0
size: 30
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"when_created",
{
data_type => "timestamp with time zone",
default_value => \"current_timestamp",
is_nullable => 0,
},
"name",
{ data_type => "varchar", is_nullable => 0, size => 30 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<author_name_unique>
=over 4
=item * L</name>
=back
=cut
__PACKAGE__->add_unique_constraint("author_name_unique", ["name"]);
=head1 RELATIONS
=head2 books
Type: has_many
Related object: L<Book::Schema::Result::Book>
=cut
__PACKAGE__->has_many(
"books",
"Book::Schema::Result::Book",
{ "foreign.author_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-18 10:43:18
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Qk0Z7HCPs/wL7PMWKSIk0w
1;
# End of lines loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Author.pm'
# These lines were loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Author.pm' found in @INC.
# They are now part of the custom portion of this file
# for you to hand-edit. If you do not either delete
# this section or remove that file from @INC, this section
# will be repeated redundantly when you re-create this
# file again via Loader! See skip_load_external to disable
# this feature.
use utf8;
package Book::Schema::Result::Author;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Book::Schema::Result::Author
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=back
=cut
__PACKAGE__->load_components("InflateColumn::DateTime");
=head1 TABLE: C<author>
=cut
__PACKAGE__->table("author");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 0
=head2 when_created
data_type: 'timestamp with time zone'
default_value: current_timestamp
is_nullable: 0
=head2 name
data_type: 'varchar'
is_nullable: 0
size: 30
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"when_created",
{
data_type => "timestamp with time zone",
default_value => \"current_timestamp",
is_nullable => 0,
},
"name",
{ data_type => "varchar", is_nullable => 0, size => 30 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<author_name_unique>
=over 4
=item * L</name>
=back
=cut
__PACKAGE__->add_unique_constraint("author_name_unique", ["name"]);
=head1 RELATIONS
=head2 books
Type: has_many
Related object: L<Book::Schema::Result::Book>
=cut
__PACKAGE__->has_many(
"books",
"Book::Schema::Result::Book",
{ "foreign.author_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-18 10:43:18
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Qk0Z7HCPs/wL7PMWKSIk0w
1;
# End of lines loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Author.pm'
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;

View File

@ -8,6 +8,15 @@ package Book::Schema::Result::Book;
Book::Schema::Result::Book
=head1 DESCRIPTION
A book present in the catalog of Project Gutenberg,
<https://www.gutenberg.org/>. Book titles are intentionally not unique,
not even within a given author (see for example "Paradise Lost" by John
Milton). In the catalog some titles have no author but for this table
the foreign key to author is required, so there is a bogus "[no author]"
row in the author table.
=cut
use strict;
@ -126,8 +135,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-24 10:45:01
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jn2J3I4s9utgM2u0qwDp3Q
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-10-13 19:14:12
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kNvd5HfYZCAV7yeq+lDGwA
# These lines were loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Book.pm' found in @INC.
# They are now part of the custom portion of this file
# for you to hand-edit. If you do not either delete
@ -136,265 +145,5 @@ __PACKAGE__->belongs_to(
# file again via Loader! See skip_load_external to disable
# this feature.
use utf8;
package Book::Schema::Result::Book;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Book::Schema::Result::Book
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=back
=cut
__PACKAGE__->load_components("InflateColumn::DateTime");
=head1 TABLE: C<book>
=cut
__PACKAGE__->table("book");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 0
=head2 author_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 when_created
data_type: 'timestamp with time zone'
default_value: current_timestamp
is_nullable: 0
=head2 title
data_type: 'varchar'
is_nullable: 0
size: 30
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"author_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"when_created",
{
data_type => "timestamp with time zone",
default_value => \"current_timestamp",
is_nullable => 0,
},
"title",
{ data_type => "varchar", is_nullable => 0, size => 30 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<book_title_unique>
=over 4
=item * L</title>
=back
=cut
__PACKAGE__->add_unique_constraint("book_title_unique", ["title"]);
=head1 RELATIONS
=head2 author
Type: belongs_to
Related object: L<Book::Schema::Result::Author>
=cut
__PACKAGE__->belongs_to(
"author",
"Book::Schema::Result::Author",
{ id => "author_id" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-18 10:43:18
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FYMjLIaXS+mX/Rlzefb8UQ
1;
# End of lines loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Book.pm'
# These lines were loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Book.pm' found in @INC.
# They are now part of the custom portion of this file
# for you to hand-edit. If you do not either delete
# this section or remove that file from @INC, this section
# will be repeated redundantly when you re-create this
# file again via Loader! See skip_load_external to disable
# this feature.
use utf8;
package Book::Schema::Result::Book;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Book::Schema::Result::Book
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 COMPONENTS LOADED
=over 4
=item * L<DBIx::Class::InflateColumn::DateTime>
=back
=cut
__PACKAGE__->load_components("InflateColumn::DateTime");
=head1 TABLE: C<book>
=cut
__PACKAGE__->table("book");
=head1 ACCESSORS
=head2 id
data_type: 'integer'
is_nullable: 0
=head2 author_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 0
=head2 when_created
data_type: 'timestamp with time zone'
default_value: current_timestamp
is_nullable: 0
=head2 title
data_type: 'varchar'
is_nullable: 0
size: 30
=cut
__PACKAGE__->add_columns(
"id",
{ data_type => "integer", is_nullable => 0 },
"author_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
"when_created",
{
data_type => "timestamp with time zone",
default_value => \"current_timestamp",
is_nullable => 0,
},
"title",
{ data_type => "varchar", is_nullable => 0, size => 30 },
);
=head1 PRIMARY KEY
=over 4
=item * L</id>
=back
=cut
__PACKAGE__->set_primary_key("id");
=head1 UNIQUE CONSTRAINTS
=head2 C<book_title_unique>
=over 4
=item * L</title>
=back
=cut
__PACKAGE__->add_unique_constraint("book_title_unique", ["title"]);
=head1 RELATIONS
=head2 author
Type: belongs_to
Related object: L<Book::Schema::Result::Author>
=cut
__PACKAGE__->belongs_to(
"author",
"Book::Schema::Result::Author",
{ id => "author_id" },
{ is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
);
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-09-18 10:43:18
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FYMjLIaXS+mX/Rlzefb8UQ
1;
# End of lines loaded from '/home/nick/.local/lib/perl5/Book/Schema/Result/Book.pm'
# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;